From 27044c8766a5edb2da91b5360844d47ce033cfea Mon Sep 17 00:00:00 2001 From: Eleftheria Stein Date: Tue, 2 Feb 2021 13:24:24 +0100 Subject: [PATCH] Make Hazelcast tests independent of ordering Closes gh-1787 --- ...actHazelcast4IndexedSessionRepositoryITests.java | 11 ++++++----- ...ractHazelcastIndexedSessionRepositoryITests.java | 13 ++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/spring-session-hazelcast/hazelcast4/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcast4IndexedSessionRepositoryITests.java b/spring-session-hazelcast/hazelcast4/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcast4IndexedSessionRepositoryITests.java index b633fe4e..482b0b38 100644 --- a/spring-session-hazelcast/hazelcast4/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcast4IndexedSessionRepositoryITests.java +++ b/spring-session-hazelcast/hazelcast4/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcast4IndexedSessionRepositoryITests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,16 +54,13 @@ abstract class AbstractHazelcast4IndexedSessionRepositoryITests { IMap hazelcastMap = this.hazelcastInstance .getMap(Hazelcast4IndexedSessionRepository.DEFAULT_SESSION_MAP_NAME); - assertThat(hazelcastMap.size()).isEqualTo(0); - this.repository.save(sessionToSave); - assertThat(hazelcastMap.size()).isEqualTo(1); assertThat(hazelcastMap.get(sessionId)).isEqualTo(sessionToSave); this.repository.deleteById(sessionId); - assertThat(hazelcastMap.size()).isEqualTo(0); + assertThat(hazelcastMap.get(sessionId)).isNull(); } @Test @@ -179,6 +176,8 @@ abstract class AbstractHazelcast4IndexedSessionRepositoryITests { this.repository.save(session); assertThat(this.repository.findById(sessionId)).isNotNull(); + + this.repository.deleteById(sessionId); } @Test @@ -195,6 +194,8 @@ abstract class AbstractHazelcast4IndexedSessionRepositoryITests { this.repository.save(session); assertThat(this.repository.findById(sessionId)).isNotNull(); + + this.repository.deleteById(sessionId); } } diff --git a/spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcastIndexedSessionRepositoryITests.java b/spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcastIndexedSessionRepositoryITests.java index fa258446..be313420 100644 --- a/spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcastIndexedSessionRepositoryITests.java +++ b/spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcastIndexedSessionRepositoryITests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,16 +58,13 @@ abstract class AbstractHazelcastIndexedSessionRepositoryITests { IMap hazelcastMap = this.hazelcastInstance .getMap(HazelcastIndexedSessionRepository.DEFAULT_SESSION_MAP_NAME); - assertThat(hazelcastMap.size()).isEqualTo(0); - this.repository.save(sessionToSave); - assertThat(hazelcastMap.size()).isEqualTo(1); assertThat(hazelcastMap.get(sessionId)).isEqualTo(sessionToSave); this.repository.deleteById(sessionId); - assertThat(hazelcastMap.size()).isEqualTo(0); + assertThat(hazelcastMap.get(sessionId)).isNull(); } @Test @@ -183,6 +180,8 @@ abstract class AbstractHazelcastIndexedSessionRepositoryITests { this.repository.save(session); assertThat(this.repository.findById(sessionId)).isNotNull(); + + this.repository.deleteById(sessionId); } @Test @@ -199,6 +198,8 @@ abstract class AbstractHazelcastIndexedSessionRepositoryITests { this.repository.save(session); assertThat(this.repository.findById(sessionId)).isNotNull(); + + this.repository.deleteById(sessionId); } @Test @@ -220,6 +221,8 @@ abstract class AbstractHazelcastIndexedSessionRepositoryITests { assertThat(this.repository .findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, username)) .hasSize(1); + + this.repository.deleteById(session.getId()); } }