本文整理汇总了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);
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
示例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();
}
示例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());
}
示例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"));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}