tags:

views:

882

answers:

3

Is there an easy way to invoke a GWT RPC service endpoint directly from Java code? I mean real Java code, not Java code compiled down into javascript.

I ask because we want to run performance benchmarks/stress tests against a GWT RPC interface. I would like to write the test harness in Java and run it in a JVM (as opposed to javascript running in a browser).

I figure there must be a way to do this because I assume GWT Hosted mode requires such functionality. However, I can't really find any code in the GWT runtime that demonstrates how to cleanly do this. I've looked at the com.google.gwt.user.client.rpc package but the stuff in there seems to use JSNI which obviously wouldn't be usable by pure Java.

A: 

You could use a conventional load testing tool like Grinder to replay post requests to your service. That isn't quite what you are asking but it may be a better way to perform load testing on your application. Grinder can simulate many simultaneous users and so on.

David Tinker
+1  A: 

Are you trying to benchmark the business logic of the service, or how well GWT-RPC itself performs? If you are mostly worried about how well your backend code performs, you could just instantiate the class that implements your service directly:

MyServiceImpl impl = new MyServiceImpl();
impl.doSomething();

If you want to test a greater slice of the stack, including the RPC calls, take a look here. There is a section called "running your test in web mode" that has the following line: 'By default, tests run in hosted mode are run as normal Java bytecode in a JVM'. So if you use the described setup, I think you get your tests to run in java by default. Also on that page is info about GWT's built in profiling tools.

Peter Recore
I want to test GWT-RPC itself and the customized dispatch mechanism we have built into our server. I would prefer to not have to use all the scaffolding that the GWT testing infrastructure imposes, but I'll look at the built-in GWT Testing tools that you reference. Thanks!
Eric
A: 

GWT SyncProxy allows you to access GWT RPC services (e.g methods) from pure Java (not JSNI) code. Thus you can use it to test your RPC interface.

See http://www.gdevelop.com/w/blog/2010/01/10/testing-gwt-rpc-services/ for details.

Trung