Search in sources :

Example 21 with HazelcastSession

use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.

the class HazelcastSessionRepositoryTests method removeAttributeFlushModeOnSave.

@Test
public void removeAttributeFlushModeOnSave() {
    verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());
    HazelcastSession session = this.repository.createSession();
    session.removeAttribute("testName");
    verifyZeroInteractions(this.sessions);
    this.repository.save(session);
    verify(this.sessions, times(1)).set(eq(session.getId()), eq(session.getDelegate()), isA(Long.class), eq(TimeUnit.SECONDS));
    verifyZeroInteractions(this.sessions);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) HazelcastSession(org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession) Test(org.junit.Test)

Example 22 with HazelcastSession

use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.

the class HazelcastSessionRepositoryTests method saveUnchangedFlushModeImmediate.

@Test
public void saveUnchangedFlushModeImmediate() {
    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));
    this.repository.save(session);
    verifyZeroInteractions(this.sessions);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) HazelcastSession(org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession) Test(org.junit.Test)

Example 23 with HazelcastSession

use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.

the class HazelcastSessionRepositoryTests method saveUpdatedLastAccessedTimeFlushModeOnSave.

@Test
public void saveUpdatedLastAccessedTimeFlushModeOnSave() {
    verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());
    HazelcastSession session = this.repository.createSession();
    session.setLastAccessedTime(Instant.now());
    verifyZeroInteractions(this.sessions);
    this.repository.save(session);
    verify(this.sessions, times(1)).set(eq(session.getId()), eq(session.getDelegate()), isA(Long.class), eq(TimeUnit.SECONDS));
    verifyZeroInteractions(this.sessions);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) HazelcastSession(org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession) Test(org.junit.Test)

Example 24 with HazelcastSession

use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.

the class HazelcastSessionRepositoryTests method saveUpdatedAttributeFlushModeOnSave.

@Test
public void saveUpdatedAttributeFlushModeOnSave() {
    verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());
    HazelcastSession session = this.repository.createSession();
    session.setAttribute("testName", "testValue");
    verifyZeroInteractions(this.sessions);
    this.repository.save(session);
    verify(this.sessions, times(1)).set(eq(session.getId()), eq(session.getDelegate()), isA(Long.class), eq(TimeUnit.SECONDS));
    verifyZeroInteractions(this.sessions);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) HazelcastSession(org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession) Test(org.junit.Test)

Example 25 with HazelcastSession

use of org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession in project spring-session by spring-projects.

the class HazelcastSessionRepositoryTests method saveUnchangedFlushModeOnSave.

@Test
public void saveUnchangedFlushModeOnSave() {
    verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());
    HazelcastSession session = this.repository.createSession();
    this.repository.save(session);
    verify(this.sessions, times(1)).set(eq(session.getId()), eq(session.getDelegate()), isA(Long.class), eq(TimeUnit.SECONDS));
    this.repository.save(session);
    verifyZeroInteractions(this.sessions);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) HazelcastSession(org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)25 HazelcastSession (org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession)25 MapListener (com.hazelcast.map.listener.MapListener)20 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 MapSession (org.springframework.session.MapSession)5 EntryProcessor (com.hazelcast.map.EntryProcessor)4 EqualPredicate (com.hazelcast.query.impl.predicates.EqualPredicate)2 ArrayList (java.util.ArrayList)1 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)1 Authentication (org.springframework.security.core.Authentication)1