GWTTestCase and RequestFactory calls containing client code

173 views
Skip to first unread message

Alexander Orlov

unread,
Mar 2, 2012, 2:45:36 PM3/2/12
to google-we...@googlegroups.com
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();
}

Thomas Broyer

unread,
Mar 2, 2012, 4:31:13 PM3/2/12
to google-we...@googlegroups.com
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.

Alexander Orlov

unread,
Mar 2, 2012, 5:24:42 PM3/2/12
to google-we...@googlegroups.com
Delays or enforcing an execution order doesn't help. I think the problem is 

"[WARN] 404 - POST /dp.verp.planer.Planer.JUnit/gwtRequest (192.168.1.51) 1424 bytes"

If I'd get this message in DevMode I'd fix web.xml's servlet-mapping but what's the equivalent of the servlet-mapping when using GWTTestCase? The WARN message occurs exactly when calling fire(). When calling fire() always 

            @Override
            public void onFailure(ServerFailure error) {
            }

is entered, instead of 

            @Override
            public void onSuccess(MyType response) {

Alexander Orlov

unread,
Mar 2, 2012, 7:42:13 PM3/2/12
to google-we...@googlegroups.com
I guess, you're running your GWTTestCases with Eclipse? I'm using IntelliJ and when I run the test cases, no folder like dp.verp.planer.Planer.JUnit is being created. However this folder is created when running the test cases with Eclipse (although they failed for other, Eclipse-specific reasons). Also this folder name corresponds to the missing "servlet-mapping"... And the GWT Maven plugin doesn't even find any tests at all.

Alexander Orlov

unread,
Mar 2, 2012, 8:39:16 PM3/2/12
to google-we...@googlegroups.com
Solution:

<servlet path="/gwtRequest" class="com.google.web.bindery.requestfactory.server.RequestFactoryServlet"/> in the *.gwt.xml is your/my friend.

Reply all
Reply to author
Forward
0 new messages