Exemplo n.º 1
0
  public void testSetData() {
    SelectMultiData data = new SelectMultiData(firstTwo);
    data.setValue(lastTwo);

    assertTrue(
        "SelectMultiData did not set value properly. Maintained old value.",
        !(data.getValue().equals(firstTwo)));
    assertEquals("SelectMultiData did not properly set value ", data.getValue(), lastTwo);

    data.setValue(firstTwo);
    assertTrue(
        "SelectMultiData did not set value properly. Maintained old value.",
        !(data.getValue().equals(lastTwo)));
    assertEquals("SelectMultiData did not properly reset value ", data.getValue(), firstTwo);
  }
Exemplo n.º 2
0
  public void testVectorImmutability() {
    SelectMultiData data = new SelectMultiData(firstTwo);
    Selection[] copy = new Selection[firstTwo.size()];
    firstTwo.copyInto(copy);
    firstTwo.setElementAt(two, 0);
    firstTwo.removeElementAt(1);

    Vector internal = (Vector) data.getValue();

    assertVectorIdentity("External Reference: ", internal, copy);

    data.setValue(lastTwo);
    Vector start = (Vector) data.getValue();

    Selection[] external = new Selection[start.size()];
    start.copyInto(external);

    start.removeElementAt(1);
    start.setElementAt(one, 0);

    assertVectorIdentity("Internal Reference: ", (Vector) data.getValue(), external);
  }
Exemplo n.º 3
0
 public void testNullData() {
   boolean exceptionThrown = false;
   SelectMultiData data = new SelectMultiData();
   data.setValue(firstTwo);
   try {
     data.setValue(null);
   } catch (NullPointerException e) {
     exceptionThrown = true;
   }
   assertTrue(
       "SelectMultiData failed to throw an exception when setting null data", exceptionThrown);
   assertTrue(
       "SelectMultiData overwrote existing value on incorrect input",
       data.getValue().equals(firstTwo));
 }
Exemplo n.º 4
0
  public void testBadDataTypes() {
    boolean failure = false;
    SelectMultiData data = new SelectMultiData(firstTwo);
    try {
      data.setValue(invalid);
      data = new SelectMultiData(invalid);
    } catch (Exception e) {
      failure = true;
    }
    assertTrue(
        "SelectMultiData did not throw a proper exception while being set to invalid data.",
        failure);

    Selection[] values = new Selection[firstTwo.size()];
    firstTwo.copyInto(values);
    assertVectorIdentity("Ensure not overwritten: ", (Vector) data.getValue(), values);
  }