AbstractTilesInitializer implements TilesInitializer { public void initialize(ApplicationContext applicationContext) { this.applicationContext = createTilesApplicationContext(applicationContext); ApplicationAccess.register(applicationContext); String key = getContainerKey(this.applicationContext); container = createContainer(this.applicationContext); TilesAccess.setContainer(this.applicationContext, container, key); }  void initialize(ApplicationContext applicationContext); void destroy(); static final String CONTAINER_KEY_INIT_PARAMETER; }
@SuppressWarnings("unchecked") @Test public void testInitialize() { ApplicationContext context = createMock(ApplicationContext.class); TilesContainer container = createMock(TilesContainer.class); Map<String, Object> scope = createMock(Map.class); expect(containerFactory.createContainer(context)).andReturn(container); expect(context.getApplicationScope()).andReturn(scope).anyTimes(); expect(scope.put(ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE, context)).andReturn(null); expect(scope.put(TilesAccess.CONTAINER_ATTRIBUTE, container)).andReturn(null); expect(scope.remove(TilesAccess.CONTAINER_ATTRIBUTE)).andReturn(container); replay(containerFactory, context, container, scope); initializer.initialize(context); initializer.destroy(); verify(containerFactory, context, container, scope); }