Hi there, I'm trying to use JSNI from within a GWTTestCase. The JavaScript object is returned via a JSON response from a servlet I have running for the test. I then eval the JSON and assert the corresponding overlay object's value. Firstly, does this sound like a reasonable thing to do from within GWTTestCase?
Here's my relevant bits of code. I have declared a parameterised class to handle JSON payloads with the parameter representing the type of JavaScriptObject I want to evaluate to: public abstract class JSONRequestCallback<T extends JavaScriptObject> implements RequestCallback { private final native T evalJSON(String jsonText) /*-{ return eval(jsonText); }-*/; @Override public void onResponseReceived(Request request, Response response) { String responseText = response.getText(); onResponseReceived(request, evalJSON(responseText)); } /** * Handle a JSON payload response. * * @param request * the original request object. * @param response * the JSON response marshalled as a JavaScript object. */ public abstract void onResponseReceived(Request request, T response); } To call it I issue an HTTP request with the callback provided like this in my test: new JSONRequestCallback<JsArray<SomeModelObject>>() { @Override public void onError(Request request, Throwable exception) { fail("Should not get here."); } @Override public void onResponseReceived(Request request, JsArray<SomeModelObject> deals) { // TODO Validate the response. assertEquals(1, deals.length()); SomeModelObject bo = deals.get(0); assertEquals("A", bo.getAccountProductType()); finishTest(); } }); SomeBusinessObject is an overlay class with getAccountProductType declared as follows: public final native String getAccountProductType() /*-{ return this.accountProductType; }-*/; Unfortunately for me, the second assertion (for "A") fails. The servlet definitely responds correctly and I can see via the debugger that eval is being performed on the JSON response. Any guidance is most appreciated. Kind regards, Christopher -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.