mockContainer.expects(once()).method("getRequiredContainerServices").will(returnValue( mockServices.proxy() ));
mockContainer.expects(atLeastOnce()).method("getOptionalContainerServices").will(returnValue( mockServices.proxy() ));
mockPortletRequestContext.expects(atLeastOnce()).method("getContainer").will(returnValue( mockContainer.proxy()));
// Create the render request that is under test, and initialize its state
RenderRequestImpl request = new RenderRequestImpl( (PortletRequestContext)mockPortletRequestContext.proxy(), (PortletRenderResponseContext)mockPortletResponseContext.proxy() );
// Mock the HttpSession, and set its expectations: it will return 0 for the last accessed time, and 5
// for the maximum inactive interval
Mock mockHttpSession = mock( HttpSession.class );
mockHttpSession.expects( once() ).method( "getLastAccessedTime" ).will( returnValue( lastAccessedTime ) );
// Prior to applying PLUTO-474, this expectation is invoked exactly twice, not once
mockHttpSession.expects( once() ).method( "getMaxInactiveInterval" ).will( returnValue( maxInactiveInterval ) );
// Set the expectation for the servlet request - it will return the mock http session
// Prior to applying PLUTO-474, this expectation is invoked exactly twice, not once
mockHttpServletRequest.expects( once() ).method( "getSession" ).will( returnValue( mockHttpSession.proxy() ) );
// this is the important expectation -
// Prior to applying PLUTO-474, the HttpSession was
// incorrectly determined to be invalid, and thus the
// HttpSession's invalidate() method was invoked.
//
// After applying PLUTO-474, invalidate() should never be called
mockHttpSession.expects( never() ).method( "invalidate" );
Mock mockPortletSession = mock( PortletSession.class );
mockPortletEnvironmentService.expects( once() ).method( "createPortletSession" ).will( returnValue( mockPortletSession.proxy() ));
PortletSession s = request.getPortletSession( true );
}