@Test
public void testAddViewInstance() throws Exception {

  ViewInstanceEntity viewInstanceEntity = ViewInstanceEntityTest.getViewInstanceEntity();
  final WebAppContext handler = createNiceMock(WebAppContext.class);
  Server server = createNiceMock(Server.class);
  expect(handler.getServer()).andReturn(server);
  handler.setServer(null);
  Capture<FilterHolder> securityHeaderFilterCapture = EasyMock.newCapture();
  Capture<FilterHolder> persistFilterCapture = EasyMock.newCapture();
  Capture<FilterHolder> securityFilterCapture = EasyMock.newCapture();
  handler.addFilter(capture(securityHeaderFilterCapture), eq("/*"), eq(AmbariServer.DISPATCHER_TYPES));
  handler.addFilter(capture(persistFilterCapture), eq("/*"), eq(AmbariServer.DISPATCHER_TYPES));
  handler.addFilter(capture(securityFilterCapture), eq("/*"), eq(AmbariServer.DISPATCHER_TYPES));
  handler.setAllowNullPathInfo(true);
  replay(handler, server);
  AmbariHandlerList handlerList = getAmbariHandlerList(handler);
  handlerList.addViewInstance(viewInstanceEntity);
  ArrayList<Handler> handlers = new ArrayList<Handler>(Arrays.asList(handlerList.getHandlers()));
  Assert.assertTrue(handlers.contains(handler));
  Assert.assertEquals(ambariViewsSecurityHeaderFilter, securityHeaderFilterCapture.getValue().getFilter());
  Assert.assertEquals(persistFilter, persistFilterCapture.getValue().getFilter());
  Assert.assertEquals(springSecurityFilter, securityFilterCapture.getValue().getFilter());
  verify(handler, server);
}