AclActivatorFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { AclStatus status = aclSecurityActivator.getStatus(); aclSecurityActivator.setStatus(statusDuringTest); try { chain.doFilter(request, response); } finally { aclSecurityActivator.setStatus(status); } } AclActivatorFilter(AclSecurityActivator aclSecurityActivator);  AclActivatorFilter(AclStatus statusDuringTest, AclSecurityActivator aclSecurityActivator); @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); @Override void destroy();  }
@Test public void should_acl_security_be_enabled_when_filter_is_activated() throws IOException, ServletException { AclActivatorFilter filter = new AclActivatorFilter(aclSecurityActivator); FilterChain chainAssert = new FilterChain() { @Override public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException { assertThat(aclSecurityActivator.isEnabled()).isTrue(); } }; assertThat(aclSecurityActivator.isEnabled()).isFalse(); filter.doFilter(null, null, chainAssert); assertThat(aclSecurityActivator.isEnabled()).isFalse(); }