@Test
public void testDoFilterFirstApplies() throws Exception {

  HttpServletRequest httpServletRequest = createMock(HttpServletRequest.class);
  HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
  FilterChain filterChain = createMock(FilterChain.class);
  AmbariAuthenticationFilter filter1 = createMock(AmbariAuthenticationFilter.class);
  expect(filter1.shouldApply(httpServletRequest)).andReturn(true).once();
  filter1.doFilter(httpServletRequest, httpServletResponse, filterChain);
  expectLastCall().once();
  AmbariAuthenticationFilter filter2 = createMock(AmbariAuthenticationFilter.class);
  AmbariAuthenticationFilter filter3 = createMock(AmbariAuthenticationFilter.class);
  replayAll();
  Filter filter = new AmbariDelegatingAuthenticationFilter(Arrays.asList(filter1, filter2, filter3));
  filter.doFilter(httpServletRequest, httpServletResponse, filterChain);
  verifyAll();
}