protected void destroyContext(Context context) { getCurrentConfiguration().getContexts().destroyContext(context); }
public Tarantula() { dependentContextActive = ConfigurationFactory.get(JSR299Configuration.class).getContexts().getDependentContext().isActive(); }
protected void setContextActive(Context context) { getCurrentConfiguration().getContexts().setActive(context); }
/** * FIXME the spec doesn't follow this exactly because technically it isn't supposed to use * the bean resolution algorithm to obtain the instance, which it does. */ @Test(groups = { "events" }) @SpecAssertions({ @SpecAssertion(section = "10.4", id = "c"), @SpecAssertion(section = "5.5.6", id = "a") }) public void testStaticObserverMethodInvoked() { Context requestContext = getCurrentConfiguration().getContexts().getRequestContext(); try { getCurrentConfiguration().getContexts().setInactive(requestContext); StaticObserver.reset(); getCurrentManager().fireEvent(new Delivery()); assert StaticObserver.isDeliveryReceived(); StaticObserver.reset(); } finally { getCurrentConfiguration().getContexts().setActive(requestContext); } }
protected void setContextInactive(Context context) { getCurrentConfiguration().getContexts().setInactive(context); }
@Test(expectedExceptions = { ContextNotActiveException.class, IllegalStateException.class }) @SpecAssertions({ @SpecAssertion(section="5.4.2", id="ab"), @SpecAssertion(section = "6.5.4", id="a") }) public void testInactiveScope() throws Exception { assert getCurrentConfiguration().getContexts().getRequestContext().isActive(); Context ctx = getCurrentConfiguration().getContexts().getRequestContext(); setContextInactive(ctx); assert !getCurrentConfiguration().getContexts().getRequestContext().isActive(); try { getInstanceByType(TunedTuna.class).getState(); } finally { // need to set request scope active again, some other tests will fail otherwise setContextActive(ctx); } } }