Search in sources :

Example 21 with MockFilterConfig

use of org.springframework.mock.web.MockFilterConfig in project spring-framework by spring-projects.

the class ConditionalDelegatingFilterProxyTests method init.

@Test
public void init() throws Exception {
    FilterConfig config = new MockFilterConfig();
    filter = new PatternMappingFilterProxy(delegate, "/");
    filter.init(config);
    assertThat(delegate.filterConfig, is(config));
}
Also used : FilterConfig(javax.servlet.FilterConfig) MockFilterConfig(org.springframework.mock.web.MockFilterConfig) MockFilterConfig(org.springframework.mock.web.MockFilterConfig) Test(org.junit.Test)

Example 22 with MockFilterConfig

use of org.springframework.mock.web.MockFilterConfig in project opennms by OpenNMS.

the class HttpRemotingContextIT method testLoadContext.

public void testLoadContext() throws Throwable {
    DaoTestConfigBean bean = new DaoTestConfigBean();
    bean.afterPropertiesSet();
    MockDatabase db = new MockDatabase(true);
    DataSourceFactory.setInstance(db);
    servletContext = new MockServletContext("file:src/main/webapp");
    servletContext.addInitParameter("contextConfigLocation", "classpath:/META-INF/opennms/applicationContext-commonConfigs.xml " + "classpath:/META-INF/opennms/applicationContext-soa.xml " + "classpath:/META-INF/opennms/applicationContext-mockDao.xml " + "classpath*:/META-INF/opennms/component-service.xml " + "classpath*:/META-INF/opennms/component-dao.xml " + // Contexts within this project
    "/WEB-INF/applicationContext-common.xml " + "/WEB-INF/applicationContext-serviceRegistryRemoting.xml " + "/WEB-INF/applicationContext-spring-security.xml " + "/WEB-INF/applicationContext-svclayer.xml ");
    servletContext.addInitParameter("parentContextKey", "daoContext");
    ServletContextEvent e = new ServletContextEvent(servletContext);
    contextListener = new ContextLoaderListener();
    contextListener.contextInitialized(e);
    servletContext.setContextPath(contextPath);
    servletConfig = new MockServletConfig(servletContext, "dispatcher");
    servletConfig.addInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig");
    servletConfig.addInitParameter("com.sun.jersey.config.property.packages", "org.opennms.web.rest");
    try {
        MockFilterConfig filterConfig = new MockFilterConfig(servletContext, "openSessionInViewFilter");
        filter = new OpenSessionInViewFilter();
        filter.init(filterConfig);
    } catch (ServletException se) {
        throw se.getRootCause();
    }
}
Also used : DaoTestConfigBean(org.opennms.test.DaoTestConfigBean) OpenSessionInViewFilter(org.springframework.orm.hibernate3.support.OpenSessionInViewFilter) ServletException(javax.servlet.ServletException) MockDatabase(org.opennms.core.test.db.MockDatabase) MockServletConfig(org.springframework.mock.web.MockServletConfig) ContextLoaderListener(org.springframework.web.context.ContextLoaderListener) MockServletContext(org.springframework.mock.web.MockServletContext) ServletContextEvent(javax.servlet.ServletContextEvent) MockFilterConfig(org.springframework.mock.web.MockFilterConfig)

Aggregations

MockFilterConfig (org.springframework.mock.web.MockFilterConfig)22 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)19 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)19 Test (org.junit.Test)12 MockFilterChain (org.springframework.mock.web.MockFilterChain)11 MockServletContext (org.springframework.mock.web.MockServletContext)9 WebStatFilter (com.alibaba.druid.support.http.WebStatFilter)8 Map (java.util.Map)5 List (java.util.List)4 WebAppStat (com.alibaba.druid.support.http.stat.WebAppStat)3 ServletException (javax.servlet.ServletException)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 MockHttpSession (org.springframework.mock.web.MockHttpSession)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 MockDatabase (org.opennms.core.test.db.MockDatabase)2 DaoTestConfigBean (org.opennms.test.DaoTestConfigBean)2 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)2 MockServletConfig (org.springframework.mock.web.MockServletConfig)2 OpenSessionInViewFilter (org.springframework.orm.hibernate3.support.OpenSessionInViewFilter)2 UserService (com.alibaba.druid.stat.spring.UserService)1