Reviewers: rjrjr,

Description:
Add tests to verify that proxies created on the client side can be sent
across the wire, both in requests and responses. The tests are disabled
for now since we cannot handle futures in responses. Will enable the
tests once the fixes are in place.

Patch by: amitmanjhi
Review by: rjrjrj

Please review this at http://gwt-code-reviews.appspot.com/936801/show

Affected files:
  M user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java
  M user/test/com/google/gwt/requestfactory/server/SimpleFoo.java
  M user/test/com/google/gwt/requestfactory/shared/SimpleFooRequest.java


Index: user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java
===================================================================
--- user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java (revision 8897) +++ user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java (working copy)
@@ -269,6 +269,46 @@
     });
   }

+  public void disabled_testEchoSimpleFutures() {
+    // tests if futureIds can be echoed back.
+    delayTestFinish(5000);
+ final SimpleFooEventHandler<SimpleFooProxy> handler = new SimpleFooEventHandler<SimpleFooProxy>();
+    EntityProxyChange.registerForProxyType(req.getEventBus(),
+        SimpleFooProxy.class, handler);
+    final SimpleFooProxy simpleFoo = req.create(SimpleFooProxy.class);
+    req.simpleFooRequest().echo(simpleFoo).fire(
+        new Receiver<SimpleFooProxy>() {
+          @Override
+          public void onSuccess(SimpleFooProxy response) {
+            assertEquals(0, handler.totalEventCount);
+            checkStableIdEquals(simpleFoo, response);
+            finishTestAndReset();
+          }
+        });
+  }
+
+  public void disabled_testEchoComplexFutures() {
+ // relate futures on the server. Check if the relationship is still present on the client.
+    delayTestFinish(5000);
+ final SimpleFooEventHandler<SimpleFooProxy> handler = new SimpleFooEventHandler<SimpleFooProxy>();
+    EntityProxyChange.registerForProxyType(req.getEventBus(),
+        SimpleFooProxy.class, handler);
+    final SimpleFooProxy simpleFoo = req.create(SimpleFooProxy.class);
+    final SimpleBarProxy simpleBar = req.create(SimpleBarProxy.class);
+    req.simpleFooRequest().echoComplex(simpleFoo, simpleBar).fire(
+        new Receiver<SimpleFooProxy>() {
+          @Override
+          public void onSuccess(SimpleFooProxy response) {
+            assertEquals(0, handler.totalEventCount);
+            checkStableIdEquals(simpleFoo, response);
+            SimpleBarProxy responseBar = response.getBarField();
+            assertNotNull(responseBar);
+            checkStableIdEquals(simpleBar, responseBar);
+            finishTestAndReset();
+          }
+        });
+  }
+
   public void testFetchEntity() {
     delayTestFinish(5000);
     req.simpleFooRequest().findSimpleFooById(999L).fire(
Index: user/test/com/google/gwt/requestfactory/server/SimpleFoo.java
===================================================================
--- user/test/com/google/gwt/requestfactory/server/SimpleFoo.java (revision 8897) +++ user/test/com/google/gwt/requestfactory/server/SimpleFoo.java (working copy)
@@ -43,6 +43,15 @@

   public static Long countSimpleFoo() {
     return 1L;
+  }
+
+  public static SimpleFoo echo(SimpleFoo simpleFoo) {
+    return simpleFoo;
+  }
+
+ public static SimpleFoo echoComplex(SimpleFoo simpleFoo, SimpleBar simpleBar) {
+    simpleFoo.setBarField(simpleBar);
+    return simpleFoo;
   }

   public static List<SimpleFoo> findAll() {
Index: user/test/com/google/gwt/requestfactory/shared/SimpleFooRequest.java
===================================================================
--- user/test/com/google/gwt/requestfactory/shared/SimpleFooRequest.java (revision 8897) +++ user/test/com/google/gwt/requestfactory/shared/SimpleFooRequest.java (working copy)
@@ -28,6 +28,10 @@

   @Instance
   Request<Long> countSimpleFooWithUserNameSideEffect(SimpleFooProxy proxy);
+
+  Request<SimpleFooProxy> echo(SimpleFooProxy proxy);
+
+ Request<SimpleFooProxy> echoComplex(SimpleFooProxy fooProxy, SimpleBarProxy barProxy);

   Request<List<SimpleFooProxy>> findAll();



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

Reply via email to