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); }
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); }
@Override public void dispose() { Disposer.dispose(this); super.dispose(); }
private void assertDisposed(MyDisposable disposable) { assertTrue(disposable.isDisposed()); assertFalse(disposable.toString(), Disposer.getTree().containsKey(disposable)); Disposer.getTree().assertNoReferenceKeptInTree(disposable); }