I'm currently trying to create a test class but somehow it fails.
Here is a little example:

        PersistenceManager pm = 
getPersistenceManagerFactory().getPersistenceManager();
        pm.currentTransaction().begin();
        UserJDO userj = new UserJDO();
        userj.setKey("dummy");
        String key = pm.makePersistent(userj).getKey();
        pm.currentTransaction().commit();
        pm.close();
        
        pm = getPersistenceManagerFactory().getPersistenceManager();
        UserJDO usr=(UserJDO)pm.getObjectById(key);

My problem is that it fails at the line with getObjectById.
Normaly the Object should be stored on my datastore but somehow this does 
not work during tests.
(although same code works if i test it through my browser)
I really don't get what i'm doing wrong.
I already searched through the web and found a site that described it: 
http://blog.appenginefan.com/2009/05/jdo-and-unit-tests.html
I'm using the functions described there because the normal way didn't 
work,too.(JDOHelper.getPersistenceManagerFactory("transactions-optional").getPersistenceManager()
 
produced the same problem)
It's important for me to have some test classes to test my programmed stuff 
before deployment.

If its possible it would be best if i somehow could test methods against 
existing data but without changing anything on my local test database.

Hope someone can help me with this.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/5Kbg20jxRz0J.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to