* Tests {@link JspUtil#getCurrentContainer(PageContext)}.
*/
public void testGetCurrentContainer() {
PageContext pageContext = EasyMock.createMock(PageContext.class);
ServletContext context = EasyMock.createMock(ServletContext.class);
TilesContainer defaultContainer = EasyMock.createMock(
TilesContainer.class);
TilesContainer alternateContainer = EasyMock.createMock(
TilesContainer.class);
EasyMock.expect(pageContext.getServletContext()).andReturn(context);
EasyMock.expect(pageContext.getAttribute(ServletUtil
.CURRENT_CONTAINER_ATTRIBUTE_NAME, PageContext.REQUEST_SCOPE))
.andReturn(null);
EasyMock.expect(context.getAttribute(TilesAccess.CONTAINER_ATTRIBUTE))
.andReturn(defaultContainer);
pageContext.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
defaultContainer, PageContext.REQUEST_SCOPE);
pageContext.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
alternateContainer, PageContext.REQUEST_SCOPE);
EasyMock.expect(pageContext.getAttribute(ServletUtil
.CURRENT_CONTAINER_ATTRIBUTE_NAME, PageContext.REQUEST_SCOPE))
.andReturn(alternateContainer);
EasyMock.replay(pageContext, context, defaultContainer, alternateContainer);
TilesContainer currentContainer = JspUtil.getCurrentContainer(pageContext);
assertTrue("The containers are not the same",
currentContainer == defaultContainer);
JspUtil.setCurrentContainer(pageContext, alternateContainer);
currentContainer = JspUtil.getCurrentContainer(pageContext);
EasyMock.verify(pageContext, context, defaultContainer, alternateContainer);