Hi Lads,

This is something has been driving me mad for the last few days. It's
the weirdest issue I've ever come across app engine since I started
using it a while back.

In a nutshell, what' happening is that when I run the simple code
below, which is supposed to get an object by Id within the datastore,
if it doesn't find it, it simply creates an new entity of this kind
and returns it (and of course later on makes it persistent).

Now this code works perfectly when I'm running the app, however, when
I'm unit testing it, a LocaleCache object is always returned from the
datastore even if no entity was ever created. I tried so many
different debugging ideas to try and figure out what was going on and
really I don't know. Even if I delete the datastore file before
running the tests, although no LocaleCache entity was ever created or
stored, when I call " pm.getObjectById(LocaleCache.class, cacheKey);"
a LocaleCache object is always returned.
This is so weird ! And as I said, the strangest is that it only
happens when the code is run as a  unit test.

Any ideas of suggestions of what is going on would be really
appreciated as this issue is slowing us down a lot.

Here is the sample code I'm referring to.

Thanks :-)

private LocaleCache getCache() {
        LocaleCache cache =null;
        Key cacheKey = keyFactory.createLocaleCacheKey(locale,
rightNow, range);
        try {
            cache = pm.getObjectById(LocaleCache.class, cacheKey);
        } catch (JDOObjectNotFoundException e) {
            cache = new LocaleCache();
            cache.setUpCache(range);
            cache.setKey(cacheKey);
        }
        return cache;
    }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to