AbstractTilesListener implements ServletContextListener { public void contextInitialized(ServletContextEvent event) { ServletContext servletContext = event.getServletContext(); initializer = createTilesInitializer(); initializer.initialize(new ServletApplicationContext( servletContext)); }  void contextInitialized(ServletContextEvent event); void contextDestroyed(ServletContextEvent event);  }
@Test public void testContextInitialized() { AbstractTilesListener listener = createMockBuilder(AbstractTilesListener.class).createMock(); ServletContextEvent event = createMock(ServletContextEvent.class); ServletContext servletContext = createMock(ServletContext.class); TilesInitializer initializer = createMock(TilesInitializer.class); expect(event.getServletContext()).andReturn(servletContext); expect(listener.createTilesInitializer()).andReturn(initializer); initializer.initialize(isA(ServletApplicationContext.class)); initializer.destroy(); replay(listener, event, servletContext, initializer); listener.contextInitialized(event); listener.contextDestroyed(event); verify(listener, event, servletContext, initializer); }