예제 #1
0
  public void testOverrideParentDisposable() throws Exception {
    Disposer.register(myFolder1, myLeaf1);
    Disposer.register(myFolder2, myFolder1);
    Disposer.register(myRoot, myFolder1);

    Disposer.dispose(myFolder2);

    assertDisposed(myFolder2);
    assertFalse(myLeaf1.isDisposed());
    assertFalse(myFolder1.isDisposed());

    Disposer.dispose(myRoot);
    assertDisposed(myFolder1);
    assertDisposed(myLeaf1);
  }
예제 #2
0
  public void testDisposalAndAbsenceOfReferences() throws Exception {
    Disposer.register(myRoot, myFolder1);
    Disposer.register(myRoot, myFolder2);
    Disposer.register(myFolder1, myLeaf1);

    Disposer.dispose(myFolder1);
    assertFalse(myRoot.isDisposed());
    assertDisposed(myFolder1);
    assertDisposed(myLeaf1);
    assertFalse(myFolder2.isDisposed());

    Disposer.dispose(myRoot);
    assertDisposed(myRoot);
    assertDisposed(myFolder2);

    Disposer.dispose(myLeaf1);
  }
예제 #3
0
 @Override
 public void dispose() {
   Disposer.dispose(this);
   super.dispose();
 }
예제 #4
0
  private void assertDisposed(MyDisposable disposable) {
    assertTrue(disposable.isDisposed());
    assertFalse(disposable.toString(), Disposer.getTree().containsKey(disposable));

    Disposer.getTree().assertNoReferenceKeptInTree(disposable);
  }