use of com.mockrunner.mock.web.MockFilterChain in project pentaho-platform by pentaho.
the class PentahoAwareCharacterEncodingFilterTest method doFilter_ignoreFlagIsSet.
@Test
public void doFilter_ignoreFlagIsSet() throws Exception {
filterConfig.addInitParameter("ignore", Boolean.TRUE.toString());
filter.init(filterConfig);
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
assertEquals(NEW_ENCODING, request.getCharacterEncoding());
}
use of com.mockrunner.mock.web.MockFilterChain in project pentaho-platform by pentaho.
the class PentahoAwareCharacterEncodingFilterTest method doFilter_ignoreFlagIsCleared_requestEncodingNotNull.
@Test
public void doFilter_ignoreFlagIsCleared_requestEncodingNotNull() throws Exception {
filterConfig.addInitParameter("ignore", Boolean.FALSE.toString());
request.setCharacterEncoding(NEW_ENCODING);
filter.init(filterConfig);
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
assertEquals(NEW_ENCODING, request.getCharacterEncoding());
}
use of com.mockrunner.mock.web.MockFilterChain in project cayenne by apache.
the class CayenneFilterTest method testDoFilter.
@Test
public void testDoFilter() throws Exception {
MockFilterConfig config = new MockFilterConfig();
config.setFilterName("abc");
config.setInitParameter(WebConfiguration.EXTRA_MODULES_PARAMETER, CayenneFilter_DispatchModule.class.getName());
MockServletContext context = new MockServletContext();
config.setupServletContext(context);
CayenneFilter filter = new CayenneFilter();
filter.init(config);
CayenneRuntime runtime = WebUtil.getCayenneRuntime(context);
CayenneFilter_DispatchRequestHandler handler = (CayenneFilter_DispatchRequestHandler) runtime.getInjector().getInstance(RequestHandler.class);
assertEquals(0, handler.getStarted());
assertEquals(0, handler.getEnded());
filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain());
assertEquals(1, handler.getStarted());
assertEquals(1, handler.getEnded());
filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain());
assertEquals(2, handler.getStarted());
assertEquals(2, handler.getEnded());
}
use of com.mockrunner.mock.web.MockFilterChain in project pentaho-platform by pentaho.
the class PentahoAwareCharacterEncodingFilterTest method doFilter_ignoreFlagIsCleared_requestEncodingIsNull.
@Test
public void doFilter_ignoreFlagIsCleared_requestEncodingIsNull() throws Exception {
filterConfig.addInitParameter("ignore", Boolean.FALSE.toString());
request.setCharacterEncoding(null);
filter.init(filterConfig);
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
assertEquals(NEW_ENCODING, request.getCharacterEncoding());
}
use of com.mockrunner.mock.web.MockFilterChain in project pentaho-platform by pentaho.
the class PentahoAwareCharacterEncodingFilterTest method doFilter_noEncodingIsProvided.
@Test
public void doFilter_noEncodingIsProvided() throws Exception {
filterConfig.addInitParameter("ignore", Boolean.FALSE.toString());
request.setCharacterEncoding(null);
MockServletContext ctx = (MockServletContext) request.getSession().getServletContext();
ctx.addInitParameter(PentahoAwareCharacterEncodingFilter.INIT_PARAM_ENCODING, "");
filter.init(filterConfig);
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
assertEquals(PentahoAwareCharacterEncodingFilter.DEFAULT_CHAR_ENCODING, request.getCharacterEncoding());
}
Aggregations