DelegatingSecurityFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Filter delegatedFilter = getFilterBean(); LOGGER.debug("delegate to org.springframework.security.web.filterChainProxy"); delegatedFilter.doFilter(request, response, chain); }  @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); void setSecurityFilterChain(Filter securityFilterChain); @Override void init(FilterConfig filterConfig); @Override void destroy();  }
@Test public void testDoFilter_shouldDelegateToSecurityFilterChain() throws Exception { ServletRequest req = mock(ServletRequest.class); ServletResponse resp = mock(ServletResponse.class); FilterChain chain = mock(FilterChain.class); Filter filter = filterFactory.createFilter(mock(ConfigurableFilterConfig.class)); filter.doFilter(req, resp, chain); verify(delegateFilter).doFilter(req, resp, chain); }
@Test(expected = IllegalStateException.class) public void testDoFilterWithoutSettedDelegatee_shouldThrowException() throws Exception { ServletRequest req = mock(ServletRequest.class); ServletResponse resp = mock(ServletResponse.class); FilterChain chain = mock(FilterChain.class); DelegatingSecurityFilter filter = new DelegatingSecurityFilter(); filter.doFilter(req, resp, chain); }