sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
long lastSaved = ((JDBCSessionManager.Session)servlet._session).getLastSaved();
//do another request to change the session attribute
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=set");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
long tmp = ((JDBCSessionManager.Session)servlet._session).getLastSaved();
assertNotEquals(lastSaved, tmp); //set of attribute will cause save to db
lastSaved = tmp;
//do nothing for just a bit longer than the save interval to ensure
//session will be checked against database on next request
Thread.currentThread().sleep((SAVE+2)*1000);
//do another request to access the session, this will cause session to be initially
//checked against db. On exit of request, the access time will need updating, so the
//session will be saved to db.
request = client.newRequest("http://localhost:" + port + "/mod/test?action=tickle");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
tmp = ((JDBCSessionManager.Session)servlet._session).getLastSaved();
assertNotEquals(lastSaved, tmp);
lastSaved = tmp;
//wait a little and do another request to access the session
Thread.currentThread().sleep((SAVE/2)*1000);
//do another request to access the session. This time, the save interval has not
//expired, so we should NOT see a debug trace of loading stale session. Nor should
//the exit of the request cause a save of the updated access time.
request = client.newRequest("http://localhost:" + port + "/mod/test?action=tickle");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
tmp = ((JDBCSessionManager.Session)servlet._session).getLastSaved();
assertEquals(lastSaved, tmp); //the save interval did not expire, so update to the access time will not have been persisted
}
finally