Search in sources :

Example 6 with ReactiveRedisOperationsSessionRepository

use of org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository in project spring-session by spring-projects.

the class RedisWebSessionConfigurationTests method qualifiedConnectionFactoryRedisConfig.

@Test
public void qualifiedConnectionFactoryRedisConfig() {
    registerAndRefresh(RedisConfig.class, QualifiedConnectionFactoryRedisConfig.class);
    ReactiveRedisOperationsSessionRepository repository = this.context.getBean(ReactiveRedisOperationsSessionRepository.class);
    ReactiveRedisConnectionFactory redisConnectionFactory = this.context.getBean("qualifiedRedisConnectionFactory", ReactiveRedisConnectionFactory.class);
    assertThat(repository).isNotNull();
    assertThat(redisConnectionFactory).isNotNull();
    ReactiveRedisOperations redisOperations = (ReactiveRedisOperations) ReflectionTestUtils.getField(repository, "sessionRedisOperations");
    assertThat(redisOperations).isNotNull();
    assertThat(ReflectionTestUtils.getField(redisOperations, "connectionFactory")).isEqualTo(redisConnectionFactory);
}
Also used : ReactiveRedisOperationsSessionRepository(org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository) ReactiveRedisConnectionFactory(org.springframework.data.redis.connection.ReactiveRedisConnectionFactory) ReactiveRedisOperations(org.springframework.data.redis.core.ReactiveRedisOperations) Test(org.junit.Test)

Example 7 with ReactiveRedisOperationsSessionRepository

use of org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository in project spring-session by spring-projects.

the class RedisWebSessionConfiguration method sessionRepository.

@Bean
public ReactiveRedisOperationsSessionRepository sessionRepository() {
    ReactiveRedisTemplate<String, Object> reactiveRedisTemplate = createReactiveRedisTemplate();
    ReactiveRedisOperationsSessionRepository sessionRepository = new ReactiveRedisOperationsSessionRepository(reactiveRedisTemplate);
    sessionRepository.setDefaultMaxInactiveInterval(this.maxInactiveIntervalInSeconds);
    if (StringUtils.hasText(this.redisNamespace)) {
        sessionRepository.setRedisKeyNamespace(this.redisNamespace);
    }
    sessionRepository.setRedisFlushMode(this.redisFlushMode);
    return sessionRepository;
}
Also used : ReactiveRedisOperationsSessionRepository(org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository) Bean(org.springframework.context.annotation.Bean)

Example 8 with ReactiveRedisOperationsSessionRepository

use of org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository in project spring-session by spring-projects.

the class RedisWebSessionConfigurationTests method customNamespace.

@Test
public void customNamespace() {
    registerAndRefresh(RedisConfig.class, CustomNamespaceConfig.class);
    ReactiveRedisOperationsSessionRepository repository = this.context.getBean(ReactiveRedisOperationsSessionRepository.class);
    assertThat(repository).isNotNull();
    assertThat(ReflectionTestUtils.getField(repository, "namespace")).isEqualTo(REDIS_NAMESPACE + ":");
}
Also used : ReactiveRedisOperationsSessionRepository(org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository) Test(org.junit.Test)

Example 9 with ReactiveRedisOperationsSessionRepository

use of org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository in project spring-session by spring-projects.

the class RedisWebSessionConfigurationTests method customMaxInactiveInterval.

@Test
public void customMaxInactiveInterval() {
    registerAndRefresh(RedisConfig.class, CustomMaxInactiveIntervalConfig.class);
    ReactiveRedisOperationsSessionRepository repository = this.context.getBean(ReactiveRedisOperationsSessionRepository.class);
    assertThat(repository).isNotNull();
    assertThat(ReflectionTestUtils.getField(repository, "defaultMaxInactiveInterval")).isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
}
Also used : ReactiveRedisOperationsSessionRepository(org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository) Test(org.junit.Test)

Example 10 with ReactiveRedisOperationsSessionRepository

use of org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository in project spring-session by spring-projects.

the class RedisWebSessionConfigurationTests method primaryConnectionFactoryRedisConfig.

@Test
public void primaryConnectionFactoryRedisConfig() {
    registerAndRefresh(RedisConfig.class, PrimaryConnectionFactoryRedisConfig.class);
    ReactiveRedisOperationsSessionRepository repository = this.context.getBean(ReactiveRedisOperationsSessionRepository.class);
    ReactiveRedisConnectionFactory redisConnectionFactory = this.context.getBean("primaryRedisConnectionFactory", ReactiveRedisConnectionFactory.class);
    assertThat(repository).isNotNull();
    assertThat(redisConnectionFactory).isNotNull();
    ReactiveRedisOperations redisOperations = (ReactiveRedisOperations) ReflectionTestUtils.getField(repository, "sessionRedisOperations");
    assertThat(redisOperations).isNotNull();
    assertThat(ReflectionTestUtils.getField(redisOperations, "connectionFactory")).isEqualTo(redisConnectionFactory);
}
Also used : ReactiveRedisOperationsSessionRepository(org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository) ReactiveRedisConnectionFactory(org.springframework.data.redis.connection.ReactiveRedisConnectionFactory) ReactiveRedisOperations(org.springframework.data.redis.core.ReactiveRedisOperations) Test(org.junit.Test)

Aggregations

ReactiveRedisOperationsSessionRepository (org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository)10 Test (org.junit.Test)9 ReactiveRedisConnectionFactory (org.springframework.data.redis.connection.ReactiveRedisConnectionFactory)4 ReactiveRedisOperations (org.springframework.data.redis.core.ReactiveRedisOperations)4 Bean (org.springframework.context.annotation.Bean)1 LettuceConnectionFactory (org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory)1 ReactiveRedisTemplate (org.springframework.data.redis.core.ReactiveRedisTemplate)1 JdkSerializationRedisSerializer (org.springframework.data.redis.serializer.JdkSerializationRedisSerializer)1