/**
   * Asserts the use case of specifying null on construction for the detail type of the detail list.
   *
   * @throws Exception
   */
  public void testElementTypeNull() throws Exception {
    WritableValue observableValue =
        new WritableValue(new WritableList(new ArrayList(), Object.class), null);

    WritableListFactory factory = new WritableListFactory();
    DetailObservableList detailObservable =
        new DetailObservableList(factory, observableValue, null);
    assertNull(detailObservable.getElementType());

    // change the type returned from the factory
    factory.type = String.class;
    observableValue.setValue(new WritableList(new ArrayList(), String.class));
    assertNull("element type not null", detailObservable.getElementType());
  }
  /**
   * Asserts that you can't change the type across multiple inner observables.
   *
   * @throws Exception
   */
  public void testElementTypeNotNull() throws Exception {
    WritableValue observableValue =
        new WritableValue(new WritableList(new ArrayList(), Object.class), null);

    WritableListFactory factory = new WritableListFactory();
    DetailObservableList detailObservable =
        new DetailObservableList(factory, observableValue, Object.class);
    assertEquals(factory.type, detailObservable.getElementType());

    try {
      factory.type = String.class;
      observableValue.setValue(
          new WritableList(Arrays.asList(new Object[] {new Object()}), String.class));
      fail("if an element type is set this cannot be changed");
    } catch (AssertionFailedException e) {
    }
  }
  /**
   * Asserts that the master observable value is not disposed upon disposing its detail observable
   * value (bug 241318).
   */
  public void testMasterNotDisposedWhenDetailDisposed() {
    class OuterObservable extends WritableValue {
      boolean disposed = false;

      @Override
      public synchronized void dispose() {
        disposed = true;
        super.dispose();
      }
    }

    OuterObservable outerObservable = new OuterObservable();
    WritableListFactory factory = new WritableListFactory();
    DetailObservableList detailObservable =
        new DetailObservableList(factory, outerObservable, null);

    assertFalse(outerObservable.disposed);

    detailObservable.dispose();
    assertFalse(outerObservable.disposed);
  }