No, the datastore should be cleared on each test run. What do your setup and
teardown methods look like?

--
Ikai Lan
Developer Programs Engineer, Google App Engine
Blogger: http://googleappengine.blogspot.com
Reddit: http://www.reddit.com/r/appengine
Twitter: http://twitter.com/app_engine



On Mon, Sep 20, 2010 at 6:26 AM, Killian <[email protected]> wrote:

> Ok, so after a few hours of going crazy, I finally found out what was
> going on I think ! :-)
>
> As it turns out, when JUNIT is run, a second "appengine-generated"
> folder instance is created at the root of the project with a parallel
> datastore.
> So, the good news is that the solution is simple, I simply need to
> delete these two directories each time. However, just for the sake, my
> question now is, was that intentionally done? Or is it a setting I
> need to place somewhere in order for the Junit tests to use the same
> datastore as the application?
>
>
>
> On Sep 19, 2:43 pm, Killian <[email protected]> wrote:
> > 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]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
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