use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.
the class HazelcastSessionRepositoryTests method findByIndexNameAndIndexValueUnknownIndexName.
@Test
public void findByIndexNameAndIndexValueUnknownIndexName() {
verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());
String indexValue = "testIndexValue";
Map<String, HazelcastSession> sessions = this.repository.findByIndexNameAndIndexValue("testIndexName", indexValue);
assertThat(sessions).isEmpty();
verifyZeroInteractions(this.sessions);
}
use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.
the class HazelcastSessionRepositoryTests method saveNewFlushModeImmediate.
@Test
public void saveNewFlushModeImmediate() {
verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());
this.repository.setHazelcastFlushMode(HazelcastFlushMode.IMMEDIATE);
HazelcastSession session = this.repository.createSession();
verify(this.sessions, times(1)).set(eq(session.getId()), eq(session.getDelegate()), isA(Long.class), eq(TimeUnit.SECONDS));
verifyZeroInteractions(this.sessions);
}
use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.
the class AbstractHazelcastRepositoryITests method changeSessionIdWhenChangeTwice.
@Test
public void changeSessionIdWhenChangeTwice() throws Exception {
HazelcastSession toSave = this.repository.createSession();
this.repository.save(toSave);
String originalId = toSave.getId();
String changeId1 = toSave.changeSessionId();
String changeId2 = toSave.changeSessionId();
this.repository.save(toSave);
assertThat(this.repository.findById(originalId)).isNull();
assertThat(this.repository.findById(changeId1)).isNull();
assertThat(this.repository.findById(changeId2)).isNotNull();
this.repository.deleteById(changeId2);
}
use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.
the class AbstractHazelcastRepositoryITests method createAndDestroySession.
@Test
public void createAndDestroySession() {
HazelcastSession sessionToSave = this.repository.createSession();
String sessionId = sessionToSave.getId();
IMap<String, MapSession> hazelcastMap = this.hazelcast.getMap(HazelcastSessionRepository.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);
}
use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.
the class AbstractHazelcastRepositoryITests method changeSessionIdWhenSetAttributeOnChangedSession.
@Test
public void changeSessionIdWhenSetAttributeOnChangedSession() throws Exception {
String attrName = "changeSessionId";
String attrValue = "changeSessionId-value";
HazelcastSession toSave = this.repository.createSession();
this.repository.save(toSave);
HazelcastSession findById = this.repository.findById(toSave.getId());
findById.setAttribute(attrName, attrValue);
String originalFindById = findById.getId();
String changeSessionId = findById.changeSessionId();
this.repository.save(findById);
assertThat(this.repository.findById(originalFindById)).isNull();
HazelcastSession findByChangeSessionId = this.repository.findById(changeSessionId);
assertThat(findByChangeSessionId.<String>getAttribute(attrName)).isEqualTo(attrValue);
this.repository.deleteById(changeSessionId);
}
Aggregations