Spring Framework MockFilterConfig - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework MockFilterConfig class.

This code example shows how to use the following methods:addInitParameter
 */ 
public class Saml11TicketValidationFilterTests { 
    @Test 
    public void testRenewInitParamThrows() throws Exception { 
        final Saml11TicketValidationFilter f = new Saml11TicketValidationFilter(); 
        final MockFilterConfig config = new MockFilterConfig(); 
        config.addInitParameter("casServerUrlPrefix", "https://cas.example.com"); 
        config.addInitParameter("renew", "true"); 
        try { 
            f.init(config); 
            fail("Should have thrown IllegalArgumentException."); 
        } catch (final IllegalArgumentException e) { 
            assertTrue(e.getMessage().contains("Renew MUST")); 
        } 
    } 
 
    @Test 
    public void testAllowsRenewContextParam() throws Exception { 
        final Saml11TicketValidationFilter f = new Saml11TicketValidationFilter(); 
        final MockServletContext context = new MockServletContext(); 
7
CodeRank
This code example shows how to use the following methods:addInitParameter
 */ 
public class Cas10TicketValidationFilterTests { 
    @Test 
    public void testThrowsRenewInitParam() throws Exception { 
        final Cas10TicketValidationFilter f = new Cas10TicketValidationFilter(); 
        final MockFilterConfig config = new MockFilterConfig(); 
        config.addInitParameter("casServerUrlPrefix", "https://cas.example.com"); 
        config.addInitParameter("renew", "true"); 
        try { 
            f.init(config); 
            fail("Should have thrown IllegalArgumentException."); 
        } catch (final IllegalArgumentException e) { 
            assertTrue(e.getMessage().contains("Renew MUST")); 
        } 
    } 
 
    @Test 
    public void testAllowsRenewContextParam() throws Exception { 
        final Cas10TicketValidationFilter f = new Cas10TicketValidationFilter(); 
        final MockServletContext context = new MockServletContext(); 
7
CodeRank
This code example shows how to use the following methods:
public class LocaleFilterTest extends TestCase { 
    private LocaleFilter filter = null; 
     
    protected void setUp() throws Exception { 
        filter = new LocaleFilter(); 
        filter.init(new MockFilterConfig()); 
    } 
     
    public void testSetLocaleInSessionWhenSessionIsNull() throws Exception { 
        MockHttpServletRequest request = new MockHttpServletRequest(); 
        request.addParameter("locale", "es"); 
 
        MockHttpServletResponse response = new MockHttpServletResponse(); 
        filter.doFilter(request, response, new MockFilterChain()); 
         
        // no session, should result in null 
        assertNull(request.getSession().getAttribute(Constants.PREFERRED_LOCALE_KEY)); 
        // thread locale should always have it, regardless of session 
        assertNotNull(LocaleContextHolder.getLocale()); 
    } 
6
CodeRank
This code example shows how to use the following methods:
    @Before 
    public void setUp() throws Exception { 
        filter = new SingleSignOutFilter(); 
        filter.setCasServerUrlPrefix(CAS_SERVER_URL_PREFIX); 
        filter.setIgnoreInitConfiguration(true); 
        filter.init(new MockFilterConfig()); 
        request = new MockHttpServletRequest(); 
        response = new MockHttpServletResponse(); 
        filterChain = new MockFilterChain(); 
    } 
     
    @Test 
    public void tokenRequest() throws IOException, ServletException { 
        request.setParameter(SingleSignOutHandler.DEFAULT_ARTIFACT_PARAMETER_NAME, TICKET); 
        request.setQueryString(SingleSignOutHandler.DEFAULT_ARTIFACT_PARAMETER_NAME + "=" + TICKET); 
        final MockHttpSession session = new MockHttpSession(); 
        request.setSession(session); 
        filter.doFilter(request, response, filterChain); 
        assertEquals(session, SingleSignOutFilter.getSingleSignOutHandler().getSessionMappingStorage().removeSessionByMappingId(TICKET)); 
    } 
6
CodeRank
This code example shows how to use the following methods:
public class LocaleFilterTest extends TestCase { 
    private LocaleFilter filter = null; 
     
    protected void setUp() throws Exception { 
        filter = new LocaleFilter(); 
        filter.init(new MockFilterConfig()); 
    } 
     
    public void testSetLocaleInSessionWhenSessionIsNull() throws Exception { 
        MockHttpServletRequest request = new MockHttpServletRequest(); 
        request.addParameter("locale", "es"); 
 
        MockHttpServletResponse response = new MockHttpServletResponse(); 
        filter.doFilter(request, response, new MockFilterChain()); 
         
        // no session, should result in null 
        assertNull(request.getSession().getAttribute(Constants.PREFERRED_LOCALE_KEY)); 
        // thread locale should always have it, regardless of session 
        assertNotNull(LocaleContextHolder.getLocale()); 
    } 
5
CodeRank
This code example shows how to use the following methods:
        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); 
 
            dispatcher = new SpringServlet(); 
            dispatcher.init(servletConfig); 
 
        } catch (ServletException se) { 
            throw se.getRootCause(); 
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
		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(); 
		} 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:addInitParameter
        filterChain = new PassThroughFilterChain(filter, new MockFilterChain()); 
    } 
 
    private UrlRewriteFilter createUrlFilter(String filterName, String mappingsFile) throws ServletException { 
        UrlRewriteFilter newFilter = new UrlRewriteFilter(); 
        MockFilterConfig filterConfig = new MockFilterConfig(filterName); 
        filterConfig.addInitParameter("confPath", mappingsFile); 
        filterConfig.addInitParameter("logLevel", "WARN"); 
        newFilter.init(filterConfig); 
        return newFilter; 
    } 
 
    @Test 
    public void rossensWebSocketPostIsRedirectedToOldBlog() throws Exception { 
        validateTemporaryRedirect( 
                "http://spring.io/blog/2013/07/24/spring-framework-4-0-m2-websocket-messaging-architectures", 
                "http://assets.spring.io/wp/WebSocketBlogPost.html"); 
    } 
 
    @Test 
5
CodeRank
This code example shows how to use the following methods:
	protected ProcessingContext processingContext;
	protected Context context;
	 
	@Before 
	public void setup(){ 
		context = new Context(new MockFilterConfig());
		 
		MockHttpServletRequest request = new MockHttpServletRequest();
		request.setContextPath("/context-path");
		 
		Asset asset = new Asset();
		asset.setConfigLocation("//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap.css");
		asset.setFinalLocation("/context-path/dandelion-assets/sha1/bootstrap2-2.3.2.css");
		processingContext = new ProcessingContext(context, asset, request);
	} 
} 
5
CodeRank
This code example shows how to use the following methods:
public class ControllerPackageLocatorSpec { 
 
 
    @Test
    public void shouldDiscoverPackagesInDirectories(){ 
        List<String> controllerPackages =  ControllerPackageLocator.locateControllerPackages(new MockFilterConfig());
        a(controllerPackages.contains("admin")).shouldBeTrue();
        a(controllerPackages.contains("admin.special2")).shouldBeTrue();
        a(controllerPackages.contains("admin.special2.special3")).shouldBeTrue();
        a(controllerPackages.contains("admin.special")).shouldBeTrue();
        a(controllerPackages.contains("rest")).shouldBeTrue();
    } 
 
 
    @Test
    public void shouldDiscoverPackagesInJars(){ 
 
 
        File jar = new File("src/test/resources/test.jar");
 
5
CodeRank