Friday, March 2, 2012

Re: GWTTestCase and RequestFactory calls containing client code



On Friday, March 2, 2012 8:45:36 PM UTC+1, Alexander Orlov wrote:
When I call RequestFactory calls containing methods from my GWTTestCase extending JUnit test I always get: 

[WARN] 404 - POST /dp.verp.actas.ActAs.JUnit/gwtRequest (192.168.1.51) 1422 bytes
Mar 2, 2012 7:36:54 PM com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl runJob
SEVERE: Job run failed with unexpected RuntimeException: [object Class JavaObject] (injected script#49)

The code works fine when it runs in DevMode or ProdMode:

void check() {
        ActAsRequest actAsRequest = ActAs.RF.actAsReqCtx();
        actAsRequest.isManager("something").fire(new Receiver<Boolean>() {
            @Override
            public void onSuccess(Boolean response) {
                Core.log(response.toString());
                System.out.println("response = " + response);
            }
        });
    }

GWTTestCase:
public void testIsManager() {
Main main = new Main();
main.check();
}
 
You should rewrite your test to:
  • call delayTestFinish()
  • pass some callback to your check() method to be notified when the response comes back
  • call finishTest() from that callback
I suspect the error comes from the fact the test is actually finished when the response comes back, and that code running outside the tests is causing the whole thing to fail.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/EJBu3ZvHbm8J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment