ManagerImpl manager = ManagerBuilder.from()
.context(SuiteContextImpl.class)
.context(ClassContextImpl.class).create();
SuiteContext suiteContext = manager.getContext(SuiteContext.class);
ClassContext classContext = manager.getContext(ClassContext.class);
try
{
suiteContext.activate();
classContext.activate(this.getClass());
Object testObject = new Object();
manager.bind(SuiteScoped.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(this.getClass());
suiteContext.deactivate();
suiteContext.destroy();
}
}