diff --git a/samples/boot/websocket/src/main/java/sample/websocket/WebSocketDisconnectHandler.java b/samples/boot/websocket/src/main/java/sample/websocket/WebSocketDisconnectHandler.java index 69869f90..ce255563 100644 --- a/samples/boot/websocket/src/main/java/sample/websocket/WebSocketDisconnectHandler.java +++ b/samples/boot/websocket/src/main/java/sample/websocket/WebSocketDisconnectHandler.java @@ -16,7 +16,6 @@ package sample.websocket; -import java.util.Arrays; import java.util.Collections; import java.util.Optional; diff --git a/spring-session/build.gradle b/spring-session/build.gradle index 2770d365..7d7de61d 100644 --- a/spring-session/build.gradle +++ b/spring-session/build.gradle @@ -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" diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerGemFireOperationsSessionRepositoryIntegrationTests.java b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerGemFireOperationsSessionRepositoryIntegrationTests.java index 82e35bf1..1ef67181 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerGemFireOperationsSessionRepositoryIntegrationTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerGemFireOperationsSessionRepositoryIntegrationTests.java @@ -190,7 +190,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests createdSession.setAttribute("attrOne", 1); - assertThat(save(touch(createdSession)).getAttribute("attrOne")).isEqualTo(1); + assertThat(save(touch(createdSession)).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.getSession()).isEqualTo(expectedSession); + assertThat(this.sessionEventListener.getSessionEvent()).isNull(); ExpiringSession savedSession = this.gemfireSessionRepository.getSession(expectedSession.getId()); diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryIntegrationTests.java b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryIntegrationTests.java index 30556f5c..32dec376 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryIntegrationTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryIntegrationTests.java @@ -105,49 +105,43 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract assertThat(this.gemfireSessionRepository.getMaxInactiveIntervalInSeconds()) .isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); - Region sessionRegion = this.gemfireCache - .getRegion(SPRING_SESSION_GEMFIRE_REGION_NAME); + Region 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 doFindByIndexNameAndIndexValue( String indexName, String indexValue) { + return this.gemfireSessionRepository.findByIndexNameAndIndexValue(indexName, indexValue); } protected Map doFindByPrincipalName(String principalName) { - return doFindByIndexNameAndIndexValue( - FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, - principalName); + return doFindByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, + principalName); } @SuppressWarnings({ "unchecked" }) protected Map doFindByPrincipalName(String regionName, String principalName) { try { - Region region = this.gemfireCache - .getRegion(regionName); + Region 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 results = (SelectResults) query - .execute(new Object[] { principalName }); + SelectResults results = + (SelectResults) query.execute(new Object[] { principalName }); - Map sessions = new HashMap( - results.size()); + Map sessions = new HashMap(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.get(johnBlumSession.getId())).isEqualTo(johnBlumSession); + assertThat(johnBlumSession.getAttribute("vip")).isEqualTo("yes"); + assertThat(this.get(robWinchSession.getId())).isEqualTo(robWinchSession); + assertThat(robWinchSession.getAttribute("vip")).isEqualTo("yes"); + assertThat(this.get(jonDoeSession.getId())).isEqualTo(jonDoeSession); + assertThat(jonDoeSession.getAttribute("vip")).isEqualTo("no"); + assertThat(this.get(pieDoeSession.getId())).isEqualTo(pieDoeSession); assertThat(pieDoeSession.getAttributeNames().contains("vip")).isFalse(); - assertThat(get(sourDoeSession.getId())).isEqualTo(sourDoeSession); + assertThat(this.get(sourDoeSession.getId())).isEqualTo(sourDoeSession); assertThat(sourDoeSession.getAttributeNames().contains("vip")).isFalse(); - Map vipSessions = doFindByIndexNameAndIndexValue("vip", - "yes"); + Map 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.get(sessionOne.getId())).isEqualTo(sessionOne); + assertThat(this.get(sessionTwo.getId())).isEqualTo(sessionTwo); + assertThat(this.get(sessionThree.getId())).isEqualTo(sessionThree); + assertThat(this.get(sessionFour.getId())).isEqualTo(sessionFour); + assertThat(this.get(sessionFive.getId())).isEqualTo(sessionFive); Map 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 findByPrincipalName = doFindByPrincipalName( - getSecurityName()); + Map 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 findByPrincipalName = doFindByPrincipalName( - getSecurityName()); + Map findByPrincipalName = doFindByPrincipalName(getSecurityName()); + assertThat(findByPrincipalName).isEmpty(); findByPrincipalName = doFindByPrincipalName(getChangedSecurityName()); + assertThat(findByPrincipalName).hasSize(1); } @Test public void findsNoSessionsByNonExistingPrincipal() { - Map nonExistingPrincipalSessions = doFindByPrincipalName( - "nonExistingPrincipalName"); + Map 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 nonExistingPrincipalSessions = doFindByPrincipalName( - username); + Map 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 expectedAttributeNames = Arrays.asList("booleanAttribute", - "numericAttribute", "stringAttribute", "personAttribute"); + List 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.getAttribute(expectedAttributeNames.get(0))).isTrue(); + assertThat(savedSession.getAttribute(expectedAttributeNames.get(1))).isEqualTo(Math.PI); + assertThat(savedSession.getAttribute(expectedAttributeNames.get(2))).isEqualTo("test"); + assertThat(savedSession.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; } diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationTests.java b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationTests.java index c5731cd5..91204e6c 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationTests.java @@ -172,7 +172,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT assertThat(sessionEvent).isInstanceOf(SessionCreatedEvent.class); assertThat(sessionEvent.getSession()).isEqualTo(expectedSession); - assertThat(this.sessionEventListener.getSessionEvent()).isNull(); + assertThat(this.sessionEventListener.getSessionEvent()).isNull(); ExpiringSession savedSession = this.gemfireSessionRepository.getSession(expectedSession.getId()); diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/config/annotation/web/http/EnableGemFireHttpSessionEventsIntegrationTests.java b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/config/annotation/web/http/EnableGemFireHttpSessionEventsIntegrationTests.java index 07c2a84a..ecc67880 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/config/annotation/web/http/EnableGemFireHttpSessionEventsIntegrationTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/config/annotation/web/http/EnableGemFireHttpSessionEventsIntegrationTests.java @@ -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 sessionRegion = this.gemfireCache - .getRegion(SPRING_SESSION_GEMFIRE_REGION_NAME); + Region 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.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(expiredSession.getId()); - assertThat(this.gemfireSessionRepository.getSession(sessionEvent.getSessionId())) - .isNull(); + assertThat(this.gemfireSessionRepository.getSession(sessionEvent.getSessionId())).isNull(); } @Test public void deleteNonExistingSession() { String expectedSessionId = UUID.randomUUID().toString(); - assertThat(this.gemfireSessionRepository.getSession(expectedSessionId)).isNull(); + assertThat(this.gemfireSessionRepository.getSession(expectedSessionId)).isNull(); this.gemfireSessionRepository.delete(expectedSessionId); AbstractSessionEvent sessionEvent = this.sessionEventListener.getSessionEvent(); assertThat(sessionEvent).isInstanceOf(SessionDeletedEvent.class); - assertThat(sessionEvent.getSession()).isNull(); + assertThat(sessionEvent.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSessionId); } diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/mongo/AbstractMongoRepositoryITests.java b/spring-session/src/integration-test/java/org/springframework/session/data/mongo/AbstractMongoRepositoryITests.java index 50bca1fe..31be3ff5 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/mongo/AbstractMongoRepositoryITests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/mongo/AbstractMongoRepositoryITests.java @@ -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.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.getAttribute("a")).isEqualTo("b"); + assertThat(session.getAttribute("1")).isEqualTo("2"); this.repository.delete(toSave.getId()); } diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryITests.java b/spring-session/src/integration-test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryITests.java index 0b8a5897..0b1e24a4 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryITests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryITests.java @@ -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.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.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.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); + .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.getAttribute("a")).isEqualTo("b"); + assertThat(session.getAttribute("1")).isEqualTo("2"); this.repository.delete(toSave.getId()); } diff --git a/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSessionEventsTests.java b/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSessionEventsTests.java index 53b07533..d42e43b6 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSessionEventsTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/hazelcast/config/annotation/web/http/EnableHazelcastHttpSessionEventsTests.java @@ -89,7 +89,7 @@ public class EnableHazelcastHttpSessionEventsTests { this.repository.save(sessionToSave); assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue(); - assertThat(this.registry.getEvent(sessionToSave.getId())) + assertThat(this.registry.getEvent(sessionToSave.getId())) .isInstanceOf(SessionCreatedEvent.class); Session session = this.repository.getSession(sessionToSave.getId()); @@ -97,7 +97,7 @@ public class EnableHazelcastHttpSessionEventsTests { assertThat(session.getId()).isEqualTo(sessionToSave.getId()); assertThat(session.getAttributeNames()) .isEqualTo(sessionToSave.getAttributeNames()); - assertThat(session.getAttribute(expectedAttributeName)) + assertThat(session.getAttribute(expectedAttributeName)) .isEqualTo(sessionToSave.getAttribute(expectedAttributeName)); } @@ -108,7 +108,7 @@ public class EnableHazelcastHttpSessionEventsTests { this.repository.save(sessionToSave); assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue(); - assertThat(this.registry.getEvent(sessionToSave.getId())) + assertThat(this.registry.getEvent(sessionToSave.getId())) .isInstanceOf(SessionCreatedEvent.class); this.registry.clear(); @@ -116,10 +116,10 @@ public class EnableHazelcastHttpSessionEventsTests { .isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue(); - assertThat(this.registry.getEvent(sessionToSave.getId())) + assertThat(this.registry.getEvent(sessionToSave.getId())) .isInstanceOf(SessionExpiredEvent.class); - assertThat(this.repository.getSession(sessionToSave.getId())).isNull(); + assertThat(this.repository.getSession(sessionToSave.getId())).isNull(); } @Test @@ -129,14 +129,14 @@ public class EnableHazelcastHttpSessionEventsTests { this.repository.save(sessionToSave); assertThat(this.registry.receivedEvent(sessionToSave.getId())).isTrue(); - assertThat(this.registry.getEvent(sessionToSave.getId())) + assertThat(this.registry.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.getEvent(sessionToSave.getId())) .isInstanceOf(SessionDeletedEvent.class); assertThat(this.repository.getSession(sessionToSave.getId())).isNull(); diff --git a/spring-session/src/integration-test/java/org/springframework/session/jdbc/AbstractJdbcOperationsSessionRepositoryITests.java b/spring-session/src/integration-test/java/org/springframework/session/jdbc/AbstractJdbcOperationsSessionRepositoryITests.java index 851e3297..c049e80b 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/jdbc/AbstractJdbcOperationsSessionRepositoryITests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/jdbc/AbstractJdbcOperationsSessionRepositoryITests.java @@ -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.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.getAttribute("a")).isEqualTo("b"); + assertThat(session.getAttribute("1")).isEqualTo("2"); this.repository.delete(toSave.getId()); } @@ -576,5 +576,4 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests { } } - } diff --git a/spring-session/src/test/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepositoryTest.java b/spring-session/src/test/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepositoryTest.java index bae193a0..42b226a3 100644 --- a/spring-session/src/test/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepositoryTest.java +++ b/spring-session/src/test/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepositoryTest.java @@ -242,7 +242,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest { assertThat(sessionEvent.getSource()) .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); - assertThat(sessionEvent.getSession()).isEqualTo(mockSession); + assertThat(sessionEvent.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.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.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.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.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.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.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.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.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.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.getAttribute("attrOne")).isEqualTo("testOne"); + assertThat(gemfireSession.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.getAttribute("attrOne")).isEqualTo("testOne"); + assertThat(session.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.getAttribute("attrOne")).isEqualTo("testOne"); + assertThat(session.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.getAttribute("attrOne")).isEqualTo("testOne"); + assertThat(session.getAttribute("attrTwo")).isNull(); session.removeAttribute("attrOne"); - assertThat(session.getAttribute("attrOne")).isNull(); - assertThat(session.getAttribute("attrTwo")).isNull(); + assertThat(session.getAttribute("attrOne")).isNull(); + assertThat(session.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.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.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.getAttribute("attrOne")).isEqualTo("testOne"); + assertThat(session.getAttribute("attrTwo")).isEqualTo("testTwo"); + assertThat(session.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.getAttribute("attrOne")).isEqualTo("testOne"); + assertThat(sessionAttributes.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.getAttribute("attrOne")).isEqualTo("testOne"); + assertThat(target.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.getAttribute("attrOne")).isEqualTo("testOne"); + assertThat(sessionAttributes.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.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.getAttribute("attrOne")).isEqualTo("one"); + assertThat(sessionAttributes.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.getAttribute("attrOne")).isEqualTo("testOne"); + assertThat(sessionAttributes.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.getAttribute("attrOne")).isEqualTo("one"); + assertThat(sessionAttributes.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.getAttribute("attrOne")).isEqualTo("one"); + assertThat(sessionAttributes.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.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.getAttribute("junk")).isNull(); + assertThat(this.session.getAttribute("tennis")).isEqualTo("pong"); + assertThat(this.session.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.getAttribute("junk")).isEqualTo("test"); + assertThat(this.session.getAttribute("tennis")).isEqualTo("ping"); this.session.setAttribute("tennis", "pong"); this.session.setAttribute("greeting", "hello"); diff --git a/spring-session/src/test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryTest.java b/spring-session/src/test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryTest.java index b2101830..86fc2860 100644 --- a/spring-session/src/test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryTest.java +++ b/spring-session/src/test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryTest.java @@ -262,7 +262,7 @@ public class GemFireOperationsSessionRepositoryTest { assertThat(sessionEvent.getSource()) .isSameAs(GemFireOperationsSessionRepositoryTest.this.sessionRepository); - assertThat(sessionEvent.getSession()).isSameAs(mockSession); + assertThat(sessionEvent.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.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.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.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSessionId); return null; diff --git a/spring-session/src/test/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfigurationTest.java b/spring-session/src/test/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfigurationTest.java index 3d9c04d5..40c3e84b 100644 --- a/spring-session/src/test/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfigurationTest.java +++ b/spring-session/src/test/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfigurationTest.java @@ -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.getField(sessionRegionFactoryBean, "clientRegionShortcut")) + .isEqualTo(ClientRegionShortcut.CACHING_PROXY); + assertThat(this.getField(sessionRegionFactoryBean, "gemfireCache")) + .isEqualTo(mockGemFireCache); + assertThat(this.getField(sessionRegionFactoryBean, "poolName")).isEqualTo("TestPool"); + assertThat(this.>getField(sessionRegionFactoryBean, + "regionAttributes")).isEqualTo(mockRegionAttributes); + assertThat(this.getField(sessionRegionFactoryBean, "regionName")).isEqualTo("TestRegion"); + assertThat(this.getField(sessionRegionFactoryBean, "serverRegionShortcut")) + .isEqualTo(RegionShortcut.REPLICATE_PERSISTENT); verifyZeroInteractions(mockGemFireCache); verifyZeroInteractions(mockRegionAttributes); diff --git a/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java b/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java index 65b2e98f..bf319231 100644 --- a/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java +++ b/spring-session/src/test/java/org/springframework/session/data/redis/RedisOperationsSessionRepositoryTests.java @@ -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.getAttribute(attrName)) .isEqualTo(expected.getAttribute(attrName)); assertThat(session.getCreationTime()).isEqualTo(expected.getCreationTime()); assertThat(session.getMaxInactiveIntervalInSeconds()) diff --git a/spring-session/src/test/java/org/springframework/session/hazelcast/HazelcastSessionRepositoryTests.java b/spring-session/src/test/java/org/springframework/session/hazelcast/HazelcastSessionRepositoryTests.java index c76ad713..a0ae300e 100644 --- a/spring-session/src/test/java/org/springframework/session/hazelcast/HazelcastSessionRepositoryTests.java +++ b/spring-session/src/test/java/org/springframework/session/hazelcast/HazelcastSessionRepositoryTests.java @@ -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.getAttribute("savedName")).isEqualTo("savedValue"); verify(this.sessions, times(1)).get(eq(saved.getId())); } diff --git a/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java b/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java index 9cd87eb3..886701f6 100644 --- a/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java +++ b/spring-session/src/test/java/org/springframework/session/jdbc/JdbcOperationsSessionRepositoryTests.java @@ -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.getAttribute("savedName")).isEqualTo("savedValue"); assertPropagationRequiresNew(); verify(this.jdbcOperations, times(1)).query(isA(String.class), isA(PreparedStatementSetter.class), isA(ResultSetExtractor.class)); diff --git a/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java b/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java index 896551b9..721f5e74 100644 --- a/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java +++ b/spring-session/src/test/java/org/springframework/session/security/SpringSessionBackedSessionRegistryTest.java @@ -121,7 +121,8 @@ public class SpringSessionBackedSessionRegistryTest { assertThat(sessionInfo.isExpired()).isTrue(); ArgumentCaptor captor = ArgumentCaptor.forClass(ExpiringSession.class); verify(this.sessionRepository).save(captor.capture()); - assertThat(captor.getValue().getAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR)).isEqualTo(Boolean.TRUE); + assertThat(captor.getValue().getAttribute(SpringSessionBackedSessionInformation.EXPIRED_ATTR)) + .isEqualTo(Boolean.TRUE); } private ExpiringSession createSession(String sessionId, String userName, Long lastAccessed) {