当前位置: 首页>>代码示例>>Java>>正文


Java MockFilterConfig.addInitParameter方法代码示例

本文整理汇总了Java中org.springframework.mock.web.MockFilterConfig.addInitParameter方法的典型用法代码示例。如果您正苦于以下问题:Java MockFilterConfig.addInitParameter方法的具体用法?Java MockFilterConfig.addInitParameter怎么用?Java MockFilterConfig.addInitParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.mock.web.MockFilterConfig的用法示例。


在下文中一共展示了MockFilterConfig.addInitParameter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureFilterConfig

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
@Before
public void configureFilterConfig() {
    MockApplication application = new MockApplication();

    MockServletContext context = new MockServletContext(application, "");
    context.setAttribute("nada", ServerContext.WORKLIST);

    filterConfig = new MockFilterConfig(context);
    filterConfig.addInitParameter(SSOFilter.URL_EXCLUDE_PATTERN_PARAM, "/rest");
    filterConfig.addInitParameter(SSOFilter.CLIENT_LOGOUT_URL, "/logout");
    filterConfig.addInitParameter(SSOConfigurableFilter.SINGULAR_CONTEXT_ATTRIBUTE, "nada");

    request = new MockHttpServletRequest(application, new MockHttpSession(context), context){
        @Override
        public String getContextPath() {
            return ServerContext.WORKLIST.getUrlPath();
        }
    };

    response = new MockHttpServletResponse(request);

}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:23,代码来源:SSOFilterTest.java

示例2: testAdapter

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
@Test
public void testAdapter() throws Exception {

    MockFilterConfig mockFilterConfig = new MockFilterConfig();
    mockFilterConfig.addInitParameter("foo", "bar");

    FilterServletConfigAdapter adapter = new FilterServletConfigAdapter(mockFilterConfig, "my-servlet");

    assertEquals("my-servlet", adapter.getServletName());
    assertEquals(mockFilterConfig.getServletContext(), adapter.getServletContext());
    assertEquals("bar", adapter.getInitParameter("foo"));

    Enumeration<String> initParameterNames = adapter.getInitParameterNames();
    assertNotNull(initParameterNames);
    assertTrue(initParameterNames.hasMoreElements());
    assertEquals("foo", initParameterNames.nextElement());
    assertFalse(initParameterNames.hasMoreElements());

}
 
开发者ID:sniffy,项目名称:sniffy,代码行数:20,代码来源:FilterServletConfigAdapterTest.java

