How do I test gwt requestbuilder with junit in gwttestcase?

My GWT application contains data that needs to be read from client side xml files. For this I am using RequestBuilder.

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,GWT.getHostPageBaseURL()+"myFile.xml");

      

try {builder.sendRequest (null, new RequestCallback () {@Override public void onResponseReceived (request request, response response) {

       // read out data and put into to a list

   }

      

}); .........

The data will be read out, put into a list, and from that list, data will be put into the view. How can I check this? When I try this in a GWTTestCase class with some assertEquals methods inside onResponseReceived I get this error message:

[WARN] 404 - GET / com.test.app.appName.JUnit / myFile.xml (192.168.2.102) 1466 bytes Request headers Host: 192.168.2.102:51731 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: ht t_p: //192.168.2.102: 51731 / com. test.app.appName.JUnit / junit-standards.html? Gwt.codesvr = 192.168.2.102: 51727 Content-Type: text / plain; encoding = UTF-8 Response headers Content-Type: text / html; encoding = iso-8859-1 Content-Length: 1466

What am I doing wrong? Please, help.

+3


source to share


1 answer


You should watch out for the GWT test code for RequestBuilder available in their source code. You can search RequestBuilder test cases.



Also in your case, you might be best off using mock to avoid slowing down your test cases.

0


source







All Articles