Friday, September 28, 2012

GWT Junit Test

Hi.

I want to test a rpc call. I use the standard GWTproject and this testclass:

public class TestGreetingService extends GWTTestCase {
    /**
     * Must refer to a valid module that sources this class.
     */
    public String getModuleName() {
        return "com.TestGreeting";
    }   

    /**
     * This test will send a request to the server using the greetServer method
     * in GreetingService and verify the response.
     */
    public void testGreetingService() {
        // Create the service that we will test.
        GreetingServiceAsync greetingService = GWT
                .create(GreetingService.class);
        ServiceDefTarget target = (ServiceDefTarget) greetingService;
        target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TestGreeting/greet");

        // Since RPC calls are asynchronous, we will need to wait for a response
        // after this test method returns. This line tells the test runner to
        // wait
        // up to 10 seconds before timing out.
        delayTestFinish(20000);

        // Send a request to the server.
        greetingService.greetServer("GWT User", new AsyncCallback<String>() {
            public void onFailure(Throwable caught) {
                // The request resulted in an unexpected error.
                fail("Request failure: " + caught.getMessage());
            }

            public void onSuccess(String result) {
                // Verify that the response is correct.
                assertTrue(result.startsWith("Hello, GWT User!"));

                // Now that we have received a response, we need to tell the
                // test runner
                // that the test is complete. You must call finishTest() after
                // an
                // asynchronous test finishes successfully, or the test will
                // time out.
                finishTest();
            }
        });
    }
}

That's the error I get. Can someone help me?

200 - POST /com.TestGreeting.JUnit/junithost (192.168.1XX.XX) 381 bytes
[WARN] 404 - POST /com.TestGreeting.JUnit/TestGreeting/greet (192.168.1XX.XX) 1427 bytes
   Request headers
      Host: 192.168.1XX.XX:53577
      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19
      Accept-Language: en-us
      Accept: */*
      Connection: Keep-Alive
      Referer: http://192.168.1XX.XX:53577/com.TestGreeting.JUnit/junit-standards.html?gwt.codesvr=192.168.1XX.XX:53572
      X-GWT-Permutation: HostedMode
      X-GWT-Module-Base: http://1192.168.1XX.XX:53577/com.TestGreeting.JUnit/
      Content-Type: text/x-gwt-rpc; charset=utf-8
      Content-Length: 181
   Response headers
      Content-Type: text/html; charset=iso-8859-1
      Content-Length: 1427

--
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/-/FnhdKxTKa5cJ.
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