Example usage for org.springframework.mock.web PassThroughFilterChain PassThroughFilterChain

List of usage examples for org.springframework.mock.web PassThroughFilterChain PassThroughFilterChain

Introduction

In this page you can find the example usage for org.springframework.mock.web PassThroughFilterChain PassThroughFilterChain.

Prototype

public PassThroughFilterChain(Servlet servlet) 

Source Link

Document

Create a new PassThroughFilterChain that delegates to the given Servlet.

Usage

From source file:org.ngrinder.security.PluggablePreAuthFilterTest.java

@Test
public void test() throws IOException, ServletException {
    PluggablePreAuthFilter filter = new PluggablePreAuthFilter();
    ReflectionTestUtils.setField(filter, "pluginManager", pluginManager);

    filter.init();/*from  www  .j ava  2  s  .  c o  m*/
    filter.onPluginEnabled(null);
    filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(),
            new PassThroughFilterChain(new FreemarkerServlet()));
    filter.onPluginDisabled(null);
}

From source file:org.ppwcode.vernacular.l10n_III.dojo.DojoDjConfigFilterTest.java

private void testDojoDjConfigFilterHelper(String type, String input, String output, String bestLocale)
        throws UnsupportedEncodingException, IOException, ServletException {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/index.html");
    MockHttpServletResponse response = new MockHttpServletResponse();

    Servlet testServlet = new SimpleServlet(type, input);
    PassThroughFilterChain chain = new PassThroughFilterChain(testServlet);

    HttpSession session = request.getSession();
    session.setAttribute(HttpRequestLocaleFilter.ATTRIBUTE_PREFERRED_LOCALE,
            LocaleHelpers.constructLocaleFromString(bestLocale));

    Filter djConfigFilter = new DojoDjConfigFilter();
    djConfigFilter.doFilter(request, response, chain);

    LOG.debug("input\n" + input);
    LOG.debug("output\n" + response.getContentAsString());

    Assert.assertEquals(output, response.getContentAsString());
    Assert.assertEquals(output.length(), response.getContentLength());
}