Create ExpiringSession which extends Session
This provides a better separation for consumers of the API. Most users are likely not interested in checking to see if a session is expired so they can focus on the Session API. Fixes #28
This commit is contained in:
@@ -50,7 +50,7 @@ public class MapSessionTests {
|
||||
assertThat(session.hashCode()).isEqualTo(session.getId().hashCode());
|
||||
}
|
||||
|
||||
static class CustomSession implements Session {
|
||||
static class CustomSession implements ExpiringSession {
|
||||
|
||||
@Override
|
||||
public long getCreationTime() {
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.data.redis.core.BoundHashOperations;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
import org.springframework.session.ExpiringSession;
|
||||
import org.springframework.session.MapSession;
|
||||
import org.springframework.session.Session;
|
||||
import org.springframework.session.data.redis.RedisOperationsSessionRepository.RedisSession;
|
||||
@@ -25,7 +26,7 @@ import org.springframework.session.data.redis.RedisOperationsSessionRepository.R
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class RedisOperationsSessionRepositoryTests {
|
||||
@Mock
|
||||
RedisOperations<String,Session> redisOperations;
|
||||
RedisOperations<String,ExpiringSession> redisOperations;
|
||||
@Mock
|
||||
BoundHashOperations<String, Object, Object> boundHashOperations;
|
||||
@Captor
|
||||
@@ -40,7 +41,7 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
|
||||
@Test
|
||||
public void createSessionDefaultMaxInactiveInterval() throws Exception {
|
||||
Session session = redisRepository.createSession();
|
||||
ExpiringSession session = redisRepository.createSession();
|
||||
assertThat(session.getMaxInactiveInterval()).isEqualTo(new MapSession().getMaxInactiveInterval());
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
public void createSessionCustomMaxInactiveInterval() throws Exception {
|
||||
int interval = 1;
|
||||
redisRepository.setDefaultMaxInactiveInterval(interval);
|
||||
Session session = redisRepository.createSession();
|
||||
ExpiringSession session = redisRepository.createSession();
|
||||
assertThat(session.getMaxInactiveInterval()).isEqualTo(interval);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user