public void testGettingAnAuthSessionFromDatastore() {
assertNull(asp.get());
String tempSessionId = "YoYoYo";
{
AuthSession tempSession = new AuthSession();
tempSession.setSessionId(tempSessionId);
tempSession.setExpirationDate(new Date(
new Date().getTime() + 1000000));
Ofy.save().entity(tempSession).now();
cookieHandler.setValue(constants.getSessionCookieName(),
tempSessionId);
}
//Verify that getting the auth session from the http session returns
//an equivalent object. Because the http session serializes, the
//pointers will not be the same
AuthSession authSession = asp.get();
assertNotNull(authSession);
assertEquals(tempSessionId, authSession.getSessionId());
//Reset the auth session provider so that it will not just return the
//same sessions. and remove the session from the datastore. This will
//test whether the same session once retrieved from the datastore can
//be retrieved again from the session.
Ofy.delete().entity(authSession).now();
AuthSession authSessionFromHttpSession = asp.get();
assertNotNull(authSessionFromHttpSession);
assertNotSame(authSession, authSessionFromHttpSession);
assertEquals(tempSessionId, authSessionFromHttpSession.getSessionId());
}