Hi everyone.
I'm trying to write some tests for my wicket-cdi application. But I can't
init wicket WebApplication, resulting:

 javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager' in
SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
java.naming.factory.url.pkgs=com.sun.enterprise.naming,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
[Root exception is javax.naming.NamingException: Invocation exception: Got
null ComponentInvocation ]
in WebAdminApplication.java row:
manager = (BeanManager)new InitialContext().lookup("java:comp/BeanManager");

LoginPageTest.java
public class LoginPageTest {
    private static WicketTester tester;
    @BeforeClass
    public static void setUpClass() {
        tester = new WicketTester(new WebAdminApplication());
    }
    @AfterClass
    public static void tearDownClass() {
    }
    @Test
    public void testRenderLoginPage() {
        LoginPage p = tester.startPage(LoginPage.class);
        tester.assertRenderedPage(LoginPage.class);
        ...
    }
}

WebAdminApplication.java
public class WebAdminApplication extends WebApplication {
    protected void init() {
        super.init();
        BeanManager manager = null;
        try {
            manager = (BeanManager)new
InitialContext().lookup("java:comp/BeanManager");
        } catch (NamingException ex) {
            logger.error("Error while creating BeanManager. Error text: {}",
ex.toString());
        }
        new CdiConfiguration(manager).configure(this);
        ...
    }
}

How I can get BeanManager for tests?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-CDI-application-junit-test-tp4665366.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to