use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-session by spring-projects.
the class RedisHttpSessionConfigurationTests method qualifiedConnectionFactoryRedisConfig.
@Test
public void qualifiedConnectionFactoryRedisConfig() {
registerAndRefresh(RedisConfig.class, QualifiedConnectionFactoryRedisConfig.class);
RedisOperationsSessionRepository repository = this.context.getBean(RedisOperationsSessionRepository.class);
RedisConnectionFactory redisConnectionFactory = this.context.getBean("qualifiedRedisConnectionFactory", RedisConnectionFactory.class);
assertThat(repository).isNotNull();
assertThat(redisConnectionFactory).isNotNull();
RedisOperations redisOperations = (RedisOperations) ReflectionTestUtils.getField(repository, "sessionRedisOperations");
assertThat(redisOperations).isNotNull();
assertThat(ReflectionTestUtils.getField(redisOperations, "connectionFactory")).isEqualTo(redisConnectionFactory);
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-session by spring-projects.
the class RedisHttpSessionConfigurationTests method qualifiedAndPrimaryConnectionFactoryRedisConfig.
@Test
public void qualifiedAndPrimaryConnectionFactoryRedisConfig() {
registerAndRefresh(RedisConfig.class, QualifiedAndPrimaryConnectionFactoryRedisConfig.class);
RedisOperationsSessionRepository repository = this.context.getBean(RedisOperationsSessionRepository.class);
RedisConnectionFactory redisConnectionFactory = this.context.getBean("qualifiedRedisConnectionFactory", RedisConnectionFactory.class);
assertThat(repository).isNotNull();
assertThat(redisConnectionFactory).isNotNull();
RedisOperations redisOperations = (RedisOperations) ReflectionTestUtils.getField(repository, "sessionRedisOperations");
assertThat(redisOperations).isNotNull();
assertThat(ReflectionTestUtils.getField(redisOperations, "connectionFactory")).isEqualTo(redisConnectionFactory);
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-session by spring-projects.
the class RedisHttpSessionConfigurationTests method mockRedisConnectionFactory.
private static RedisConnectionFactory mockRedisConnectionFactory() {
RedisConnectionFactory connectionFactory = mock(RedisConnectionFactory.class);
RedisConnection connection = mock(RedisConnection.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.getConfig(anyString())).willReturn(new Properties());
return connectionFactory;
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-session by spring-projects.
the class RedisHttpSessionConfiguration method setRedisConnectionFactory.
@Autowired
public void setRedisConnectionFactory(@SpringSessionRedisConnectionFactory ObjectProvider<RedisConnectionFactory> springSessionRedisConnectionFactory, ObjectProvider<RedisConnectionFactory> redisConnectionFactory) {
RedisConnectionFactory redisConnectionFactoryToUse = springSessionRedisConnectionFactory.getIfAvailable();
if (redisConnectionFactoryToUse == null) {
redisConnectionFactoryToUse = redisConnectionFactory.getObject();
}
this.redisConnectionFactory = redisConnectionFactoryToUse;
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-integration by spring-projects.
the class RedisMetadataStoreTests method testGetNonExistingKeyValue.
@Test
@RedisAvailable
public void testGetNonExistingKeyValue() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
String retrievedValue = metadataStore.get("does-not-exist");
assertNull(retrievedValue);
}
Aggregations