Search in sources :

Example 46 with MapSession

use of org.springframework.session.MapSession in project spring-session by spring-projects.

the class SpringSessionBackedSessionRegistryTest method createSession.

private Session createSession(String sessionId, String userName, Instant lastAccessed) {
    MapSession session = new MapSession(sessionId);
    session.setLastAccessedTime(lastAccessed);
    Authentication authentication = mock(Authentication.class);
    when(authentication.getName()).thenReturn(userName);
    SecurityContextImpl securityContext = new SecurityContextImpl();
    securityContext.setAuthentication(authentication);
    session.setAttribute("SPRING_SECURITY_CONTEXT", securityContext);
    return session;
}
Also used : SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) Authentication(org.springframework.security.core.Authentication) MapSession(org.springframework.session.MapSession)

Example 47 with MapSession

use of org.springframework.session.MapSession in project spring-session by spring-projects.

the class CookieHttpSessionIdResolverTests method setup.

@Before
public void setup() throws Exception {
    this.cookieName = "SESSION";
    this.session = new MapSession();
    this.request = new MockHttpServletRequest();
    this.response = new MockHttpServletResponse();
    this.strategy = new CookieHttpSessionIdResolver();
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MapSession(org.springframework.session.MapSession) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Before(org.junit.Before)

Aggregations

MapSession (org.springframework.session.MapSession)47 Test (org.junit.Test)37 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)16 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 RedisSession (org.springframework.session.data.redis.RedisOperationsSessionRepository.RedisSession)7 HashMap (java.util.HashMap)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)6 MapSessionRepository (org.springframework.session.MapSessionRepository)6 IOException (java.io.IOException)5 Before (org.junit.Before)5 Session (org.springframework.session.Session)5 HazelcastSession (org.springframework.session.hazelcast.HazelcastSessionRepository.HazelcastSession)5 MapListener (com.hazelcast.map.listener.MapListener)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 Map (java.util.Map)3 BatchPreparedStatementSetter (org.springframework.jdbc.core.BatchPreparedStatementSetter)3 PreparedStatementSetter (org.springframework.jdbc.core.PreparedStatementSetter)3 DefaultMessage (org.springframework.data.redis.connection.DefaultMessage)2