Hello,
You have to use the LocalServiceTestHelper class to manage datastore,memcache, task queues and etc.

Here is one example that could help you find out how to use it:

class UserServiceImplTest  extends TestCase {
  private  LocalServiceTestHelper helper = new LocalServiceTestHelper(
              new LocalDatastoreServiceTestConfig(),
              new LocalMemcacheServiceTestConfig(),
              new LocalURLFetchServiceTestConfig());

  @Override
  public void setUp() {
     helper.setUp();
  }

  @Override
  protected void tearDown() throws Exception {
    helper.tearDown();
  }

  public void testAddsNewUser() {
        User user = new User("test","test");
        new UserServiceImpl().addUser(user);
        assertUserExists(user);
  }
   .....
}

Please note that there is an excellent presentation about testing from google io and you can check it out at: http://code.google.com/events/io/2010/sessions/testing-techniques-app-engine.html

Regards,
  Miroslav

On 07/12/2010 01:08 PM, poe wrote:
Hi everyone,

i want to test a remoteService that performs operations on a datastore
with jdo. For example:

public class UserServiceImpl extends RemoteServiceServlet implements
                UserService {

   public User addUser(User u) {
     PersistenceManager pm = PMF.get().getPersistenceManager();
     try {
       pm.makePersistent(u);
     } finally {
       pm.close();
     }
     return u;

   };
   public User updateUser(User u) {
     ...
   }
   ...
}

how can i implement a test case, that tests the listed operations, so
that the datastore operations didn't effect my development datastore
(maybe does some memcache operations or so?). I hope you get what i
mean :-) tell me if you need more information.

Thanks and greetings,
Poe


--
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 google-appengine-j...@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