Search in sources :

Example 6 with ServerModule

use of org.apache.cayenne.configuration.server.ServerModule in project cayenne by apache.

the class ROPServletTest method testInitWithStandardModules.

@Test
public void testInitWithStandardModules() throws Exception {
    String name = "cayenne-org.apache.cayenne.configuration.rop.server.test-config";
    MockServletConfig config = new MockServletConfig();
    config.setServletName(name);
    MockServletContext context = new MockServletContext();
    config.setServletContext(context);
    ROPServlet servlet = new ROPServlet();
    servlet.init(config);
    runtime = WebUtil.getCayenneRuntime(context);
    assertNotNull(runtime);
    List<String> locations = runtime.getInjector().getInstance(Key.getListOf(String.class, Constants.SERVER_PROJECT_LOCATIONS_LIST));
    assertEquals(Arrays.asList(name + ".xml"), locations);
    Collection<Module> modules = runtime.getModules();
    assertEquals(4, 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);
}
Also used : MockServletConfig(com.mockrunner.mock.web.MockServletConfig) WebModule(org.apache.cayenne.configuration.web.WebModule) ROPServlet(org.apache.cayenne.rop.ROPServlet) Module(org.apache.cayenne.di.Module) WebModule(org.apache.cayenne.configuration.web.WebModule) ServerModule(org.apache.cayenne.configuration.server.ServerModule) MockServletContext(com.mockrunner.mock.web.MockServletContext) ServerModule(org.apache.cayenne.configuration.server.ServerModule) Test(org.junit.Test)

Aggregations

ServerModule (org.apache.cayenne.configuration.server.ServerModule)6 Test (org.junit.Test)5 MockServletContext (com.mockrunner.mock.web.MockServletContext)4 Module (org.apache.cayenne.di.Module)4 MockFilterConfig (com.mockrunner.mock.web.MockFilterConfig)2 MockServletConfig (com.mockrunner.mock.web.MockServletConfig)2 CayenneRuntime (org.apache.cayenne.configuration.CayenneRuntime)2 WebModule (org.apache.cayenne.configuration.web.WebModule)2 ROPServlet (org.apache.cayenne.rop.ROPServlet)2 DataDomain (org.apache.cayenne.access.DataDomain)1 RequestHandler (org.apache.cayenne.configuration.web.RequestHandler)1 DbSyncModule (org.apache.cayenne.dbsync.DbSyncModule)1 Binder (org.apache.cayenne.di.Binder)1 Injector (org.apache.cayenne.di.Injector)1 DataMap (org.apache.cayenne.map.DataMap)1 ObjEntity (org.apache.cayenne.map.ObjEntity)1 CayenneModelerModule (org.apache.cayenne.modeler.init.CayenneModelerModule)1 ProjectModule (org.apache.cayenne.project.ProjectModule)1