@@ -0,0 +1,2060 @@
+/**%0A * %3CLicense%3E%0A */%0Apackage edu.colorado.csdms.wmt.client;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport com.google.gwt.core.client.JsArrayString;%0Aimport com.google.gwt.junit.client.GWTTestCase;%0A%0Aimport edu.colorado.csdms.wmt.client.data.ComponentListJSO;%0A%0A/**%0A * Tests for %7B@link ComponentListJSO%7D. JUnit integration is provided by%0A * extending %7B@link GWTTestCase%7D.%0A * %0A * @see http://www.gwtproject.org/doc/latest/DevGuideTesting.html%0A * @see http://www.gwtproject.org/doc/latest/tutorial/JUnit.html%0A * @see http://blog.danielwellman.com/2008/08/testing-json-parsing-using-javascript-overlay-types-in-gwt-15.html%0A * @author Mark Piper (mark.piper@colorado.edu)%0A */%0Apublic class ComponentListJSOTest extends GWTTestCase %7B%0A%0A  private ComponentListJSO jso;%0A  private JsArrayString ids;%0A  %0A  /**%0A   * The module that sources this class. Must be present.%0A   */%0A  @Override%0A  public String getModuleName() %7B%0A     return %22edu.colorado.csdms.wmt.WMT%22;%0A  %7D%0A  %0A  /**%0A   * A JSNI method that defines a fixture for the tests. Returns a%0A   * %7B@link ComponentListJSO%7D object for testing.%0A   * %0A   * @param ids%0A   */%0A  private native ComponentListJSO testComponentListJSO(JsArrayString ids) /*-%7B%0A%09%09return ids;%0A  %7D-*/;  %0A  %0A  @Before%0A  @Override%0A  protected void gwtSetUp() throws Exception %7B%0A    ids = (JsArrayString) JsArrayString.createObject();%0A    ids.setLength(3);%0A    ids.push(%22avulsion%22);%0A    ids.push(%22cem%22);%0A    ids.push(%22hydrotrend%22);%0A    jso = testComponentListJSO(ids);%0A  %7D%0A%0A  @After%0A  @Override%0A  protected void gwtTearDown() throws Exception %7B%0A  %7D%0A%0A  // Test the length of the array.%0A  @Test%0A  public void testLength() %7B%0A    int arrayLength = 3;%0A    assertEquals(arrayLength, jso.getComponents().length());%0A  %7D%0A%0A  // Test whether all ids can be retrieved.%0A  @Test%0A  public void testGetIds() %7B%0A    assertEquals(ids, jso.getComponents());%0A  %7D%0A%0A  // Test whether a single id can be retrieved.%0A  @Test%0A  public void testGetSingleId() %7B%0A    int index = 0;%0A    assertEquals(ids.get(index), jso.getComponents().get(index));%0A  %7D%0A%7D%0A

Add ComponentListJSOTest