### Question:
AuthenticationFilter extends ExcludingPatternFilter { protected void doAuthenticationFiltering(final HttpServletRequestAccessor requestAccessor, final HttpServletResponse response, final TenantIdAccessor tenantIdAccessor, final FilterChain chain) throws ServletException, IOException { try { if (!isAuthorized(requestAccessor, response, tenantIdAccessor, chain)) { cleanHttpSession(requestAccessor.getHttpSession()); if (requestAccessor.asHttpServletRequest().getMethod().equals("GET")) { response.sendRedirect(createLoginPageUrl(requestAccessor, tenantIdAccessor).getLocation()); } else { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } } } catch (TenantIsPausedException e) { handleTenantPausedException(requestAccessor, response, e); } catch (final EngineUserNotFoundOrInactive e) { handleUserNotFoundOrInactiveException(requestAccessor, response, e); } } AuthenticationFilter(); String getDefaultExcludedPages(); @Override void proceedWithFiltering(final ServletRequest request, final ServletResponse response, final FilterChain chain); @Override void destroy();  }### Answer:
@Test public void testFilter() throws Exception { when(httpRequest.getSession()).thenReturn(httpSession); doAnswer(new Answer<Object>() { @Override public Object answer(final InvocationOnMock invocation) throws Throwable { return null; } }).when(authenticationFilter).doAuthenticationFiltering(any(HttpServletRequestAccessor.class), any(HttpServletResponse.class), any(TenantIdAccessor.class), any(FilterChain.class)); authenticationFilter.doFilter(httpRequest, httpResponse, chain); verify(authenticationFilter, times(1)).doAuthenticationFiltering(any(HttpServletRequestAccessor.class), any(HttpServletResponse.class), any(TenantIdAccessor.class), any(FilterChain.class)); }
@Test public void testFilterWithExcludedURL() throws Exception { final String url = "test"; when(httpRequest.getRequestURL()).thenReturn(new StringBuffer(url)); doReturn(true).when(authenticationFilter).matchExcludePatterns(url); authenticationFilter.doFilter(httpRequest, httpResponse, chain); verify(authenticationFilter, times(0)).doAuthenticationFiltering(request, httpResponse, tenantIdAccessor, chain); verify(chain, times(1)).doFilter(httpRequest, httpResponse); }