Is there two Datastore instances in the test enviroment?

i am using GWT 1.7, Google Plugin 1.2.2 und Eclipse Galileo. the same Issue
exists in GWT 1.6, Google Plugin 1.2.1 und Eclipse 3.4.

recently i have got a problem like below:

My example is simple:
1.  Create an object and save it,  then use Service to update its value.
2. load it using pm with id direct from Datastore. the Changes doesn't take
effect.
3.  but when i load it using service to retrieve it from datastore, the
Changes take effect.

WorkitemService uses JDO to save the Object of Workitem and update the
Object of Workitem.
Workitem is a class simply saves data.

source code below demonstrate the Problem i got:

private WorkitemServiceImpl wsi = new WorkitemServiceImpl();
PersistenceManager pm = PMF.get().getPersistenceManager();

public void testUpdate() {

try {

Date date = new Date();
                Date date1 = new Date();
                Long user_id = 1L;
     Workitem wi1 = new Workitem("test", 1, "tag", date, user_id);
     pm.makePersistent(wi1);
     Workitem wi2 = pm.detachCopy(wi1);
wi2.setDescription("test1");
 wi2.setTagString("tag1 tag2");
wi2.setDuration(2);
wi2.setDate(date1);
 wsi.update(wi2);
ArrayList<Workitem> workitems = wsi.loadWorkitems(user_id);
 Workitem wi3 = workitems.get(0);
 assertEquals(wi2.getId(), wi3.getId());
assertEquals("test1", wi3.getDescription());
 assertEquals(2, wi3.getDuration());
assertEquals("tag1 tag2", wi3.getTagString());
 assertEquals(date1, wi3.getDate());
    } catch (Exception e) {
     System.out.println(e.toString());
     assertTrue(false);
    } finally {
      pm.close();
    }
}

the test passes. wenn i change the way of fetching the updated Object in the
test case like below, the test can not pass any more.

public void testUpdate() {

try {

Date date = new Date();
                Date date1 = new Date();
                Long user_id = 1L;
      Workitem wi1 = new Workitem("test", 1, "tag", date, user_id);
      pm.makePersistent(wi1);
     Workitem wi2 = pm.detachCopy(wi1);
 wi2.setDescription("test1");
wi2.setTagString("tag1 tag2");
 wi2.setDuration(2);
wi2.setDate(date1);
wsi.update(wi2);
 Workitem wi3 = pm.getObjectById(Workitem.class, wi2.getId());
assertEquals(wi2.getId(), wi3.getId());
 assertEquals("test1", wi3.getDescription());
assertEquals(2, wi3.getDuration());
 assertEquals("tag1 tag2", wi3.getTagString());
assertEquals(date1, wi3.getDate());
     } catch (Exception e) {
     System.out.println(e.toString());
      assertTrue(false);
    } finally {
       pm.close();
    }
}

i did have do what Jason has said:

change

public String getRequestNamespace() {  return "gmail.com";
}

topublic String getRequestNamespace() {
  return "";
}



it doesn't work for me.

so my question is: is there two different Datastore instances in the test
enviroment for GAE? or have i done something wrong?

thanks in advance.

ray

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

Reply via email to