@Test
public void testRemoveViewInstance() 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);
  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));
  handlerList.removeViewInstance(viewInstanceEntity);
  handlers = new ArrayList<Handler>(Arrays.asList(handlerList.getHandlers()));
  Assert.assertFalse(handlers.contains(handler));
  verify(handler, server);
}