Search in sources :

Example 6 with MockFilterConfig

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

the class WebConfigurationTest method testFilterOtherParameters.

@Test
public void testFilterOtherParameters() {
    MockFilterConfig config1 = new MockFilterConfig();
    config1.setFilterName("cayenne-x");
    config1.setInitParameter(WebConfiguration.CONFIGURATION_LOCATION_PARAMETER, "cayenne-y.xml");
    config1.setInitParameter(WebConfiguration.EXTRA_MODULES_PARAMETER, "M1,M2");
    config1.setInitParameter("test", "xxx");
    WebConfiguration configuration1 = new WebConfiguration(config1);
    Map<String, String> parameters = configuration1.getOtherParameters();
    assertNotSame(parameters, configuration1.getOtherParameters());
    assertEquals(parameters, configuration1.getOtherParameters());
    assertEquals(1, parameters.size());
    assertEquals("xxx", parameters.get("test"));
}
Also used : MockFilterConfig(com.mockrunner.mock.web.MockFilterConfig) Test(org.junit.Test)

Example 7 with MockFilterConfig

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

the class WebConfigurationTest method testFilterParameters.

@Test
public void testFilterParameters() {
    MockFilterConfig config1 = new MockFilterConfig();
    config1.setFilterName("cayenne-x");
    config1.setInitParameter(WebConfiguration.CONFIGURATION_LOCATION_PARAMETER, "cayenne-y.xml");
    config1.setInitParameter("test", "xxx");
    WebConfiguration configuration1 = new WebConfiguration(config1);
    Map<String, String> parameters = configuration1.getParameters();
    assertNotSame(parameters, configuration1.getParameters());
    assertEquals(parameters, configuration1.getParameters());
    assertEquals(2, parameters.size());
    assertEquals("cayenne-y.xml", parameters.get(WebConfiguration.CONFIGURATION_LOCATION_PARAMETER));
    assertEquals("xxx", parameters.get("test"));
}
Also used : MockFilterConfig(com.mockrunner.mock.web.MockFilterConfig) Test(org.junit.Test)

Example 8 with MockFilterConfig

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

the class WebConfigurationTest method testFilterConfigurationLocation_Parameter.

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

Example 9 with MockFilterConfig

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

the class CayenneFilterTest method testInitWithCustomDomainName.

@Test
public void testInitWithCustomDomainName() throws Exception {
    MockFilterConfig config = new MockFilterConfig();
    config.setFilterName("abc");
    config.setInitParameter(WebConfiguration.DATA_DOMAIN_NAME_PARAMETER, "custom");
    MockServletContext context = new MockServletContext();
    config.setupServletContext(context);
    CayenneFilter filter = new CayenneFilter();
    filter.init(config);
    CayenneRuntime runtime = WebUtil.getCayenneRuntime(context);
    assertNotNull(runtime);
    String domainName = runtime.getInjector().getInstance(Key.getMapOf(String.class, String.class, Constants.PROPERTIES_MAP)).get(Constants.SERVER_DOMAIN_NAME_PROPERTY);
    assertEquals("custom", domainName);
}
Also used : CayenneRuntime(org.apache.cayenne.configuration.CayenneRuntime) MockServletContext(com.mockrunner.mock.web.MockServletContext) MockFilterConfig(com.mockrunner.mock.web.MockFilterConfig) Test(org.junit.Test)

Example 10 with MockFilterConfig

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

the class CayenneFilterTest method testInitWithMultipleLocations.

@Test
public void testInitWithMultipleLocations() throws Exception {
    MockFilterConfig config = new MockFilterConfig();
    config.setFilterName("abc");
    config.setInitParameter(WebConfiguration.CONFIGURATION_LOCATION_PARAMETER, "xyz,abc,\tdef, \n ghi");
    MockServletContext context = new MockServletContext();
    config.setupServletContext(context);
    CayenneFilter filter = new CayenneFilter();
    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("xyz", "abc", "def", "ghi"), 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

MockFilterConfig (com.mockrunner.mock.web.MockFilterConfig)15 Test (org.junit.Test)13 MockServletContext (com.mockrunner.mock.web.MockServletContext)7 CayenneRuntime (org.apache.cayenne.configuration.CayenneRuntime)7 Module (org.apache.cayenne.di.Module)4 MockServletConfig (com.mockrunner.mock.web.MockServletConfig)2 WebMockObjectFactory (com.mockrunner.mock.web.WebMockObjectFactory)2 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 ServerModule (org.apache.cayenne.configuration.server.ServerModule)2 Assert (org.junit.Assert)2 Before (org.junit.Before)2 MockFilterChain (com.mockrunner.mock.web.MockFilterChain)1 MockHttpServletRequest (com.mockrunner.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (com.mockrunner.mock.web.MockHttpServletResponse)1