TilesAccess { public static void setContainer(ApplicationContext context, TilesContainer container) { setContainer(context, container, 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 testSetContainer() { ApplicationContext context = createMock(ApplicationContext.class); TilesContainer container = createMock(TilesContainer.class); Map<String, Object> attribs = new HashMap<String, Object>(); expect(context.getApplicationScope()).andReturn(attribs); replay(context, container); TilesAccess.setContainer(context, container); assertEquals(attribs.size(), 1); assertEquals(attribs.get(TilesAccess.CONTAINER_ATTRIBUTE), container); verify(context, container); }
@Test public void testSetContainerWithKey() { 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); TilesAccess.setContainer(context, container, "myKey"); assertEquals(1, attribs.size()); assertEquals(container, attribs.get("myKey")); TilesAccess.setContainer(context, null, "myKey"); assertEquals(0, attribs.size()); TilesAccess.setContainer(context, container, null); assertEquals(1, attribs.size()); assertEquals(container, attribs.get(TilesAccess.CONTAINER_ATTRIBUTE)); verify(context, container); }