Hi,

I have a problem with the following test (with TomEE 7.0.1):

@ContainerProperties(@ContainerProperties.Property(name = 
"openejb.testing.start-cdi-contexts", value = "false"))
@Classes(cdi = true, innerClassesAsBean = true)
@RunWith(ApplicationComposer.class)
public class ScopesRuleTest {
    public static class Foo {
        public void touch() {}
    }

    @Rule
    public final ScopesRule rule = new ScopesRule();

    @Inject
    private BeanManager beanManager;

    @Test
    public void scopeDoesNotExist() {
        
Assert.assertFalse(beanManager.getContext(RequestScoped.class).isActive());
    }

    @Test
    @CdiScopes(RequestScoped.class)
    public void scopeExists() {
        
Assert.assertTrue(beanManager.getContext(RequestScoped.class).isActive());
    }
}

The scopes should not be started but the first test gives an assertion error 
(so the RequestContext is well started although that's not what I wanted) and 
the second one gives a NPE:

java.lang.NullPointerException
    at org.apache.openejb.util.AppFinder.findAppContextOrWeb(AppFinder.java:28)
    at 
org.apache.openejb.cdi.ThreadSingletonServiceImpl.get(ThreadSingletonServiceImpl.java:287)
    at 
org.apache.openejb.cdi.ThreadSingletonServiceImpl.getContext(ThreadSingletonServiceImpl.java:267)
    at 
org.apache.openejb.cdi.ThreadSingletonServiceImpl.get(ThreadSingletonServiceImpl.java:327)
    at 
org.apache.openejb.cdi.ThreadSingletonServiceImpl.get(ThreadSingletonServiceImpl.java:64)
    at 
org.apache.webbeans.config.WebBeansFinder.getSingletonInstance(WebBeansFinder.java:51)
    at 
org.apache.webbeans.config.WebBeansContext.getInstance(WebBeansContext.java:185)
    at 
org.apache.webbeans.config.WebBeansContext.currentInstance(WebBeansContext.java:203)
    at org.apache.openejb.junit.ScopesRule$1.evaluate(ScopesRule.java:42)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)

If I remove the first test, the second one passes.

Is this a bug?

Thanks,

Xavier

Reply via email to