Monday, November 29, 2010

GWTTestCase: Unable to access objects returned from a successful RPC call

I've got a project I'm working on where I make an RPC call to the
server which calls a webservice on a different domain, gets some XML,
parses it, and then returns to me a Java object.

Now I'm trying to unit test this and I'm running into a problem where
my Java object is "not accessible" after it's been returned by the
server. That is, in my onSuccess(MyJavaObject result) method in my
GWTTestCase, I cannot say: result.getSomeData(). Doing this results
in something kinda funny...the test just finishes. It doesn't execute
any lines of code after that line, and it does not cause the test to

Here's a snippet of my code:
public void testGetSomeData() {
MyServiceAsync svc = MyService.Util.getInstance();
AsyncCallback<MyJavaObject > callback = new
AsyncCallback<MyJavaObject >() {
public void onFailure(Throwable caught) {
public void onSuccess(MyJavaObject result) {
System.out.println(result.getSomeData()); // <option 1>

System.out.println("Foo"); // <option 2>

svc.getSomeData("parameter", callback);

Now if I run this as it's written above, "Foo" does NOT get printed.
However, if I run this without the line marked <option 1>, then "Foo"
DOES get printed.

Is this a limitation to the GWTTestCase, or something that I'm
missing? Also, something to note, if MyJavaObject happens to be of
type String, I can say System.out.println(result); and it will print
the string returned from the server call.


You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment