HttpServletResponse mockResponse = createNiceMock(HttpServletResponse.class);
replay(mockRequest);
replay(mockResponse);
Subject subject = newSubject(mockRequest, mockResponse);
Session session = subject.getSession();
Serializable sessionId = session.getId();
assertNotNull(sessionId);
verify(mockRequest);
verify(mockResponse);
mockRequest = createNiceMock(HttpServletRequest.class);
mockResponse = createNiceMock(HttpServletResponse.class);
//now simulate the cookie going with the request and the Subject should be acquired based on that:
Cookie[] cookies = new Cookie[]{new Cookie(ShiroHttpSession.DEFAULT_SESSION_ID_NAME, sessionId.toString())};
expect(mockRequest.getCookies()).andReturn(cookies).anyTimes();
expect(mockRequest.getParameter(isA(String.class))).andReturn(null).anyTimes();
replay(mockRequest);
replay(mockResponse);
subject = newSubject(mockRequest, mockResponse);
session = subject.getSession(false);
assertNotNull(session);
assertEquals(sessionId, session.getId());
verify(mockRequest);
verify(mockResponse);