Hi all. I really want to use RPC synchronic calls for creating simple to read automated tests against my model classes services. *** I don't want to use RPC calls synchronically on production code, only on my automated tests. ****
In my particular case, I think it is a common case, I have some RPC services that perform CRUD operations on some model class. (behind there is appengine datastore and objectify, but that isn't part of the problem).
I want to write test units that, for example, add some entities through RPC, delete, search and update the entities and make some asserts for making sure it works (like a DAO automated test in common j2ee applications).
The problem is that because of the asynchronic nature of GWT RPC it is very hard to write such tests cases. For example, writing a simple use case test like "1) save a new entity, 2) get the entity and check it was saved/loaded ok 3) update the entity and assert it was updated ok, 4) delete the entity and assert it was deleted ok" take five or more anidated rpc callbacks. and more complicated uses cases code are almost impossible to write/ read.
I have created a simple "Synchronic queue" so I can execute each stage of the test more asynchronically and thus more readable. But still kind of complicated, see
http://code.google.com/p/yuigwt/source/browse/madrenecesidad/src/org/sgx/madrenecesidad/client/test/tests/ChannelServiceTest1.java#41In this case, synchronic RPC would be ideal:
service.addMyEntity(new MyEntity(...));
assertTrue(service.listMyEntities().size()==1);
MyEntity e = service.getEntityByName("name");
assertTrue(e.getName.equals("...));
service.deleteMyEntity(e);
assertTrue(service.listMyEntities().size()==0);
etc.
There is a project called
http://code.google.com/p/gwt-syncproxy/ that claims to support synch rpc calls just like I want, but it do not seems to be supported anymore and the .jar do not contain any GWT module
My question to you all is, is there a way of facilitating the writing of automated testcases for testing RPC services ? How do you do that ? I bet GWT brings something for this case after all automated testing on RPC services should be a common tasks for GWTers.... but I can't figure out.
Thanks in advance, any suggestion is most welcome.