Search in sources :

Example 91 with RedisConnectionFactory

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

the class RedisLockRegistryTests method testExpireNotChanged.

@Test
@RedisAvailable
public void testExpireNotChanged() throws Exception {
    RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest();
    final RedisLockRegistry registry = new RedisLockRegistry(connectionFactory, this.registryKey, 10000);
    Lock lock = registry.obtain("foo");
    lock.lock();
    Long expire = getExpire(registry, "foo");
    Future<Object> result = Executors.newSingleThreadExecutor().submit(() -> {
        Lock lock2 = registry.obtain("foo");
        assertFalse(lock2.tryLock());
        return null;
    });
    result.get();
    assertEquals(expire, getExpire(registry, "foo"));
    lock.unlock();
}
Also used : RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Lock(java.util.concurrent.locks.Lock) RedisAvailable(org.springframework.integration.redis.rules.RedisAvailable) Test(org.junit.Test)

Example 92 with RedisConnectionFactory

use of org.springframework.data.redis.connection.RedisConnectionFactory in project redisson by redisson.

the class RedissonClusterConnectionTest method testConnectionFactoryReturnsClusterConnection.

@Test
public void testConnectionFactoryReturnsClusterConnection() {
    RedisConnectionFactory connectionFactory = new RedissonConnectionFactory(redisson);
    assertThat(connectionFactory.getConnection()).isInstanceOf(RedissonClusterConnection.class);
}
Also used : RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Test(org.junit.Test)

Example 93 with RedisConnectionFactory

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

the class RedisServiceConnectorCreatorTest method cloudRedisCreationNoConfig.

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

Example 94 with RedisConnectionFactory

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

the class RedisConnectionFactoryXmlConfigTest method cloudRedisConnectionFactoryWithMinMaxPool.

@Test
public void cloudRedisConnectionFactoryWithMinMaxPool() {
    ApplicationContext testContext = getTestApplicationContext("cloud-redis-with-config.xml", createService("my-service"));
    RedisConnectionFactory connector = testContext.getBean("service-pool5-30-wait3000", getConnectorType());
    RedisConnectionFactoryCloudConfigTestHelper.assertPoolProperties(connector, 30, 5, 3000);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Test(org.junit.Test)

Example 95 with RedisConnectionFactory

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

the class RedisConnectionFactoryConfigWithServiceConfig method cloudRedisConnectionFactoryWithMinMaxPool.

@Test
public void cloudRedisConnectionFactoryWithMinMaxPool() {
    ApplicationContext testContext = getTestApplicationContext(RedisConnectionFactoryConfigWithServiceConfig.class, createService("my-service"));
    RedisConnectionFactory connector = testContext.getBean("pool5_30Wait3000", getConnectorType());
    RedisConnectionFactoryCloudConfigTestHelper.assertPoolProperties(connector, 30, 5, 3000);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) 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