Search in sources :

Example 1 with RequestHandler

use of org.apache.cayenne.configuration.web.RequestHandler in project cayenne by apache.

the class ROPServletTest method testInitWithExtraModules.

@Test
public void testInitWithExtraModules() throws Exception {
    String name = "cayenne-org.apache.cayenne.configuration.rop.server.test-config";
    MockServletConfig config = new MockServletConfig();
    config.setServletName(name);
    config.setInitParameter("extra-modules", MockModule1.class.getName() + "," + MockModule2.class.getName());
    MockServletContext context = new MockServletContext();
    config.setServletContext(context);
    ROPServlet servlet = new ROPServlet();
    servlet.init(config);
    runtime = WebUtil.getCayenneRuntime(context);
    assertNotNull(runtime);
    Collection<Module> modules = runtime.getModules();
    assertEquals(6, modules.size());
    Object[] marray = modules.toArray();
    if (marray[0] instanceof ServerModule) {
        assertTrue(marray[1] instanceof WebModule);
    } else {
        assertTrue(marray[0] instanceof WebModule);
    }
    assertTrue(marray[2] instanceof ROPServerModule);
    assertTrue(marray[3] instanceof MockModule1);
    assertTrue(marray[4] instanceof MockModule2);
    RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class);
    assertTrue(handler instanceof MockRequestHandler);
}
Also used : MockServletConfig(com.mockrunner.mock.web.MockServletConfig) WebModule(org.apache.cayenne.configuration.web.WebModule) ROPServlet(org.apache.cayenne.rop.ROPServlet) MockServletContext(com.mockrunner.mock.web.MockServletContext) ServerModule(org.apache.cayenne.configuration.server.ServerModule) RequestHandler(org.apache.cayenne.configuration.web.RequestHandler) Module(org.apache.cayenne.di.Module) WebModule(org.apache.cayenne.configuration.web.WebModule) ServerModule(org.apache.cayenne.configuration.server.ServerModule) Test(org.junit.Test)

Aggregations

MockServletConfig (com.mockrunner.mock.web.MockServletConfig)1 MockServletContext (com.mockrunner.mock.web.MockServletContext)1 ServerModule (org.apache.cayenne.configuration.server.ServerModule)1 RequestHandler (org.apache.cayenne.configuration.web.RequestHandler)1 WebModule (org.apache.cayenne.configuration.web.WebModule)1 Module (org.apache.cayenne.di.Module)1 ROPServlet (org.apache.cayenne.rop.ROPServlet)1 Test (org.junit.Test)1