Search in sources :

Example 6 with MockServletConfig

use of com.mockrunner.mock.web.MockServletConfig in project cayenne by apache.

the class ROPServletTest method testInitHessianService.

@Test
public void testInitHessianService() throws Exception {
    MockServletConfig config = new MockServletConfig();
    config.setServletName("abc");
    MockServletContext context = new MockServletContext();
    config.setServletContext(context);
    config.setInitParameter("extra-modules", ROPHessianServlet_ConfigModule.class.getName());
    ROPServlet servlet = new ROPServlet();
    servlet.init(config);
    runtime = WebUtil.getCayenneRuntime(context);
    Collection<Module> modules = runtime.getModules();
    assertEquals(5, modules.size());
    Object[] marray = modules.toArray();
    assertTrue(marray[3] instanceof ROPHessianServlet_ConfigModule);
// TODO: mock servlet request to check that the right service instance
// is invoked
}
Also used : MockServletConfig(com.mockrunner.mock.web.MockServletConfig) 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) Test(org.junit.Test)

Example 7 with MockServletConfig

use of com.mockrunner.mock.web.MockServletConfig in project cayenne by apache.

the class WebConfigurationTest method testServletConfigurationLocation_Parameter.

@Test
public void testServletConfigurationLocation_Parameter() {
    MockServletConfig config1 = new MockServletConfig();
    config1.setServletName("cayenne-x");
    config1.setInitParameter(WebConfiguration.CONFIGURATION_LOCATION_PARAMETER, "cayenne-y.xml");
    WebConfiguration configuration1 = new WebConfiguration(config1);
    assertEquals("cayenne-y.xml", configuration1.getConfigurationLocation());
}
Also used : MockServletConfig(com.mockrunner.mock.web.MockServletConfig) Test(org.junit.Test)

Example 8 with MockServletConfig

use of com.mockrunner.mock.web.MockServletConfig in project cayenne by apache.

the class WebConfigurationTest method testServletConfigurationLocation_Name.

@Test
public void testServletConfigurationLocation_Name() {
    MockServletConfig config1 = new MockServletConfig();
    config1.setServletName("cayenne-x");
    WebConfiguration configuration1 = new WebConfiguration(config1);
    assertEquals("cayenne-x.xml", configuration1.getConfigurationLocation());
    MockServletConfig config2 = new MockServletConfig();
    config2.setServletName("cayenne-y.xml");
    WebConfiguration configuration2 = new WebConfiguration(config2);
    assertEquals("cayenne-y.xml", configuration2.getConfigurationLocation());
    MockServletConfig config3 = new MockServletConfig();
    config3.setServletName("a/b/c/cayenne-z.xml");
    WebConfiguration configuration3 = new WebConfiguration(config3);
    assertEquals("a/b/c/cayenne-z.xml", configuration3.getConfigurationLocation());
}
Also used : MockServletConfig(com.mockrunner.mock.web.MockServletConfig) Test(org.junit.Test)

Aggregations

MockServletConfig (com.mockrunner.mock.web.MockServletConfig)8 Test (org.junit.Test)8 MockServletContext (com.mockrunner.mock.web.MockServletContext)5 ROPServlet (org.apache.cayenne.rop.ROPServlet)5 Module (org.apache.cayenne.di.Module)4 ServerModule (org.apache.cayenne.configuration.server.ServerModule)3 WebModule (org.apache.cayenne.configuration.web.WebModule)3 MockFilterConfig (com.mockrunner.mock.web.MockFilterConfig)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 RequestHandler (org.apache.cayenne.configuration.web.RequestHandler)1 Assert (org.junit.Assert)1