ModularTilesInitializer implements TilesInitializer { public void initialize(ApplicationContext preliminaryContext) { ApplicationContext applicationContext = new WildcardServletApplicationContext( (ServletContext) preliminaryContext.getContext()); loadInitializers(applicationContext); for (TilesInitializer initializer : initializers) { initializer.initialize(preliminaryContext); } }  void initialize(ApplicationContext preliminaryContext); void destroy();  }
@Test public void testInitialize() throws MalformedURLException { ApplicationContext preliminaryContext = createMock(ApplicationContext.class); ServletContext servletContext = createMock(ServletContext.class); URL manifestUrl = getClass().getResource("/FAKE-MANIFEST.MF"); expect(preliminaryContext.getContext()).andReturn(servletContext); expect(servletContext.getResource("/META-INF/MANIFEST.MF")).andReturn(manifestUrl); replay(preliminaryContext, servletContext); ModularTilesInitializer initializer = new ModularTilesInitializer(); initializer.initialize(preliminaryContext); assertTrue(TilesInitializer1.initialized); assertTrue(TilesInitializer2.initialized); initializer.destroy(); assertTrue(TilesInitializer1.destroyed); assertTrue(TilesInitializer2.destroyed); verify(preliminaryContext, servletContext); }