To make clearer what I mean with "not predictable", I post part of a
test method:
[...]
try{
pm.makePersistent(persistent);
saved = persistent.getKey();
}
finally{
pm.close();
}
[...]
If I run the test, it fails.
If I modify *just that* portion of code stating
[...]
try{
pm.makePersistent(persistent);
saved = persistent.getKey();
}
finally{
if (pm.currentTransaction().isActive()){
pm.currentTransaction().rollback();
}
pm.close();
}
[...]
And run the test again (nothing else changes in my JUnit test nor in
data model), it passes.
If i run again the test (no further code modifications) it fails like
the first time.
This may be a problem in my test configurations, I guess.If this can
help, general config for my unit test is
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new
LocalDatastoreServiceTestConfig());
private static final PersistenceManagerFactory pmf =
JDOHelper.getPersistenceManagerFactory("transactions-optional");
@Before
public void setUp() throws Exception {
helper.setUp();
}
@After
public void tearDown() throws Exception {
helper.tearDown();
}
Hope this can better identify the issue.
Regards
Lorenzo
On Oct 13, 12:21 pm, "l.denardo" <[email protected]> wrote:
> Hello everybody,
> I'm facing a really annoying issue which I stepped into.
>
> My unit tests (JDO) sometimes throw a
> ClassCastException: oid is not instanceof
> javax.jdo.identity.ObjectIdentity
>
> The most annoying fact is that this is not reproducible in a
> predictable way.
> The very same JUnit test (using the App Engine testing suite) throws
> this error, then stops, then throws it again.
>
> I got this error for a while, tried to set up a simpler data model to
> reproduce it, without success (all tests on simplified model passed
> without errors).
> Then i re-run the failed test, and it completed successfully *without
> any code modifications*.
>
> Looks like this behavior is difficult to reproduce and appears to
> happen quite
> randomly:http://groups.google.com/group/google-appengine-java/browse_thread/th...
>
> If anyone has advice about the reasons for this behavior, it would be
> a great help.
> It makes testing a data model unreliable, so I would like to
> understand if this is a bug in the test cases or something due to
> particular data models, to modify my classes accordingly.
>
> Thanks for your help
> Lorenzo
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" 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-java?hl=en.