Search in sources :

Example 11 with MockServletContext

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

the class CayenneFilterTest method testInitWithFilterName.

@Test
public void testInitWithFilterName() throws Exception {
    MockFilterConfig config = new MockFilterConfig();
    config.setFilterName("abc");
    MockServletContext context = new MockServletContext();
    config.setupServletContext(context);
    CayenneFilter filter = new CayenneFilter();
    assertNull(WebUtil.getCayenneRuntime(context));
    filter.init(config);
    CayenneRuntime runtime = WebUtil.getCayenneRuntime(context);
    assertNotNull(runtime);
    List<String> locations = runtime.getInjector().getInstance(Key.getListOf(String.class, Constants.SERVER_PROJECT_LOCATIONS_LIST));
    assertEquals(Arrays.asList("abc.xml"), locations);
}
Also used : CayenneRuntime(org.apache.cayenne.configuration.CayenneRuntime) MockServletContext(com.mockrunner.mock.web.MockServletContext) MockFilterConfig(com.mockrunner.mock.web.MockFilterConfig) Test(org.junit.Test)

Aggregations

MockServletContext (com.mockrunner.mock.web.MockServletContext)11 Test (org.junit.Test)11 CayenneRuntime (org.apache.cayenne.configuration.CayenneRuntime)6 MockFilterConfig (com.mockrunner.mock.web.MockFilterConfig)5 MockServletConfig (com.mockrunner.mock.web.MockServletConfig)5 ServerModule (org.apache.cayenne.configuration.server.ServerModule)5 Module (org.apache.cayenne.di.Module)5 ROPServlet (org.apache.cayenne.rop.ROPServlet)5 WebModule (org.apache.cayenne.configuration.web.WebModule)3 MockFilterChain (com.mockrunner.mock.web.MockFilterChain)1 MockHttpServletRequest (com.mockrunner.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (com.mockrunner.mock.web.MockHttpServletResponse)1 RequestHandler (org.apache.cayenne.configuration.web.RequestHandler)1