Revision: 8927
Author: [email protected]
Date: Sun Oct  3 14:17:43 2010
Log: Fix ClassCastException in AbtstractRequestContext.isChanged();
Patch by: bobv
Review by: rjrjr

Review at http://gwt-code-reviews.appspot.com/931803

http://code.google.com/p/google-web-toolkit/source/detail?r=8927

Modified:
/trunk/user/src/com/google/gwt/requestfactory/client/impl/AbstractRequestContext.java /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java

=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/client/impl/AbstractRequestContext.java Sun Oct 3 08:48:15 2010 +++ /trunk/user/src/com/google/gwt/requestfactory/client/impl/AbstractRequestContext.java Sun Oct 3 14:17:43 2010
@@ -142,13 +142,13 @@
     /*
      * NB: Don't use the presence of ephemeral objects for this test.
      *
- * Diffing the objects until one is found to be different. It's not just a
+     * Diff the objects until one is found to be different. It's not just a
* simple flag-check because of the possibility of "unmaking" a change, per
      * the JavaDoc.
      */
     for (EntityProxy edited : seenProxies.values()) {
       AutoBean<EntityProxy> bean = AutoBeanUtils.getAutoBean(edited);
- AutoBean<?> previous = AutoBeanUtils.getAutoBean((EntityProxy) bean.getTag(PARENT_OBJECT));
+      AutoBean<?> previous = bean.getTag(PARENT_OBJECT);
       if (previous == null) {
         // Compare to empty object
         previous = getRequestFactory().getAutoBeanFactory().create(
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Sun Oct 3 08:48:15 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Sun Oct 3 14:17:43 2010
@@ -190,7 +190,6 @@

   /**
    * Test that we can commit child objects.
-
    */
   public void testCascadingCommit() {
     delayTestFinish(5000);
@@ -238,6 +237,40 @@
     foo.setCharField(null);
     assertFalse(context.isChanged());
   }
+
+  public void testChangedEdit() {
+    delayTestFinish(5000);
+    simpleFooRequest().findSimpleFooById(1L).fire(
+        new Receiver<SimpleFooProxy>() {
+
+          @Override
+          public void onSuccess(SimpleFooProxy foo) {
+            SimpleFooRequest context = simpleFooRequest();
+
+            // edit() doesn't cause a change
+            foo = context.edit(foo);
+            assertFalse(context.isChanged());
+
+            final String newName = "something else;";
+            String oldName = foo.getUserName();
+            assertFalse("Don't accidentally set the same name",
+                newName.equals(oldName));
+
+            // gets don't cause a change
+            assertFalse(context.isChanged());
+
+            // Change
+            foo.setUserName(newName);
+            assertTrue(context.isChanged());
+
+            // Undo the change
+            foo.setUserName(oldName);
+            assertFalse(context.isChanged());
+
+            finishTestAndReset();
+          }
+        });
+  }

   public void testClassToken() {
     String token = req.getHistoryToken(SimpleFooProxy.class);

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to