TilesAccess { public static TilesContainer getContainer(ApplicationContext context) { return getContainer(context, CONTAINER_ATTRIBUTE); } private  TilesAccess(); static void setContainer(ApplicationContext context,
            TilesContainer container); static void setContainer(ApplicationContext context,
            TilesContainer container, String key); static TilesContainer getContainer(ApplicationContext context); static TilesContainer getContainer(ApplicationContext context,
            String key); static void setCurrentContainer(Request request,
            String key); static void setCurrentContainer(Request request,
            TilesContainer container); static TilesContainer getCurrentContainer(Request request); static final String CURRENT_CONTAINER_ATTRIBUTE_NAME; static final String CONTAINER_ATTRIBUTE; }
@Test public void testGetContainer() { ApplicationContext context = createMock(ApplicationContext.class); TilesContainer container = createMock(TilesContainer.class); Map<String, Object> attribs = new HashMap<String, Object>(); expect(context.getApplicationScope()).andReturn(attribs).anyTimes(); replay(context, container); attribs.put(TilesAccess.CONTAINER_ATTRIBUTE, container); assertEquals(container, TilesAccess.getContainer(context)); verify(context, container); }
@Test public void testGetContainerWithKey() { ApplicationContext context = createMock(ApplicationContext.class); TilesContainer container = createMock(TilesContainer.class); Map<String, Object> attribs = new HashMap<String, Object>(); expect(context.getApplicationScope()).andReturn(attribs).anyTimes(); replay(context, container); attribs.put(TilesAccess.CONTAINER_ATTRIBUTE, container); attribs.put("myKey", container); assertEquals(container, TilesAccess.getContainer(context, null)); assertEquals(container, TilesAccess.getContainer(context, "myKey")); verify(context, container); }