Search in sources :

Example 1 with ReactiveRedisOperationsSessionRepository

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

the class IndexDocTests method newReactiveRedisOperationsSessionRepository.

@Test
@SuppressWarnings("unused")
public void newReactiveRedisOperationsSessionRepository() {
    LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory();
    RedisSerializationContext<String, Object> serializationContext = RedisSerializationContext.<String, Object>newSerializationContext(new JdkSerializationRedisSerializer()).build();
    // tag::new-reactiveredisoperationssessionrepository[]
    // ... create and configure connectionFactory and serializationContext ...
    ReactiveRedisTemplate<String, Object> redisTemplate = new ReactiveRedisTemplate<>(connectionFactory, serializationContext);
    ReactiveSessionRepository<? extends Session> repository = new ReactiveRedisOperationsSessionRepository(redisTemplate);
// end::new-reactiveredisoperationssessionrepository[]
}
Also used : ReactiveRedisTemplate(org.springframework.data.redis.core.ReactiveRedisTemplate) JdkSerializationRedisSerializer(org.springframework.data.redis.serializer.JdkSerializationRedisSerializer) LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) ReactiveRedisOperationsSessionRepository(org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository) Test(org.junit.Test)

Example 2 with ReactiveRedisOperationsSessionRepository

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

the class RedisWebSessionConfigurationTests method qualifiedAndPrimaryConnectionFactoryRedisConfig.

@Test
public void qualifiedAndPrimaryConnectionFactoryRedisConfig() {
    registerAndRefresh(RedisConfig.class, QualifiedAndPrimaryConnectionFactoryRedisConfig.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 3 with ReactiveRedisOperationsSessionRepository

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

the class RedisWebSessionConfigurationTests method defaultConfiguration.

@Test
public void defaultConfiguration() {
    registerAndRefresh(RedisConfig.class, DefaultConfig.class);
    ReactiveRedisOperationsSessionRepository repository = this.context.getBean(ReactiveRedisOperationsSessionRepository.class);
    assertThat(repository).isNotNull();
}
Also used : ReactiveRedisOperationsSessionRepository(org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository) Test(org.junit.Test)

Example 4 with ReactiveRedisOperationsSessionRepository

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

the class RedisWebSessionConfigurationTests method namedConnectionFactoryRedisConfig.

@Test
public void namedConnectionFactoryRedisConfig() {
    registerAndRefresh(RedisConfig.class, NamedConnectionFactoryRedisConfig.class);
    ReactiveRedisOperationsSessionRepository repository = this.context.getBean(ReactiveRedisOperationsSessionRepository.class);
    ReactiveRedisConnectionFactory redisConnectionFactory = this.context.getBean("redisConnectionFactory", 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 5 with ReactiveRedisOperationsSessionRepository

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

the class RedisWebSessionConfigurationTests method customFlushMode.

@Test
public void customFlushMode() {
    registerAndRefresh(RedisConfig.class, CustomFlushModeConfig.class);
    ReactiveRedisOperationsSessionRepository repository = this.context.getBean(ReactiveRedisOperationsSessionRepository.class);
    assertThat(repository).isNotNull();
    assertThat(ReflectionTestUtils.getField(repository, "redisFlushMode")).isEqualTo(RedisFlushMode.IMMEDIATE);
}
Also used : ReactiveRedisOperationsSessionRepository(org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository) 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