Search in sources :

Example 1 with AbstractUnitTest

use of org.apache.webbeans.test.AbstractUnitTest in project openwebbeans by apache.

the class OwbRequestContextControllerTest method check.

@Test
public void check() {
    startContainer();
    final ContextsService cs = getWebBeansContext().getContextsService();
    // it is started by AbstractUnitTest
    cs.endContext(RequestScoped.class, null);
    final RequestContextController controller = getInstance(RequestContextController.class);
    assertNull(cs.getCurrentContext(RequestScoped.class));
    assertTrue(controller.activate());
    final RequestContextController i2 = getInstance(RequestContextController.class);
    assertFalse(i2.activate());
    final RequestContextController i3 = getInstance(RequestContextController.class);
    assertFalse(i3.activate());
    assertTrue(cs.getCurrentContext(RequestScoped.class).isActive());
    i2.deactivate();
    // skip i3 to ensure we deactivate by the "owner"
    controller.deactivate();
    assertNull(cs.getCurrentContext(RequestScoped.class));
}
Also used : ContextsService(org.apache.webbeans.spi.ContextsService) RequestScoped(javax.enterprise.context.RequestScoped) RequestContextController(javax.enterprise.context.control.RequestContextController) AbstractUnitTest(org.apache.webbeans.test.AbstractUnitTest) Test(org.junit.Test)

Aggregations

RequestScoped (javax.enterprise.context.RequestScoped)1 RequestContextController (javax.enterprise.context.control.RequestContextController)1 ContextsService (org.apache.webbeans.spi.ContextsService)1 AbstractUnitTest (org.apache.webbeans.test.AbstractUnitTest)1 Test (org.junit.Test)1