MyDisposable disposable = (MyDisposable ) ipc.getComponentInstance(MyDisposable.class);
assertTrue(disposable.disposed);
}
public void testFacetiouslyThatLifeCycleGuardPreventsCyclingOfChildContainersAsComponentsAreNotTheOnlyThingsThatAreLifecycleable() {
DefaultPicoContainer parent = new DefaultPicoContainer();
MutablePicoContainer child = parent.makeChildContainer();
parent.registerComponentImplementation("foo", MyDisposable.class);
child.registerComponentImplementation("bar", MyDisposable.class);
ImmutablePicoContainer ipc = new ImmutablePicoContainer(parent);
try {
ipc.dispose();
fail("Should have barfed");
} catch (UnsupportedOperationException e) {
// expected
}
MyDisposable parentDisposable = (MyDisposable) parent.getComponentInstance("foo");
assertFalse(parentDisposable.disposed);
MyDisposable childDisposable = (MyDisposable) child.getComponentInstance("bar");
assertFalse(childDisposable.disposed);