Search in sources :

Example 1 with ReactiveRedisConnectionFactory

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

the class RedisWebSessionConfiguration method setRedisConnectionFactory.

@Autowired
public void setRedisConnectionFactory(@SpringSessionRedisConnectionFactory ObjectProvider<ReactiveRedisConnectionFactory> springSessionRedisConnectionFactory, ObjectProvider<ReactiveRedisConnectionFactory> redisConnectionFactory) {
    ReactiveRedisConnectionFactory redisConnectionFactoryToUse = springSessionRedisConnectionFactory.getIfAvailable();
    if (redisConnectionFactoryToUse == null) {
        redisConnectionFactoryToUse = redisConnectionFactory.getObject();
    }
    this.redisConnectionFactory = redisConnectionFactoryToUse;
}
Also used : ReactiveRedisConnectionFactory(org.springframework.data.redis.connection.ReactiveRedisConnectionFactory) Autowired(org.springframework.beans.factory.annotation.Autowired)

Example 2 with ReactiveRedisConnectionFactory

use of org.springframework.data.redis.connection.ReactiveRedisConnectionFactory 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 ReactiveRedisConnectionFactory

use of org.springframework.data.redis.connection.ReactiveRedisConnectionFactory 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 4 with ReactiveRedisConnectionFactory

use of org.springframework.data.redis.connection.ReactiveRedisConnectionFactory 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 5 with ReactiveRedisConnectionFactory

use of org.springframework.data.redis.connection.ReactiveRedisConnectionFactory 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

ReactiveRedisConnectionFactory (org.springframework.data.redis.connection.ReactiveRedisConnectionFactory)5 Test (org.junit.Test)4 ReactiveRedisOperations (org.springframework.data.redis.core.ReactiveRedisOperations)4 ReactiveRedisOperationsSessionRepository (org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository)4 Autowired (org.springframework.beans.factory.annotation.Autowired)1