ManagerImpl manager = (ManagerImpl)ManagerBuilder.from()
.context(ManagerTestContextImpl.class)
.context(ManagerTest2ContextImpl.class).create();
ManagerTestContext suiteContext = manager.getContext(ManagerTestContext.class);
ManagerTest2Context classContext = manager.getContext(ManagerTest2Context.class);
try
{
suiteContext.activate();
classContext.activate("A");
Object testObject = new Object();
manager.bind(ManagerTestScoped.class, Object.class, testObject);
Assert.assertEquals(
"Verify value was bound to the correct context",
testObject,
suiteContext.getObjectStore().get(Object.class));
Assert.assertNull(
"Verify value was not bound to any other context",
classContext.getObjectStore().get(Object.class));
}
finally
{
classContext.deactivate();
classContext.destroy("A");
suiteContext.deactivate();
suiteContext.destroy();
}
}