Add generic signature to getSessionRepository().
Add commit(:Session) method.
This commit is contained in:
@@ -291,8 +291,9 @@ public abstract class AbstractGemFireIntegrationTests extends ForkingClientServe
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected SessionRepository<Session> getSessionRepository() {
|
||||
return this.sessionRepository;
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <S extends Session, T extends SessionRepository<S>> T getSessionRepository() {
|
||||
return (T) this.sessionRepository;
|
||||
}
|
||||
|
||||
protected void assertValidSession(Session session) {
|
||||
@@ -347,6 +348,16 @@ public abstract class AbstractGemFireIntegrationTests extends ForkingClientServe
|
||||
return enableQueryDebugging();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends Session> T commit(T session) {
|
||||
|
||||
return Optional.ofNullable(getSessionRepository())
|
||||
.filter(AbstractGemFireOperationsSessionRepository.class::isInstance)
|
||||
.map(AbstractGemFireOperationsSessionRepository.class::cast)
|
||||
.map(it -> (T) it.commit(session))
|
||||
.orElse(session);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends Session> T createSession() {
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.gemfire.config.annotation.PeerCacheApplication;
|
||||
import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;
|
||||
import org.springframework.session.Session;
|
||||
import org.springframework.session.SessionRepository;
|
||||
import org.springframework.session.data.gemfire.AbstractGemFireIntegrationTests;
|
||||
import org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession;
|
||||
import org.springframework.session.data.gemfire.expiration.config.FixedDurationExpirationSessionRepositoryBeanPostProcessor;
|
||||
@@ -57,8 +58,11 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
public class LazyTimeoutSessionExpirationIntegrationTests extends AbstractGemFireIntegrationTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void sessionRepositoryIsAFixedDurationExpirationSessionRepository() {
|
||||
assertThat(getSessionRepository()).isInstanceOf(FixedDurationExpirationSessionRepository.class);
|
||||
|
||||
assertThat(this.<Session, SessionRepository>getSessionRepository())
|
||||
.isInstanceOf(FixedDurationExpirationSessionRepository.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user