Revision: 8902
Author: [email protected]
Date: Thu Sep 30 07:03:25 2010
Log: 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
Review at http://gwt-code-reviews.appspot.com/936801
http://code.google.com/p/google-web-toolkit/source/detail?r=8902
Modified:
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java
/trunk/user/test/com/google/gwt/requestfactory/server/SimpleFoo.java
/trunk/user/test/com/google/gwt/requestfactory/shared/SimpleFooRequest.java
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java
Wed Sep 29 11:01:14 2010
+++
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java
Thu Sep 30 07:03:25 2010
@@ -268,6 +268,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);
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/server/SimpleFoo.java
Fri Sep 24 12:10:50 2010
+++ /trunk/user/test/com/google/gwt/requestfactory/server/SimpleFoo.java
Thu Sep 30 07:03:25 2010
@@ -44,6 +44,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() {
return Collections.singletonList(get());
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/shared/SimpleFooRequest.java
Wed Sep 29 21:51:38 2010
+++
/trunk/user/test/com/google/gwt/requestfactory/shared/SimpleFooRequest.java
Thu Sep 30 07:03:25 2010
@@ -29,6 +29,10 @@
@Instance
Request<Long> countSimpleFooWithUserNameSideEffect(SimpleFooProxy proxy);
+ Request<SimpleFooProxy> echo(SimpleFooProxy proxy);
+
+ Request<SimpleFooProxy> echoComplex(SimpleFooProxy fooProxy,
SimpleBarProxy barProxy);
+
Request<List<SimpleFooProxy>> findAll();
Request<SimpleFooProxy> findSimpleFooById(Long id);
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors