Fix Java 8 ambiguous compiler errors
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package sample.websocket;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ dependencies {
|
||||
"org.apache.derby:derby:10.12.1.1",
|
||||
"com.h2database:h2:$h2Version",
|
||||
"com.hazelcast:hazelcast-client:$hazelcastVersion",
|
||||
"org.hsqldb:hsqldb:2.3.3",
|
||||
"org.hsqldb:hsqldb:2.4.0",
|
||||
"de.flapdoodle.embed:de.flapdoodle.embed.mongo:1.50.2"
|
||||
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
@@ -54,7 +54,14 @@ dependencies {
|
||||
"edu.umd.cs.mtc:multithreadedtc:1.01",
|
||||
"org.springframework:spring-test:$springVersion",
|
||||
"org.assertj:assertj-core:$assertjVersion",
|
||||
"org.springframework.security:spring-security-core:$springSecurityVersion"
|
||||
"org.springframework.security:spring-security-core:$springSecurityVersion",
|
||||
"org.apache.commons:commons-pool2:2.2",
|
||||
"org.apache.derby:derby:10.12.1.1",
|
||||
"com.h2database:h2:$h2Version",
|
||||
"com.hazelcast:hazelcast-client:$hazelcastVersion",
|
||||
"org.hsqldb:hsqldb:2.4.0",
|
||||
"de.flapdoodle.embed:de.flapdoodle.embed.mongo:1.50.2",
|
||||
"redis.clients:jedis:$jedisVersion"
|
||||
|
||||
jacoco "org.jacoco:org.jacoco.agent:0.7.2.201409121644:runtime"
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
|
||||
|
||||
createdSession.setAttribute("attrOne", 1);
|
||||
|
||||
assertThat(save(touch(createdSession)).getAttribute("attrOne")).isEqualTo(1);
|
||||
assertThat(save(touch(createdSession)).<Integer>getAttribute("attrOne")).isEqualTo(1);
|
||||
|
||||
sessionEvent = this.sessionEventListener.waitForSessionEvent(500);
|
||||
|
||||
@@ -206,8 +206,8 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
|
||||
AbstractSessionEvent sessionEvent = this.sessionEventListener.waitForSessionEvent(500);
|
||||
|
||||
assertThat(sessionEvent).isInstanceOf(SessionCreatedEvent.class);
|
||||
assertThat(sessionEvent.getSession()).isEqualTo(expectedSession);
|
||||
assertThat(this.sessionEventListener.getSessionEvent()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isEqualTo(expectedSession);
|
||||
assertThat(this.sessionEventListener.<SessionCreatedEvent>getSessionEvent()).isNull();
|
||||
|
||||
ExpiringSession savedSession = this.gemfireSessionRepository.getSession(expectedSession.getId());
|
||||
|
||||
|
||||
@@ -105,49 +105,43 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
assertThat(this.gemfireSessionRepository.getMaxInactiveIntervalInSeconds())
|
||||
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
|
||||
Region<Object, ExpiringSession> sessionRegion = this.gemfireCache
|
||||
.getRegion(SPRING_SESSION_GEMFIRE_REGION_NAME);
|
||||
Region<Object, ExpiringSession> sessionRegion = this.gemfireCache.getRegion(SPRING_SESSION_GEMFIRE_REGION_NAME);
|
||||
|
||||
assertRegion(sessionRegion, SPRING_SESSION_GEMFIRE_REGION_NAME,
|
||||
DataPolicy.PARTITION);
|
||||
assertEntryIdleTimeout(sessionRegion, ExpirationAction.INVALIDATE,
|
||||
MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
assertRegion(sessionRegion, SPRING_SESSION_GEMFIRE_REGION_NAME, DataPolicy.PARTITION);
|
||||
assertEntryIdleTimeout(sessionRegion, ExpirationAction.INVALIDATE, MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
}
|
||||
|
||||
protected Map<String, ExpiringSession> doFindByIndexNameAndIndexValue(
|
||||
String indexName, String indexValue) {
|
||||
|
||||
return this.gemfireSessionRepository.findByIndexNameAndIndexValue(indexName,
|
||||
indexValue);
|
||||
}
|
||||
|
||||
protected Map<String, ExpiringSession> doFindByPrincipalName(String principalName) {
|
||||
return doFindByIndexNameAndIndexValue(
|
||||
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME,
|
||||
principalName);
|
||||
return doFindByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME,
|
||||
principalName);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
protected Map<String, ExpiringSession> doFindByPrincipalName(String regionName,
|
||||
String principalName) {
|
||||
try {
|
||||
Region<String, ExpiringSession> region = this.gemfireCache
|
||||
.getRegion(regionName);
|
||||
Region<String, ExpiringSession> region = this.gemfireCache.getRegion(regionName);
|
||||
|
||||
assertThat(region).isNotNull();
|
||||
|
||||
QueryService queryService = region.getRegionService().getQueryService();
|
||||
|
||||
String queryString = String.format(
|
||||
GemFireOperationsSessionRepository.FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY,
|
||||
region.getFullPath());
|
||||
String queryString = String.format(GemFireOperationsSessionRepository.FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY,
|
||||
region.getFullPath());
|
||||
|
||||
Query query = queryService.newQuery(queryString);
|
||||
|
||||
SelectResults<ExpiringSession> results = (SelectResults<ExpiringSession>) query
|
||||
.execute(new Object[] { principalName });
|
||||
SelectResults<ExpiringSession> results =
|
||||
(SelectResults<ExpiringSession>) query.execute(new Object[] { principalName });
|
||||
|
||||
Map<String, ExpiringSession> sessions = new HashMap<String, ExpiringSession>(
|
||||
results.size());
|
||||
Map<String, ExpiringSession> sessions = new HashMap<String, ExpiringSession>(results.size());
|
||||
|
||||
for (ExpiringSession session : results.asList()) {
|
||||
sessions.put(session.getId(), session);
|
||||
@@ -167,35 +161,36 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
|
||||
protected ExpiringSession setAttribute(ExpiringSession session, String attributeName,
|
||||
Object attributeValue) {
|
||||
|
||||
session.setAttribute(attributeName, attributeValue);
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findSessionsByIndexedSessionAttributeNameValues() {
|
||||
ExpiringSession johnBlumSession = save(
|
||||
touch(setAttribute(createSession("johnBlum"), "vip", "yes")));
|
||||
ExpiringSession robWinchSession = save(
|
||||
touch(setAttribute(createSession("robWinch"), "vip", "yes")));
|
||||
ExpiringSession jonDoeSession = save(
|
||||
touch(setAttribute(createSession("jonDoe"), "vip", "no")));
|
||||
ExpiringSession pieDoeSession = save(
|
||||
touch(setAttribute(createSession("pieDoe"), "viper", "true")));
|
||||
ExpiringSession johnBlumSession = save(touch(setAttribute(
|
||||
createSession("johnBlum"), "vip", "yes")));
|
||||
ExpiringSession robWinchSession = save(touch(setAttribute(
|
||||
createSession("robWinch"), "vip", "yes")));
|
||||
ExpiringSession jonDoeSession = save(touch(setAttribute(
|
||||
createSession("jonDoe"), "vip", "no")));
|
||||
ExpiringSession pieDoeSession = save(touch(setAttribute(
|
||||
createSession("pieDoe"), "viper", "true")));
|
||||
ExpiringSession sourDoeSession = save(touch(createSession("sourDoe")));
|
||||
|
||||
assertThat(get(johnBlumSession.getId())).isEqualTo(johnBlumSession);
|
||||
assertThat(johnBlumSession.getAttribute("vip")).isEqualTo("yes");
|
||||
assertThat(get(robWinchSession.getId())).isEqualTo(robWinchSession);
|
||||
assertThat(robWinchSession.getAttribute("vip")).isEqualTo("yes");
|
||||
assertThat(get(jonDoeSession.getId())).isEqualTo(jonDoeSession);
|
||||
assertThat(jonDoeSession.getAttribute("vip")).isEqualTo("no");
|
||||
assertThat(get(pieDoeSession.getId())).isEqualTo(pieDoeSession);
|
||||
assertThat(this.<ExpiringSession>get(johnBlumSession.getId())).isEqualTo(johnBlumSession);
|
||||
assertThat(johnBlumSession.<String>getAttribute("vip")).isEqualTo("yes");
|
||||
assertThat(this.<ExpiringSession>get(robWinchSession.getId())).isEqualTo(robWinchSession);
|
||||
assertThat(robWinchSession.<String>getAttribute("vip")).isEqualTo("yes");
|
||||
assertThat(this.<ExpiringSession>get(jonDoeSession.getId())).isEqualTo(jonDoeSession);
|
||||
assertThat(jonDoeSession.<String>getAttribute("vip")).isEqualTo("no");
|
||||
assertThat(this.<ExpiringSession>get(pieDoeSession.getId())).isEqualTo(pieDoeSession);
|
||||
assertThat(pieDoeSession.getAttributeNames().contains("vip")).isFalse();
|
||||
assertThat(get(sourDoeSession.getId())).isEqualTo(sourDoeSession);
|
||||
assertThat(this.<ExpiringSession>get(sourDoeSession.getId())).isEqualTo(sourDoeSession);
|
||||
assertThat(sourDoeSession.getAttributeNames().contains("vip")).isFalse();
|
||||
|
||||
Map<String, ExpiringSession> vipSessions = doFindByIndexNameAndIndexValue("vip",
|
||||
"yes");
|
||||
Map<String, ExpiringSession> vipSessions = doFindByIndexNameAndIndexValue("vip", "yes");
|
||||
|
||||
assertThat(vipSessions).isNotNull();
|
||||
assertThat(vipSessions.size()).isEqualTo(2);
|
||||
@@ -231,11 +226,11 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
ExpiringSession sessionFour = save(touch(createSession("johnBlum")));
|
||||
ExpiringSession sessionFive = save(touch(createSession("robWinch")));
|
||||
|
||||
assertThat(get(sessionOne.getId())).isEqualTo(sessionOne);
|
||||
assertThat(get(sessionTwo.getId())).isEqualTo(sessionTwo);
|
||||
assertThat(get(sessionThree.getId())).isEqualTo(sessionThree);
|
||||
assertThat(get(sessionFour.getId())).isEqualTo(sessionFour);
|
||||
assertThat(get(sessionFive.getId())).isEqualTo(sessionFive);
|
||||
assertThat(this.<ExpiringSession>get(sessionOne.getId())).isEqualTo(sessionOne);
|
||||
assertThat(this.<ExpiringSession>get(sessionTwo.getId())).isEqualTo(sessionTwo);
|
||||
assertThat(this.<ExpiringSession>get(sessionThree.getId())).isEqualTo(sessionThree);
|
||||
assertThat(this.<ExpiringSession>get(sessionFour.getId())).isEqualTo(sessionFour);
|
||||
assertThat(this.<ExpiringSession>get(sessionFive.getId())).isEqualTo(sessionFive);
|
||||
|
||||
Map<String, ExpiringSession> johnBlumSessions = doFindByPrincipalName("johnBlum");
|
||||
|
||||
@@ -261,12 +256,13 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
@Test
|
||||
public void findSessionsBySecurityPrincipalName() {
|
||||
ExpiringSession toSave = this.gemfireSessionRepository.createSession();
|
||||
|
||||
toSave.setAttribute(SPRING_SECURITY_CONTEXT, this.context);
|
||||
|
||||
save(toSave);
|
||||
|
||||
Map<String, ExpiringSession> findByPrincipalName = doFindByPrincipalName(
|
||||
getSecurityName());
|
||||
Map<String, ExpiringSession> findByPrincipalName = doFindByPrincipalName(getSecurityName());
|
||||
|
||||
assertThat(findByPrincipalName).hasSize(1);
|
||||
assertThat(findByPrincipalName.keySet()).containsOnly(toSave.getId());
|
||||
}
|
||||
@@ -274,24 +270,28 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
@Test
|
||||
public void findSessionsByChangedSecurityPrincipalName() {
|
||||
ExpiringSession toSave = this.gemfireSessionRepository.createSession();
|
||||
|
||||
toSave.setAttribute(SPRING_SECURITY_CONTEXT, this.context);
|
||||
|
||||
save(toSave);
|
||||
|
||||
toSave.setAttribute(SPRING_SECURITY_CONTEXT, this.changedContext);
|
||||
|
||||
save(toSave);
|
||||
|
||||
Map<String, ExpiringSession> findByPrincipalName = doFindByPrincipalName(
|
||||
getSecurityName());
|
||||
Map<String, ExpiringSession> findByPrincipalName = doFindByPrincipalName(getSecurityName());
|
||||
|
||||
assertThat(findByPrincipalName).isEmpty();
|
||||
|
||||
findByPrincipalName = doFindByPrincipalName(getChangedSecurityName());
|
||||
|
||||
assertThat(findByPrincipalName).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsNoSessionsByNonExistingPrincipal() {
|
||||
Map<String, ExpiringSession> nonExistingPrincipalSessions = doFindByPrincipalName(
|
||||
"nonExistingPrincipalName");
|
||||
Map<String, ExpiringSession> nonExistingPrincipalSessions =
|
||||
doFindByPrincipalName("nonExistingPrincipalName");
|
||||
|
||||
assertThat(nonExistingPrincipalSessions).isNotNull();
|
||||
assertThat(nonExistingPrincipalSessions.isEmpty()).isTrue();
|
||||
@@ -301,12 +301,12 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
public void findsNoSessionsAfterPrincipalIsRemoved() {
|
||||
String username = "doesNotFindAfterPrincipalRemoved";
|
||||
ExpiringSession session = save(touch(createSession(username)));
|
||||
session.setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME,
|
||||
null);
|
||||
|
||||
session.setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, null);
|
||||
|
||||
save(session);
|
||||
|
||||
Map<String, ExpiringSession> nonExistingPrincipalSessions = doFindByPrincipalName(
|
||||
username);
|
||||
Map<String, ExpiringSession> nonExistingPrincipalSessions = doFindByPrincipalName(username);
|
||||
|
||||
assertThat(nonExistingPrincipalSessions).isNotNull();
|
||||
assertThat(nonExistingPrincipalSessions.isEmpty()).isTrue();
|
||||
@@ -316,14 +316,12 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
public void saveAndReadSessionWithAttributes() {
|
||||
ExpiringSession expectedSession = this.gemfireSessionRepository.createSession();
|
||||
|
||||
assertThat(expectedSession).isInstanceOf(
|
||||
AbstractGemFireOperationsSessionRepository.GemFireSession.class);
|
||||
assertThat(expectedSession).isInstanceOf(AbstractGemFireOperationsSessionRepository.GemFireSession.class);
|
||||
|
||||
((AbstractGemFireOperationsSessionRepository.GemFireSession) expectedSession)
|
||||
.setPrincipalName("jblum");
|
||||
((AbstractGemFireOperationsSessionRepository.GemFireSession) expectedSession).setPrincipalName("jblum");
|
||||
|
||||
List<String> expectedAttributeNames = Arrays.asList("booleanAttribute",
|
||||
"numericAttribute", "stringAttribute", "personAttribute");
|
||||
List<String> expectedAttributeNames = Arrays.asList("booleanAttribute", "numericAttribute", "stringAttribute",
|
||||
"personAttribute");
|
||||
|
||||
Person jonDoe = new Person("Jon", "Doe");
|
||||
|
||||
@@ -334,32 +332,21 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
|
||||
this.gemfireSessionRepository.save(touch(expectedSession));
|
||||
|
||||
ExpiringSession savedSession = this.gemfireSessionRepository
|
||||
.getSession(expectedSession.getId());
|
||||
ExpiringSession savedSession = this.gemfireSessionRepository.getSession(expectedSession.getId());
|
||||
|
||||
assertThat(savedSession).isEqualTo(expectedSession);
|
||||
assertThat(savedSession).isInstanceOf(
|
||||
AbstractGemFireOperationsSessionRepository.GemFireSession.class);
|
||||
assertThat(
|
||||
((AbstractGemFireOperationsSessionRepository.GemFireSession) savedSession)
|
||||
.getPrincipalName()).isEqualTo("jblum");
|
||||
assertThat(savedSession).isInstanceOf(AbstractGemFireOperationsSessionRepository.GemFireSession.class);
|
||||
assertThat(((AbstractGemFireOperationsSessionRepository.GemFireSession) savedSession).getPrincipalName())
|
||||
.isEqualTo("jblum");
|
||||
|
||||
assertThat(savedSession.getAttributeNames().containsAll(expectedAttributeNames))
|
||||
.as(String.format("Expected (%1$s); but was (%2$s)",
|
||||
expectedAttributeNames, savedSession.getAttributeNames()))
|
||||
.as(String.format("Expected (%1$s); but was (%2$s)", expectedAttributeNames, savedSession.getAttributeNames()))
|
||||
.isTrue();
|
||||
|
||||
assertThat(Boolean.valueOf(
|
||||
String.valueOf(savedSession.getAttribute(expectedAttributeNames.get(0)))))
|
||||
.isTrue();
|
||||
assertThat(Double.valueOf(
|
||||
String.valueOf(savedSession.getAttribute(expectedAttributeNames.get(1)))))
|
||||
.isEqualTo(Math.PI);
|
||||
assertThat(
|
||||
String.valueOf(savedSession.getAttribute(expectedAttributeNames.get(2))))
|
||||
.isEqualTo("test");
|
||||
assertThat(savedSession.getAttribute(expectedAttributeNames.get(3)))
|
||||
.isEqualTo(jonDoe);
|
||||
assertThat(savedSession.<Boolean>getAttribute(expectedAttributeNames.get(0))).isTrue();
|
||||
assertThat(savedSession.<Double>getAttribute(expectedAttributeNames.get(1))).isEqualTo(Math.PI);
|
||||
assertThat(savedSession.<String>getAttribute(expectedAttributeNames.get(2))).isEqualTo("test");
|
||||
assertThat(savedSession.<Person>getAttribute(expectedAttributeNames.get(3))).isEqualTo(jonDoe);
|
||||
}
|
||||
|
||||
private String getSecurityName() {
|
||||
@@ -373,13 +360,10 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
@EnableGemFireHttpSession(regionName = SPRING_SESSION_GEMFIRE_REGION_NAME, maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS)
|
||||
static class SpringSessionGemFireConfiguration {
|
||||
|
||||
@Bean
|
||||
Properties gemfireProperties() {
|
||||
Properties gemfireProperties = new Properties();
|
||||
|
||||
gemfireProperties.setProperty("name",
|
||||
GemFireOperationsSessionRepositoryIntegrationTests.class.getName());
|
||||
gemfireProperties.setProperty("mcast-port", "0");
|
||||
gemfireProperties.setProperty("name", GemFireOperationsSessionRepositoryIntegrationTests.class.getName());
|
||||
gemfireProperties.setProperty("log-level", GEMFIRE_LOG_LEVEL);
|
||||
|
||||
return gemfireProperties;
|
||||
@@ -410,8 +394,7 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
|
||||
}
|
||||
|
||||
private String validate(String value) {
|
||||
Assert.hasText(value,
|
||||
String.format("The String value (%1$s) must be specified!", value));
|
||||
Assert.hasText(value, String.format("The String value (%1$s) must be specified!", value));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
|
||||
|
||||
assertThat(sessionEvent).isInstanceOf(SessionCreatedEvent.class);
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isEqualTo(expectedSession);
|
||||
assertThat(this.sessionEventListener.getSessionEvent()).isNull();
|
||||
assertThat(this.sessionEventListener.<SessionCreatedEvent>getSessionEvent()).isNull();
|
||||
|
||||
ExpiringSession savedSession = this.gemfireSessionRepository.getSession(expectedSession.getId());
|
||||
|
||||
|
||||
@@ -87,16 +87,13 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
|
||||
assertThat(GemFireUtils.isPeer(this.gemfireCache)).isTrue();
|
||||
assertThat(this.gemfireSessionRepository).isNotNull();
|
||||
assertThat(this.gemfireSessionRepository.getMaxInactiveIntervalInSeconds())
|
||||
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
assertThat(this.sessionEventListener).isNotNull();
|
||||
|
||||
Region<Object, ExpiringSession> sessionRegion = this.gemfireCache
|
||||
.getRegion(SPRING_SESSION_GEMFIRE_REGION_NAME);
|
||||
Region<Object, ExpiringSession> sessionRegion = this.gemfireCache.getRegion(SPRING_SESSION_GEMFIRE_REGION_NAME);
|
||||
|
||||
assertRegion(sessionRegion, SPRING_SESSION_GEMFIRE_REGION_NAME,
|
||||
DataPolicy.REPLICATE);
|
||||
assertEntryIdleTimeout(sessionRegion, ExpirationAction.INVALIDATE,
|
||||
MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
assertRegion(sessionRegion, SPRING_SESSION_GEMFIRE_REGION_NAME, DataPolicy.REPLICATE);
|
||||
assertEntryIdleTimeout(sessionRegion, ExpirationAction.INVALIDATE, MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -118,12 +115,9 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
|
||||
|
||||
assertThat(createdSession).isEqualTo(expectedSession);
|
||||
assertThat(createdSession.getId()).isNotNull();
|
||||
assertThat(createdSession.getCreationTime())
|
||||
.isGreaterThanOrEqualTo(beforeOrAtCreationTime);
|
||||
assertThat(createdSession.getLastAccessedTime())
|
||||
.isEqualTo(createdSession.getCreationTime());
|
||||
assertThat(createdSession.getMaxInactiveIntervalInSeconds())
|
||||
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
assertThat(createdSession.getCreationTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime);
|
||||
assertThat(createdSession.getLastAccessedTime()).isEqualTo(createdSession.getCreationTime());
|
||||
assertThat(createdSession.getMaxInactiveIntervalInSeconds()).isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
assertThat(createdSession.isExpired()).isFalse();
|
||||
}
|
||||
|
||||
@@ -134,8 +128,7 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
|
||||
assertThat(expectedSession.isExpired()).isFalse();
|
||||
|
||||
// NOTE though unlikely, a possible race condition exists between save and get...
|
||||
ExpiringSession savedSession = this.gemfireSessionRepository
|
||||
.getSession(expectedSession.getId());
|
||||
ExpiringSession savedSession = this.gemfireSessionRepository.getSession(expectedSession.getId());
|
||||
|
||||
assertThat(savedSession).isEqualTo(expectedSession);
|
||||
}
|
||||
@@ -152,21 +145,18 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
|
||||
|
||||
assertThat(createdSession).isEqualTo(expectedSession);
|
||||
assertThat(createdSession.isExpired()).isTrue();
|
||||
assertThat(this.gemfireSessionRepository.getSession(createdSession.getId()))
|
||||
.isNull();
|
||||
assertThat(this.gemfireSessionRepository.getSession(createdSession.getId())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNonExistingSession() {
|
||||
assertThat(this.gemfireSessionRepository.getSession(UUID.randomUUID().toString()))
|
||||
.isNull();
|
||||
assertThat(this.gemfireSessionRepository.getSession(UUID.randomUUID().toString())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteExistingNonExpiredSession() {
|
||||
ExpiringSession expectedSession = save(touch(createSession()));
|
||||
ExpiringSession savedSession = this.gemfireSessionRepository
|
||||
.getSession(expectedSession.getId());
|
||||
ExpiringSession savedSession = this.gemfireSessionRepository.getSession(expectedSession.getId());
|
||||
|
||||
assertThat(savedSession).isEqualTo(expectedSession);
|
||||
assertThat(savedSession.isExpired()).isFalse();
|
||||
@@ -181,8 +171,7 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
|
||||
ExpiringSession deletedSession = sessionEvent.getSession();
|
||||
|
||||
assertThat(deletedSession).isEqualTo(savedSession);
|
||||
assertThat(this.gemfireSessionRepository.getSession(deletedSession.getId()))
|
||||
.isNull();
|
||||
assertThat(this.gemfireSessionRepository.getSession(deletedSession.getId())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -197,9 +186,8 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
|
||||
|
||||
assertThat(createdSession).isEqualTo(expectedSession);
|
||||
|
||||
sessionEvent = this.sessionEventListener.waitForSessionEvent(TimeUnit.SECONDS
|
||||
.toMillis(this.gemfireSessionRepository.getMaxInactiveIntervalInSeconds()
|
||||
+ 1));
|
||||
sessionEvent = this.sessionEventListener.waitForSessionEvent(
|
||||
TimeUnit.SECONDS.toMillis(this.gemfireSessionRepository.getMaxInactiveIntervalInSeconds() + 1));
|
||||
|
||||
assertThat(sessionEvent).isInstanceOf(SessionExpiredEvent.class);
|
||||
|
||||
@@ -213,24 +201,23 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
|
||||
sessionEvent = this.sessionEventListener.getSessionEvent();
|
||||
|
||||
assertThat(sessionEvent).isInstanceOf(SessionDeletedEvent.class);
|
||||
assertThat(sessionEvent.getSession()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isNull();
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(expiredSession.getId());
|
||||
assertThat(this.gemfireSessionRepository.getSession(sessionEvent.getSessionId()))
|
||||
.isNull();
|
||||
assertThat(this.gemfireSessionRepository.<ExpiringSession>getSession(sessionEvent.getSessionId())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteNonExistingSession() {
|
||||
String expectedSessionId = UUID.randomUUID().toString();
|
||||
|
||||
assertThat(this.gemfireSessionRepository.getSession(expectedSessionId)).isNull();
|
||||
assertThat(this.gemfireSessionRepository.<ExpiringSession>getSession(expectedSessionId)).isNull();
|
||||
|
||||
this.gemfireSessionRepository.delete(expectedSessionId);
|
||||
|
||||
AbstractSessionEvent sessionEvent = this.sessionEventListener.getSessionEvent();
|
||||
|
||||
assertThat(sessionEvent).isInstanceOf(SessionDeletedEvent.class);
|
||||
assertThat(sessionEvent.getSession()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isNull();
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSessionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ abstract public class AbstractMongoRepositoryITests extends AbstractITests {
|
||||
|
||||
assertThat(session.getId()).isEqualTo(toSave.getId());
|
||||
assertThat(session.getAttributeNames()).isEqualTo(toSave.getAttributeNames());
|
||||
assertThat(session.getAttribute(expectedAttributeName))
|
||||
assertThat(session.<String>getAttribute(expectedAttributeName))
|
||||
.isEqualTo(toSave.getAttribute(expectedAttributeName));
|
||||
|
||||
this.repository.delete(toSave.getId());
|
||||
@@ -102,8 +102,8 @@ abstract public class AbstractMongoRepositoryITests extends AbstractITests {
|
||||
|
||||
Session session = this.repository.getSession(toSave.getId());
|
||||
assertThat(session.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(session.getAttribute("a")).isEqualTo("b");
|
||||
assertThat(session.getAttribute("1")).isEqualTo("2");
|
||||
assertThat(session.<String>getAttribute("a")).isEqualTo("b");
|
||||
assertThat(session.<String>getAttribute("1")).isEqualTo("2");
|
||||
|
||||
this.repository.delete(toSave.getId());
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class RedisOperationsSessionRepositoryITests extends AbstractITests {
|
||||
this.repository.save(toSave);
|
||||
|
||||
assertThat(this.registry.receivedEvent(toSave.getId())).isTrue();
|
||||
assertThat(this.registry.getEvent(toSave.getId()))
|
||||
assertThat(this.registry.<SessionCreatedEvent>getEvent(toSave.getId()))
|
||||
.isInstanceOf(SessionCreatedEvent.class);
|
||||
assertThat(this.redis.boundSetOps(usernameSessionKey).members())
|
||||
.contains(toSave.getId());
|
||||
@@ -86,7 +86,7 @@ public class RedisOperationsSessionRepositoryITests extends AbstractITests {
|
||||
|
||||
assertThat(session.getId()).isEqualTo(toSave.getId());
|
||||
assertThat(session.getAttributeNames()).isEqualTo(toSave.getAttributeNames());
|
||||
assertThat(session.getAttribute(expectedAttributeName))
|
||||
assertThat(session.<String>getAttribute(expectedAttributeName))
|
||||
.isEqualTo(toSave.getAttribute(expectedAttributeName));
|
||||
|
||||
this.registry.clear();
|
||||
@@ -94,13 +94,13 @@ public class RedisOperationsSessionRepositoryITests extends AbstractITests {
|
||||
this.repository.delete(toSave.getId());
|
||||
|
||||
assertThat(this.repository.getSession(toSave.getId())).isNull();
|
||||
assertThat(this.registry.getEvent(toSave.getId()))
|
||||
assertThat(this.registry.<SessionDestroyedEvent>getEvent(toSave.getId()))
|
||||
.isInstanceOf(SessionDestroyedEvent.class);
|
||||
assertThat(this.redis.boundSetOps(usernameSessionKey).members())
|
||||
.doesNotContain(toSave.getId());
|
||||
|
||||
assertThat(this.registry.getEvent(toSave.getId()).getSession()
|
||||
.getAttribute(expectedAttributeName)).isEqualTo(expectedAttributeValue);
|
||||
.<String>getAttribute(expectedAttributeName)).isEqualTo(expectedAttributeValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,8 +118,8 @@ public class RedisOperationsSessionRepositoryITests extends AbstractITests {
|
||||
|
||||
Session session = this.repository.getSession(toSave.getId());
|
||||
assertThat(session.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(session.getAttribute("a")).isEqualTo("b");
|
||||
assertThat(session.getAttribute("1")).isEqualTo("2");
|
||||
assertThat(session.<String>getAttribute("a")).isEqualTo("b");
|
||||
assertThat(session.<String>getAttribute("1")).isEqualTo("2");
|
||||
|
||||
this.repository.delete(toSave.getId());
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class EnableHazelcastHttpSessionEventsTests<S extends ExpiringSession> {
|
||||
this.repository.save(sessionToSave);
|
||||
|
||||
assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
|
||||
assertThat(this.registry.getEvent(sessionToSave.getId()))
|
||||
assertThat(this.registry.<SessionCreatedEvent>getEvent(sessionToSave.getId()))
|
||||
.isInstanceOf(SessionCreatedEvent.class);
|
||||
|
||||
Session session = this.repository.getSession(sessionToSave.getId());
|
||||
@@ -97,7 +97,7 @@ public class EnableHazelcastHttpSessionEventsTests<S extends ExpiringSession> {
|
||||
assertThat(session.getId()).isEqualTo(sessionToSave.getId());
|
||||
assertThat(session.getAttributeNames())
|
||||
.isEqualTo(sessionToSave.getAttributeNames());
|
||||
assertThat(session.getAttribute(expectedAttributeName))
|
||||
assertThat(session.<String>getAttribute(expectedAttributeName))
|
||||
.isEqualTo(sessionToSave.getAttribute(expectedAttributeName));
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class EnableHazelcastHttpSessionEventsTests<S extends ExpiringSession> {
|
||||
this.repository.save(sessionToSave);
|
||||
|
||||
assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
|
||||
assertThat(this.registry.getEvent(sessionToSave.getId()))
|
||||
assertThat(this.registry.<SessionCreatedEvent>getEvent(sessionToSave.getId()))
|
||||
.isInstanceOf(SessionCreatedEvent.class);
|
||||
this.registry.clear();
|
||||
|
||||
@@ -116,10 +116,10 @@ public class EnableHazelcastHttpSessionEventsTests<S extends ExpiringSession> {
|
||||
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
|
||||
assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
|
||||
assertThat(this.registry.getEvent(sessionToSave.getId()))
|
||||
assertThat(this.registry.<SessionExpiredEvent>getEvent(sessionToSave.getId()))
|
||||
.isInstanceOf(SessionExpiredEvent.class);
|
||||
|
||||
assertThat(this.repository.getSession(sessionToSave.getId())).isNull();
|
||||
assertThat(this.repository.<ExpiringSession>getSession(sessionToSave.getId())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,14 +129,14 @@ public class EnableHazelcastHttpSessionEventsTests<S extends ExpiringSession> {
|
||||
this.repository.save(sessionToSave);
|
||||
|
||||
assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
|
||||
assertThat(this.registry.getEvent(sessionToSave.getId()))
|
||||
assertThat(this.registry.<SessionCreatedEvent>getEvent(sessionToSave.getId()))
|
||||
.isInstanceOf(SessionCreatedEvent.class);
|
||||
this.registry.clear();
|
||||
|
||||
this.repository.delete(sessionToSave.getId());
|
||||
|
||||
assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue();
|
||||
assertThat(this.registry.getEvent(sessionToSave.getId()))
|
||||
assertThat(this.registry.<SessionDeletedEvent>getEvent(sessionToSave.getId()))
|
||||
.isInstanceOf(SessionDeletedEvent.class);
|
||||
|
||||
assertThat(this.repository.getSession(sessionToSave.getId())).isNull();
|
||||
|
||||
@@ -104,7 +104,7 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests {
|
||||
|
||||
assertThat(session.getId()).isEqualTo(toSave.getId());
|
||||
assertThat(session.getAttributeNames()).isEqualTo(toSave.getAttributeNames());
|
||||
assertThat(session.getAttribute(expectedAttributeName))
|
||||
assertThat(session.<String>getAttribute(expectedAttributeName))
|
||||
.isEqualTo(toSave.getAttribute(expectedAttributeName));
|
||||
|
||||
this.repository.delete(toSave.getId());
|
||||
@@ -137,8 +137,8 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests {
|
||||
|
||||
Session session = this.repository.getSession(toSave.getId());
|
||||
assertThat(session.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(session.getAttribute("a")).isEqualTo("b");
|
||||
assertThat(session.getAttribute("1")).isEqualTo("2");
|
||||
assertThat(session.<String>getAttribute("a")).isEqualTo("b");
|
||||
assertThat(session.<String>getAttribute("1")).isEqualTo("2");
|
||||
|
||||
this.repository.delete(toSave.getId());
|
||||
}
|
||||
@@ -576,5 +576,4 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isEqualTo(mockSession);
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isEqualTo(mockSession);
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -284,7 +284,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isNull();
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -350,7 +350,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isEqualTo(mockSession);
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isEqualTo(mockSession);
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -392,7 +392,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isNull();
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -433,7 +433,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isNull();
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -477,7 +477,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isEqualTo(mockSession);
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isEqualTo(mockSession);
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -518,7 +518,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isNull();
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -559,7 +559,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isNull();
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -614,7 +614,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isEqualTo(mockSession);
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isEqualTo(mockSession);
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -647,7 +647,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isNull();
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId);
|
||||
|
||||
return null;
|
||||
@@ -757,8 +757,8 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
assertThat(gemfireSession.getLastAccessedTime()).isEqualTo(expectedLastAccessTime);
|
||||
assertThat(gemfireSession.getMaxInactiveIntervalInSeconds()).isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
assertThat(gemfireSession.getAttributeNames()).isEqualTo(expectedAttributedNames);
|
||||
assertThat(String.valueOf(gemfireSession.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(String.valueOf(gemfireSession.getAttribute("attrTwo"))).isEqualTo("testTwo");
|
||||
assertThat(gemfireSession.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(gemfireSession.<String>getAttribute("attrTwo")).isEqualTo("testTwo");
|
||||
|
||||
verify(mockSession, times(1)).getId();
|
||||
verify(mockSession, times(1)).getCreationTime();
|
||||
@@ -850,25 +850,25 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
session.setAttribute("attrOne", "testOne");
|
||||
|
||||
assertThat(session.getAttributeNames()).isEqualTo(asSet("attrOne"));
|
||||
assertThat(String.valueOf(session.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(session.getAttribute("attrTwo")).isNull();
|
||||
assertThat(session.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(session.<String>getAttribute("attrTwo")).isNull();
|
||||
|
||||
session.setAttribute("attrTwo", "testTwo");
|
||||
|
||||
assertThat(session.getAttributeNames()).isEqualTo(asSet("attrOne", "attrTwo"));
|
||||
assertThat(String.valueOf(session.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(String.valueOf(session.getAttribute("attrTwo"))).isEqualTo("testTwo");
|
||||
assertThat(session.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(session.<String>getAttribute("attrTwo")).isEqualTo("testTwo");
|
||||
|
||||
session.setAttribute("attrTwo", null);
|
||||
|
||||
assertThat(session.getAttributeNames()).isEqualTo(asSet("attrOne"));
|
||||
assertThat(String.valueOf(session.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(session.getAttribute("attrTwo")).isNull();
|
||||
assertThat(session.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(session.<String>getAttribute("attrTwo")).isNull();
|
||||
|
||||
session.removeAttribute("attrOne");
|
||||
|
||||
assertThat(session.getAttribute("attrOne")).isNull();
|
||||
assertThat(session.getAttribute("attrTwo")).isNull();
|
||||
assertThat(session.<String>getAttribute("attrOne")).isNull();
|
||||
assertThat(session.<String>getAttribute("attrTwo")).isNull();
|
||||
assertThat(session.getAttributeNames().isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@@ -933,14 +933,14 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
assertThat(session.getPrincipalName()).isEqualTo("jblum");
|
||||
assertThat(session.getAttributeNames())
|
||||
.isEqualTo(asSet(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME));
|
||||
assertThat(String.valueOf(session.getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME)))
|
||||
assertThat(session.<String>getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))
|
||||
.isEqualTo("jblum");
|
||||
|
||||
session.setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "rwinch");
|
||||
|
||||
assertThat(session.getAttributeNames())
|
||||
.isEqualTo(asSet(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME));
|
||||
assertThat(String.valueOf(session.getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME)))
|
||||
assertThat(session.<String>getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))
|
||||
.isEqualTo("rwinch");
|
||||
assertThat(session.getPrincipalName()).isEqualTo("rwinch");
|
||||
|
||||
@@ -1024,9 +1024,9 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
assertThat(session.getPrincipalName()).isEqualTo(expectedPrincipalName);
|
||||
assertThat(session.getAttributeNames().size()).isEqualTo(3);
|
||||
assertThat(session.getAttributeNames().containsAll(expectedAttributeNames)).isTrue();
|
||||
assertThat(String.valueOf(session.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(String.valueOf(session.getAttribute("attrTwo"))).isEqualTo("testTwo");
|
||||
assertThat(String.valueOf(session.getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME)))
|
||||
assertThat(session.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(session.<String>getAttribute("attrTwo")).isEqualTo("testTwo");
|
||||
assertThat(session.<String>getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))
|
||||
.isEqualTo(expectedPrincipalName);
|
||||
|
||||
verify(mockDataInput, times(2)).readUTF();
|
||||
@@ -1268,8 +1268,8 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue();
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("testTwo");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrTwo")).isEqualTo("testTwo");
|
||||
|
||||
verify(mockSession, times(1)).getAttributeNames();
|
||||
verify(mockSession, times(1)).getAttribute(eq("attrOne"));
|
||||
@@ -1293,8 +1293,8 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(target.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(target.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue();
|
||||
assertThat(String.valueOf(target.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(String.valueOf(target.getAttribute("attrTwo"))).isEqualTo("testTwo");
|
||||
assertThat(target.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(target.<String>getAttribute("attrTwo")).isEqualTo("testTwo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1349,8 +1349,8 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue();
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("testTwo");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrTwo")).isEqualTo("testTwo");
|
||||
|
||||
verify(mockDataInput, times(1)).readInt();
|
||||
verify(mockDataInput, times(2)).readUTF();
|
||||
@@ -1370,7 +1370,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
sessionAttributes.setAttribute("attrOne", "testOne");
|
||||
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(sessionAttributes.hasDelta()).isTrue();
|
||||
}
|
||||
|
||||
@@ -1450,16 +1450,16 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue();
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("one");
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("two");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrOne")).isEqualTo("one");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrTwo")).isEqualTo("two");
|
||||
assertThat(sessionAttributes.hasDelta()).isTrue();
|
||||
|
||||
sessionAttributes.fromDelta(mockDataInput);
|
||||
|
||||
assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue();
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("testOne");
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("testTwo");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrOne")).isEqualTo("testOne");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrTwo")).isEqualTo("testTwo");
|
||||
assertThat(sessionAttributes.hasDelta()).isFalse();
|
||||
|
||||
verify(mockDataInput, times(1)).readInt();
|
||||
@@ -1474,16 +1474,16 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue();
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("one");
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("two");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrOne")).isEqualTo("one");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrTwo")).isEqualTo("two");
|
||||
assertThat(sessionAttributes.hasDelta()).isTrue();
|
||||
|
||||
sessionAttributes.fromDelta(mockDataInput);
|
||||
|
||||
assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2);
|
||||
assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue();
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("one");
|
||||
assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("testThree");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrOne")).isEqualTo("one");
|
||||
assertThat(sessionAttributes.<String>getAttribute("attrTwo")).isEqualTo("testThree");
|
||||
assertThat(sessionAttributes.hasDelta()).isTrue();
|
||||
|
||||
verify(mockDataInput, times(1)).readInt();
|
||||
@@ -1584,8 +1584,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
assertThat(this.session.getMaxInactiveIntervalInSeconds()).isEqualTo(60);
|
||||
assertThat(this.session.getPrincipalName()).isEqualTo("jblum");
|
||||
assertThat(this.session.getAttributeNames().size()).isEqualTo(1);
|
||||
assertThat(String.valueOf(
|
||||
this.session.getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME)))
|
||||
assertThat(this.session.<String>getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))
|
||||
.isEqualTo("jblum");
|
||||
|
||||
this.session.setAttribute("tennis", "ping");
|
||||
@@ -1605,9 +1604,9 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
assertThat(this.session.getAttributeNames().size()).isEqualTo(3);
|
||||
assertThat(this.session.getAttributeNames().containsAll(asSet("tennis", "greeting"))).isTrue();
|
||||
assertThat(this.session.getAttributeNames().contains("junk")).isFalse();
|
||||
assertThat(this.session.getAttribute("junk")).isNull();
|
||||
assertThat(String.valueOf(this.session.getAttribute("tennis"))).isEqualTo("pong");
|
||||
assertThat(String.valueOf(this.session.getAttribute("greeting"))).isEqualTo("hello");
|
||||
assertThat(this.session.<String>getAttribute("junk")).isNull();
|
||||
assertThat(this.session.<String>getAttribute("tennis")).isEqualTo("pong");
|
||||
assertThat(this.session.<String>getAttribute("greeting")).isEqualTo("hello");
|
||||
}
|
||||
|
||||
public void thread2() {
|
||||
@@ -1626,8 +1625,8 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
assertThat(this.session.getPrincipalName()).isEqualTo("rwinch");
|
||||
assertThat(this.session.getAttributeNames().size()).isEqualTo(3);
|
||||
assertThat(this.session.getAttributeNames().containsAll(asSet("tennis", "junk"))).isTrue();
|
||||
assertThat(String.valueOf(this.session.getAttribute("junk"))).isEqualTo("test");
|
||||
assertThat(String.valueOf(this.session.getAttribute("tennis"))).isEqualTo("ping");
|
||||
assertThat(this.session.<String>getAttribute("junk")).isEqualTo("test");
|
||||
assertThat(this.session.<String>getAttribute("tennis")).isEqualTo("ping");
|
||||
|
||||
this.session.setAttribute("tennis", "pong");
|
||||
this.session.setAttribute("greeting", "hello");
|
||||
|
||||
@@ -262,7 +262,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isSameAs(GemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isSameAs(mockSession);
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isSameAs(mockSession);
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSessionId);
|
||||
|
||||
return null;
|
||||
@@ -304,7 +304,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
assertThat(actualSession.getLastAccessedTime()).isNotEqualTo(currentLastAccessedTime);
|
||||
assertThat(actualSession.getLastAccessedTime()).isGreaterThanOrEqualTo(expectedCreationTime);
|
||||
assertThat(actualSession.getAttributeNames()).isEqualTo(Collections.singleton("attrOne"));
|
||||
assertThat(String.valueOf(actualSession.getAttribute("attrOne"))).isEqualTo("test");
|
||||
assertThat(String.valueOf(actualSession.<String>getAttribute("attrOne"))).isEqualTo("test");
|
||||
|
||||
verify(this.mockTemplate, times(1)).get(eq(expectedId));
|
||||
verify(mockSession, times(1)).isExpired();
|
||||
@@ -385,7 +385,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource())
|
||||
.isSameAs(GemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isSameAs(mockSession);
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isSameAs(mockSession);
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSessionId);
|
||||
|
||||
return null;
|
||||
@@ -416,7 +416,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
assertThat(sessionEvent.getSource()).
|
||||
isSameAs(GemFireOperationsSessionRepositoryTest.this.sessionRepository);
|
||||
assertThat(sessionEvent.getSession()).isNull();
|
||||
assertThat(sessionEvent.<ExpiringSession>getSession()).isNull();
|
||||
assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSessionId);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -289,14 +289,16 @@ public class GemFireHttpSessionConfigurationTest {
|
||||
this.gemfireConfiguration.sessionRegion(mockGemFireCache, mockRegionAttributes);
|
||||
|
||||
assertThat(sessionRegionFactoryBean).isNotNull();
|
||||
assertThat(getField(sessionRegionFactoryBean, "clientRegionShortcut")).isEqualTo(
|
||||
ClientRegionShortcut.CACHING_PROXY);
|
||||
assertThat(getField(sessionRegionFactoryBean, "gemfireCache")).isEqualTo(mockGemFireCache);
|
||||
assertThat(getField(sessionRegionFactoryBean, "poolName")).isEqualTo("TestPool");
|
||||
assertThat(getField(sessionRegionFactoryBean, "regionAttributes")).isEqualTo(mockRegionAttributes);
|
||||
assertThat(getField(sessionRegionFactoryBean, "regionName")).isEqualTo("TestRegion");
|
||||
assertThat(getField(sessionRegionFactoryBean, "serverRegionShortcut")).isEqualTo(
|
||||
RegionShortcut.REPLICATE_PERSISTENT);
|
||||
assertThat(this.<ClientRegionShortcut>getField(sessionRegionFactoryBean, "clientRegionShortcut"))
|
||||
.isEqualTo(ClientRegionShortcut.CACHING_PROXY);
|
||||
assertThat(this.<GemFireCache>getField(sessionRegionFactoryBean, "gemfireCache"))
|
||||
.isEqualTo(mockGemFireCache);
|
||||
assertThat(this.<String>getField(sessionRegionFactoryBean, "poolName")).isEqualTo("TestPool");
|
||||
assertThat(this.<RegionAttributes<Object, ExpiringSession>>getField(sessionRegionFactoryBean,
|
||||
"regionAttributes")).isEqualTo(mockRegionAttributes);
|
||||
assertThat(this.<String>getField(sessionRegionFactoryBean, "regionName")).isEqualTo("TestRegion");
|
||||
assertThat(this.<RegionShortcut>getField(sessionRegionFactoryBean, "serverRegionShortcut"))
|
||||
.isEqualTo(RegionShortcut.REPLICATE_PERSISTENT);
|
||||
|
||||
verifyZeroInteractions(mockGemFireCache);
|
||||
verifyZeroInteractions(mockRegionAttributes);
|
||||
|
||||
@@ -390,7 +390,7 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
RedisSession session = this.redisRepository.getSession(expected.getId());
|
||||
assertThat(session.getId()).isEqualTo(expected.getId());
|
||||
assertThat(session.getAttributeNames()).isEqualTo(expected.getAttributeNames());
|
||||
assertThat(session.getAttribute(attrName))
|
||||
assertThat(session.<String>getAttribute(attrName))
|
||||
.isEqualTo(expected.getAttribute(attrName));
|
||||
assertThat(session.getCreationTime()).isEqualTo(expected.getCreationTime());
|
||||
assertThat(session.getMaxInactiveIntervalInSeconds())
|
||||
|
||||
@@ -269,7 +269,7 @@ public class HazelcastSessionRepositoryTests {
|
||||
HazelcastSession session = this.repository.getSession(saved.getId());
|
||||
|
||||
assertThat(session.getId()).isEqualTo(saved.getId());
|
||||
assertThat(session.getAttribute("savedName")).isEqualTo("savedValue");
|
||||
assertThat(session.<String>getAttribute("savedName")).isEqualTo("savedValue");
|
||||
verify(this.sessions, times(1)).get(eq(saved.getId()));
|
||||
}
|
||||
|
||||
|
||||
@@ -443,7 +443,7 @@ public class JdbcOperationsSessionRepositoryTests {
|
||||
|
||||
assertThat(session.getId()).isEqualTo(saved.getId());
|
||||
assertThat(session.isNew()).isFalse();
|
||||
assertThat(session.getAttribute("savedName")).isEqualTo("savedValue");
|
||||
assertThat(session.<String>getAttribute("savedName")).isEqualTo("savedValue");
|
||||
assertPropagationRequiresNew();
|
||||
verify(this.jdbcOperations, times(1)).query(isA(String.class),
|
||||
isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class));
|
||||
|
||||
@@ -121,7 +121,8 @@ public class SpringSessionBackedSessionRegistryTest {
|
||||
assertThat(sessionInfo.isExpired()).isTrue();
|
||||
ArgumentCaptor<ExpiringSession> captor = ArgumentCaptor.forClass(ExpiringSession.class);
|
||||
verify(this.sessionRepository).save(captor.capture());
|
||||
assertThat(captor.getValue().getAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR)).isEqualTo(Boolean.TRUE);
|
||||
assertThat(captor.getValue().<Boolean>getAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR))
|
||||
.isEqualTo(Boolean.TRUE);
|
||||
}
|
||||
|
||||
private ExpiringSession createSession(String sessionId, String userName, Long lastAccessed) {
|
||||
|
||||
Reference in New Issue
Block a user