public class ContextActivationTestCase
{
@Test
public void shouldBeAbleToReceiveObjectAfterReActivation()
{
ManagerTestContext context = new ManagerTestContextImpl();
try
{
Assert.assertFalse(context.isActive());
context.activate();
Assert.assertTrue(context.isActive());
ObjectStore store = context.getObjectStore();
store.add(Boolean.class, true);
Assert.assertEquals(
"Verify that we can get objects from a active context",
new Boolean(true),
store.get(Boolean.class));
context.deactivate();
Assert.assertFalse(context.isActive());
try
{
context.getObjectStore();
Assert.fail("Trying to get ObjectStore outside active context should have thrown Exception");
}
catch (Exception e) {
}
context.activate();
store = context.getObjectStore();
Assert.assertEquals(
"Verify that we can get objects from a active context",
new Boolean(true),
store.get(Boolean.class));
}
finally
{
context.deactivate();
context.destroy();
}
}