use of com.mockrunner.mock.web.MockFilterConfig in project geode by apache.
the class SessionReplicationJUnitTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
WebMockObjectFactory factory = getWebMockObjectFactory();
MockFilterConfig config = factory.getMockFilterConfig();
config.setInitParameter(DistributionConfig.GEMFIRE_PREFIX + "property.mcast-port", "0");
config.setInitParameter("cache-type", "peer-to-peer");
factory.getMockServletContext().setContextPath(CONTEXT_PATH);
factory.getMockRequest().setRequestURL("/test/foo/bar");
factory.getMockRequest().setContextPath(CONTEXT_PATH);
createFilter(SessionCachingFilter.class);
createServlet(CallbackServlet.class);
setDoChain(true);
}
use of com.mockrunner.mock.web.MockFilterConfig in project geode by apache.
the class SessionReplicationLocalCacheJUnitTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
WebMockObjectFactory factory = getWebMockObjectFactory();
MockFilterConfig config = factory.getMockFilterConfig();
config.setInitParameter(DistributionConfig.GEMFIRE_PREFIX + "property.mcast-port", "0");
config.setInitParameter("cache-type", "peer-to-peer");
config.setInitParameter(DistributionConfig.GEMFIRE_PREFIX + "cache.enable_local_cache", "true");
factory.getMockServletContext().setContextPath(CONTEXT_PATH);
factory.getMockRequest().setRequestURL("/test/foo/bar");
factory.getMockRequest().setContextPath(CONTEXT_PATH);
createFilter(SessionCachingFilter.class);
createServlet(CallbackServlet.class);
setDoChain(true);
}
use of com.mockrunner.mock.web.MockFilterConfig in project cayenne by apache.
the class CayenneFilterTest method testInitWithLocation.
@Test
public void testInitWithLocation() throws Exception {
MockFilterConfig config = new MockFilterConfig();
config.setFilterName("abc");
config.setInitParameter(WebConfiguration.CONFIGURATION_LOCATION_PARAMETER, "xyz");
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(Collections.singletonList("xyz"), locations);
}
use of com.mockrunner.mock.web.MockFilterConfig in project cayenne by apache.
the class CayenneFilterTest method testInitWithStandardModules.
@Test
public void testInitWithStandardModules() throws Exception {
MockFilterConfig config = new MockFilterConfig();
config.setFilterName("cayenne-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(Collections.singletonList("cayenne-abc.xml"), locations);
Collection<Module> modules = runtime.getModules();
assertEquals(3, modules.size());
Object[] marray = modules.toArray();
if (marray[0] instanceof ServerModule) {
assertTrue(marray[1] instanceof WebModule);
} else {
assertTrue(marray[0] instanceof WebModule);
}
RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class);
assertTrue(handler instanceof SessionContextRequestHandler);
}
use of com.mockrunner.mock.web.MockFilterConfig in project cayenne by apache.
the class CayenneFilterTest method testInitWithExtraModules.
@Test
public void testInitWithExtraModules() throws Exception {
MockFilterConfig config = new MockFilterConfig();
config.setFilterName("abc");
config.setInitParameter(WebConfiguration.EXTRA_MODULES_PARAMETER, MockModule1.class.getName() + "," + MockModule2.class.getName());
MockServletContext context = new MockServletContext();
config.setupServletContext(context);
CayenneFilter filter = new CayenneFilter();
filter.init(config);
CayenneRuntime runtime = WebUtil.getCayenneRuntime(context);
assertNotNull(runtime);
Collection<Module> modules = runtime.getModules();
assertEquals(5, 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 MockModule1);
assertTrue(marray[3] instanceof MockModule2);
RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class);
assertTrue(handler instanceof MockRequestHandler);
}
Aggregations