Search in sources :

Example 51 with RedisConnectionFactory

use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class SpringData1RedisServiceConnectorCreatorTest method cloudRedisCreationNoConfig.

@Test
public void cloudRedisCreationNoConfig() throws Exception {
    RedisServiceInfo serviceInfo = createServiceInfo();
    RedisConnectionFactory dataSource = testCreator.create(serviceInfo, null);
    assertConnectorProperties(serviceInfo, dataSource);
}
Also used : RedisServiceInfo(org.springframework.cloud.service.common.RedisServiceInfo) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Test(org.junit.Test)

Example 52 with RedisConnectionFactory

use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class RedisConnectionFactoryXmlConfigTest method cloudRedisConnectionFactoryWithMaxPoolAndTimeout.

@Test
public void cloudRedisConnectionFactoryWithMaxPoolAndTimeout() {
    ApplicationContext testContext = getTestApplicationContext("cloud-redis-with-config.xml", createService("my-service"));
    RedisConnectionFactory connector = testContext.getBean("service-pool30-wait300-timeout20", getConnectorType());
    RedisConnectionFactoryCloudConfigTestHelper.assertPoolProperties(connector, 30, 0, 300);
    RedisConnectionFactoryCloudConfigTestHelper.assertConnectionProperties(connector, 20);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Test(org.junit.Test)

Example 53 with RedisConnectionFactory

use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class RedisConnectionFactoryXmlConfigTest method cloudRedisConnectionFactoryWithTimeout.

@Test
public void cloudRedisConnectionFactoryWithTimeout() {
    ApplicationContext testContext = getTestApplicationContext("cloud-redis-with-config.xml", createService("my-service"));
    RedisConnectionFactory connector = testContext.getBean("service-timeout10", getConnectorType());
    RedisConnectionFactoryCloudConfigTestHelper.assertConnectionProperties(connector, 10);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Test(org.junit.Test)

Example 54 with RedisConnectionFactory

use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class RedisConnectionFactoryConfigWithServiceConfig method cloudRedisConnectionFactoryWithWithMaxPoolAndTimeout.

@Test
public void cloudRedisConnectionFactoryWithWithMaxPoolAndTimeout() {
    ApplicationContext testContext = getTestApplicationContext(RedisConnectionFactoryConfigWithServiceConfig.class, createService("my-service"));
    RedisConnectionFactory connector = testContext.getBean("pool30Wait300_timeout20", getConnectorType());
    RedisConnectionFactoryCloudConfigTestHelper.assertPoolProperties(connector, 30, 0, 300);
    RedisConnectionFactoryCloudConfigTestHelper.assertConnectionProperties(connector, 20);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Test(org.junit.Test)

Example 55 with RedisConnectionFactory

use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-boot by spring-projects.

the class RedisHealthIndicatorTests method redisClusterIsUp.

@Test
public void redisClusterIsUp() throws Exception {
    Properties clusterProperties = new Properties();
    clusterProperties.setProperty("cluster_size", "4");
    clusterProperties.setProperty("cluster_slots_ok", "4");
    clusterProperties.setProperty("cluster_slots_fail", "0");
    List<RedisClusterNode> redisMasterNodes = Arrays.asList(new RedisClusterNode("127.0.0.1", 7001), new RedisClusterNode("127.0.0.2", 7001));
    RedisClusterConnection redisConnection = mock(RedisClusterConnection.class);
    given(redisConnection.clusterGetNodes()).willReturn(redisMasterNodes);
    given(redisConnection.clusterGetClusterInfo()).willReturn(new ClusterInfo(clusterProperties));
    RedisConnectionFactory redisConnectionFactory = mock(RedisConnectionFactory.class);
    given(redisConnectionFactory.getConnection()).willReturn(redisConnection);
    RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory);
    Health health = healthIndicator.health();
    assertThat(health.getStatus()).isEqualTo(Status.UP);
    assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L);
    assertThat(health.getDetails().get("slots_up")).isEqualTo(4L);
    assertThat(health.getDetails().get("slots_fail")).isEqualTo(0L);
    verify(redisConnectionFactory, atLeastOnce()).getConnection();
}
Also used : RedisClusterConnection(org.springframework.data.redis.connection.RedisClusterConnection) ClusterInfo(org.springframework.data.redis.connection.ClusterInfo) RedisClusterNode(org.springframework.data.redis.connection.RedisClusterNode) Properties(java.util.Properties) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Test(org.junit.Test)

Aggregations

RedisConnectionFactory (org.springframework.data.redis.connection.RedisConnectionFactory)95 Test (org.junit.Test)83 RedisAvailable (org.springframework.integration.redis.rules.RedisAvailable)62 GenericMessage (org.springframework.messaging.support.GenericMessage)22 BeanFactory (org.springframework.beans.factory.BeanFactory)19 StringRedisTemplate (org.springframework.data.redis.core.StringRedisTemplate)17 MessageGroup (org.springframework.integration.store.MessageGroup)14 SimpleMessageGroup (org.springframework.integration.store.SimpleMessageGroup)13 ArrayList (java.util.ArrayList)12 Message (org.springframework.messaging.Message)10 Properties (java.util.Properties)9 ApplicationContext (org.springframework.context.ApplicationContext)9 List (java.util.List)8 DefaultRedisList (org.springframework.data.redis.support.collections.DefaultRedisList)8 RedisList (org.springframework.data.redis.support.collections.RedisList)8 RedisConnection (org.springframework.data.redis.connection.RedisConnection)7 DefaultRedisZSet (org.springframework.data.redis.support.collections.DefaultRedisZSet)7 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)6 TypedTuple (org.springframework.data.redis.core.ZSetOperations.TypedTuple)6 LiteralExpression (org.springframework.expression.common.LiteralExpression)6