use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-boot by spring-projects.
the class RedisHealthIndicatorTests method redisIsDown.
@Test
public void redisIsDown() throws Exception {
RedisConnection redisConnection = mock(RedisConnection.class);
RedisConnectionFactory redisConnectionFactory = mock(RedisConnectionFactory.class);
given(redisConnectionFactory.getConnection()).willReturn(redisConnection);
given(redisConnection.info()).willThrow(new RedisConnectionFailureException("Connection failed"));
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(((String) health.getDetails().get("error")).contains("Connection failed"));
verify(redisConnectionFactory).getConnection();
verify(redisConnection).info();
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project cas by apereo.
the class CasMetricsRepositoryConfiguration method redisMetricWriter.
@ConditionalOnProperty(prefix = "cas.metrics.redis", name = "prefix")
@Bean
@ExportMetricWriter
public MetricWriter redisMetricWriter() {
final MetricsProperties.Redis redis = casProperties.getMetrics().getRedis();
final RedisObjectFactory factory = new RedisObjectFactory();
final RedisConnectionFactory connectionFactory = factory.newRedisConnectionFactory(redis);
return new RedisMetricRepository(connectionFactory, redis.getPrefix(), redis.getKey());
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-session by spring-projects.
the class RedisHttpSessionConfigurationXmlCustomExpireTests method connectionFactory.
static RedisConnectionFactory connectionFactory() {
RedisConnectionFactory factory = mock(RedisConnectionFactory.class);
RedisConnection connection = mock(RedisConnection.class);
given(factory.getConnection()).willReturn(connection);
given(connection.getConfig(anyString())).willReturn(new Properties());
return factory;
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-session by spring-projects.
the class RedisHttpSessionConfigurationClassPathXmlApplicationContextTests method connectionFactory.
static RedisConnectionFactory connectionFactory() {
RedisConnectionFactory factory = mock(RedisConnectionFactory.class);
RedisConnection connection = mock(RedisConnection.class);
given(factory.getConnection()).willReturn(connection);
given(connection.getConfig(anyString())).willReturn(new Properties());
return factory;
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-session by spring-projects.
the class RedisHttpSessionConfigurationTests method namedConnectionFactoryRedisConfig.
@Test
public void namedConnectionFactoryRedisConfig() {
registerAndRefresh(RedisConfig.class, NamedConnectionFactoryRedisConfig.class);
RedisOperationsSessionRepository repository = this.context.getBean(RedisOperationsSessionRepository.class);
RedisConnectionFactory redisConnectionFactory = this.context.getBean("redisConnectionFactory", 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);
}
Aggregations