@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);
}