示例3: testRedirectWithQueryString

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
@Test
public void testRedirectWithQueryString() throws Exception {
    request.setQueryString("test=12456");
    request.setRequestURI("/test");
    request.setSecure(true);
    this.filter = new CasAuthenticationFilter();

    final MockFilterConfig config = new MockFilterConfig();
    config.addInitParameter("casServerLoginUrl", CAS_LOGIN_URL);
    config.addInitParameter("serverName", "localhost:8443");
    this.filter.init(config);

    this.filter.doFilter(request, response, filterChain);

    assertEquals(
            CAS_LOGIN_URL
                    + "?service="
                    + URLEncoder.encode("https://localhost:8443" + request.getRequestURI() + "?"
                            + request.getQueryString(), "UTF-8"), response.getRedirectedUrl());
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:21,代码来源:CasAuthenticationFilterTest.java

示例4: testDoFilter

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
/**
 * Test for BypassSessionTimeoutFilter#doFilter(ServletRequest,ServletResponse,FilterChain)
 * 
 * @throws Exception
 *             Exception.
 */
@Test
public void testDoFilter() throws Exception {
    MockFilterConfig filterConfig = new MockFilterConfig();
    String requestParameterName = UUID.randomUUID().toString();
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockHttpServletRequest request = new MockHttpServletRequest();
    Filter filter = new BypassSessionTimeoutFilter();
    try {
        filter.init(filterConfig);
        Assert.fail("This should fail, if there is no requestParameterName");
    } catch (ServletException e) {
        // Do nothing.
    }
    filterConfig.addInitParameter("requestParameterName", requestParameterName);
    filter.init(filterConfig);

    // Filter without session
    filter.doFilter(request, response, new MockFilterChain());
    MockHttpSession session = new MockHttpSession();
    request.setSession(session);
    Assert.assertNull(session.getAttribute("lastInSessionRequestTime"));

    filter.doFilter(request, response, new MockFilterChain());
    Assert.assertNotNull(session.getAttribute("lastInSessionRequestTime"));

    session.setMaxInactiveInterval(Integer.MAX_VALUE);
    request.addParameter(requestParameterName, Boolean.TRUE.toString());
    filter.doFilter(request, response, new MockFilterChain());
    Assert.assertFalse(session.isInvalid());

    session.setMaxInactiveInterval(0);
    session.setAttribute("lastInSessionRequestTime", 0L);
    request.addParameter(requestParameterName, Boolean.TRUE.toString());
    filter.doFilter(request, response, new MockFilterChain());
    Assert.assertTrue(session.isInvalid());

}
 
开发者ID:Communote,项目名称:communote-server,代码行数:44,代码来源:BypassSessionTimeoutFilterTest.java

示例5: setUp

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
@Before
   public void setUp() throws Exception {
filter = new StaticFilter();
MockFilterConfig config = new MockFilterConfig();
config.addInitParameter("includes", "/scripts/*");
filter.init(config);
   }
 
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:8,代码来源:StaticFilterTest.java

示例6: setUp

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
/**
 * @throws ServletException if the filter cannot be initialized
 */
@Before
public final void setUp() throws ServletException {
	clientParameterFilter = new ClientParameterFilter();
	MockFilterConfig filterConfig = new MockFilterConfig();
	filterConfig.addInitParameter(
			ClientParameterFilter.CONFIG_PARAMETER_NAME, "scratchpad");
	clientParameterFilter.init(filterConfig);

	servletRequest = new MockHttpServletRequest();
	servletResponse = new MockHttpServletResponse();
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:15,代码来源:ClientParameterFilterTest.java

示例7: testFilter

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
@Test
public void testFilter() throws IOException, ServletException {
    ResponseHeaderFilter f = new ResponseHeaderFilter();

    MockFilterConfig config = new MockFilterConfig();
    config.addInitParameter("Foo", "Bar");
    f.init(config);

    f.doFilter(request, response, filterChain);

    Assert.assertEquals("Bar", response.getHeader("Foo"));

    Assert.assertSame(request, filterChain.getRequest());
    Assert.assertSame(response, filterChain.getResponse());
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:16,代码来源:ResponseHeaderFilterTest.java

示例8: test

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
@Test
public void test() throws IOException, ServletException {
	MockFilterConfig config = new MockFilterConfig();
	MockFilterChain chain = new MockFilterChain();
	MockHttpServletRequest request = new MockHttpServletRequest();
	MockHttpServletResponse response = new MockHttpServletResponse();
	config.addInitParameter("expiresSeconds", "123");

	CacheControlHeaderFilter filter = new CacheControlHeaderFilter();
	filter.init(config);
	filter.doFilter(request, response, chain);

	assertEquals("private, max-age=123", response.getHeader("Cache-Control"));
}
 
开发者ID:Michaelleolee,项目名称:appengine,代码行数:15,代码来源:CacheControlHeaderFilterTest.java

示例9: setUp

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    this.filter = new CasAuthenticationFilter();
    final MockFilterConfig config = new MockFilterConfig();
    config.addInitParameter("casServerLoginUrl", CAS_LOGIN_URL);
    config.addInitParameter("service", "https://localhost:8443/service");
    request.setSession(session);
    this.filter.init(config);
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:10,代码来源:CasAuthenticationFilterTest.java

示例10: testInitExcludeURL_SinglePattern

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
@Test
public void testInitExcludeURL_SinglePattern() throws Exception {
    final MockFilterConfig config = new MockFilterConfig();
    config.addInitParameter("casServerLoginUrl", CAS_LOGIN_URL);
    config.addInitParameter("serverName", "localhost:8443");
    config.addInitParameter(CasAuthenticationFilter.EXCLUDE_PARAMETERS_INIT_PARAM, "*\\.action");
    this.filter.init(config);

    assertNotNull(filter.getExcludePatterns());
    assertEquals("Expected a single pattern but received: " + filter.getExcludePatterns(), 1,
            filter.getExcludePatterns().length);
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:13,代码来源:CasAuthenticationFilterTest.java

示例11: testInitExcludeURL_MultiplePattern

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
@Test
public void testInitExcludeURL_MultiplePattern() throws Exception {
    final MockFilterConfig config = new MockFilterConfig();
    config.addInitParameter("casServerLoginUrl", CAS_LOGIN_URL);
    config.addInitParameter("serverName", "localhost:8443");
    config.addInitParameter(CasAuthenticationFilter.EXCLUDE_PARAMETERS_INIT_PARAM, ".*\\.action,.*/ajax/.*");
    this.filter.init(config);

    assertNotNull(filter.getExcludePatterns());
    assertEquals("Expected a two patterns but received: " + filter.getExcludePatterns(), 2,
            filter.getExcludePatterns().length);
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:13,代码来源:CasAuthenticationFilterTest.java

示例12: prepareFilterConfig

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
private FilterConfig prepareFilterConfig(String monitorSourceClassName, String caching) {
	MockFilterConfig filterConfig = new MockFilterConfig();
	filterConfig.addInitParameter(SimonServletFilter.INIT_PARAM_STOPWATCH_SOURCE_CLASS, monitorSourceClassName);
	filterConfig.addInitParameter(SimonServletFilter.INIT_PARAM_STOPWATCH_SOURCE_CACHE, caching);
	return filterConfig;
}
 
开发者ID:virgo47,项目名称:javasimon,代码行数:7,代码来源:SimonServletFilterUtilsTest.java

示例13: setupFilter

import org.springframework.mock.web.MockFilterConfig; //导入方法依赖的package包/类
protected void setupFilter() throws ServletException {
  MockFilterConfig config = new MockFilterConfig();
  config.addInitParameter(ProcessEngineAuthenticationFilter.AUTHENTICATION_PROVIDER_PARAM, HttpBasicAuthenticationProvider.class.getName());
  authenticationFilter = new ProcessEngineAuthenticationFilter();
  authenticationFilter.init(config);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:7,代码来源:AuthenticationFilterPathMatchingTest.java


注:本文中的org.springframework.mock.web.MockFilterConfig.addInitParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。