Search code examples
gwttestingoverlays

Testing GWT Overlay types


I am using GWT Overlay Types and am not sure how this could be tested. I would like to somehow ensure that my Overlay object accessors match the field names in the class that is serialized to JSON.

for example

//Class to be serialized to JSON
public class SoCool1 implements SoCool
{
  private String myString;

  public String getMyString()
  {
    return myString;
  }
}

//Overlay class
public class SoCool2 extends JavaScriptObject implements SoCool
{
  public final native String getMyString() /*-{
    return this.myString;
  }-*/;
}

How do I test that the SoCool2 native method return matches the field in SoCool1?


Solution

  • If you want an end-to-end test, use a servlet where you serialize your object to json (put a <servlet> element in your test *.gwt.xml) and call it from your GWTTestCase where you deserialize it as an overlay.