Skip to content

Commit b7209f8

Browse files
committed
Make Hazelcast tests independent of ordering
Closes gh-1787
1 parent 645e525 commit b7209f8

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

spring-session-hazelcast/hazelcast4/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcast4IndexedSessionRepositoryITests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2020 the original author or authors.
2+
* Copyright 2014-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,16 +54,13 @@ void createAndDestroySession() {
5454
IMap<String, MapSession> hazelcastMap = this.hazelcastInstance
5555
.getMap(Hazelcast4IndexedSessionRepository.DEFAULT_SESSION_MAP_NAME);
5656

57-
assertThat(hazelcastMap.size()).isEqualTo(0);
58-
5957
this.repository.save(sessionToSave);
6058

61-
assertThat(hazelcastMap.size()).isEqualTo(1);
6259
assertThat(hazelcastMap.get(sessionId)).isEqualTo(sessionToSave);
6360

6461
this.repository.deleteById(sessionId);
6562

66-
assertThat(hazelcastMap.size()).isEqualTo(0);
63+
assertThat(hazelcastMap.get(sessionId)).isNull();
6764
}
6865

6966
@Test
@@ -179,6 +176,8 @@ void createAndUpdateSession() {
179176
this.repository.save(session);
180177

181178
assertThat(this.repository.findById(sessionId)).isNotNull();
179+
180+
this.repository.deleteById(sessionId);
182181
}
183182

184183
@Test
@@ -195,6 +194,8 @@ void createSessionWithSecurityContextAndFindById() {
195194
this.repository.save(session);
196195

197196
assertThat(this.repository.findById(sessionId)).isNotNull();
197+
198+
this.repository.deleteById(sessionId);
198199
}
199200

200201
}

spring-session-hazelcast/src/integration-test/java/org/springframework/session/hazelcast/AbstractHazelcastIndexedSessionRepositoryITests.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -58,16 +58,13 @@ void createAndDestroySession() {
5858
IMap<String, MapSession> hazelcastMap = this.hazelcastInstance
5959
.getMap(HazelcastIndexedSessionRepository.DEFAULT_SESSION_MAP_NAME);
6060

61-
assertThat(hazelcastMap.size()).isEqualTo(0);
62-
6361
this.repository.save(sessionToSave);
6462

65-
assertThat(hazelcastMap.size()).isEqualTo(1);
6663
assertThat(hazelcastMap.get(sessionId)).isEqualTo(sessionToSave);
6764

6865
this.repository.deleteById(sessionId);
6966

70-
assertThat(hazelcastMap.size()).isEqualTo(0);
67+
assertThat(hazelcastMap.get(sessionId)).isNull();
7168
}
7269

7370
@Test
@@ -183,6 +180,8 @@ void createAndUpdateSession() {
183180
this.repository.save(session);
184181

185182
assertThat(this.repository.findById(sessionId)).isNotNull();
183+
184+
this.repository.deleteById(sessionId);
186185
}
187186

188187
@Test
@@ -199,6 +198,8 @@ void createSessionWithSecurityContextAndFindById() {
199198
this.repository.save(session);
200199

201200
assertThat(this.repository.findById(sessionId)).isNotNull();
201+
202+
this.repository.deleteById(sessionId);
202203
}
203204

204205
@Test
@@ -220,6 +221,8 @@ void createSessionWithSecurityContextAndFindByPrincipal() {
220221
assertThat(this.repository
221222
.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, username))
222223
.hasSize(1);
224+
225+
this.repository.deleteById(session.getId());
223226
}
224227

225228
}

0 commit comments

Comments
 (0)