Search in sources :

Example 61 with RedisConnectionFactory

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);
}
Also used : RedisOperations(org.springframework.data.redis.core.RedisOperations) RedisOperationsSessionRepository(org.springframework.session.data.redis.RedisOperationsSessionRepository) SpringSessionRedisConnectionFactory(org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Test(org.junit.Test)

Example 62 with 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);
}
Also used : RedisOperations(org.springframework.data.redis.core.RedisOperations) RedisOperationsSessionRepository(org.springframework.session.data.redis.RedisOperationsSessionRepository) SpringSessionRedisConnectionFactory(org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Test(org.junit.Test)

Example 63 with 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;
}
Also used : Properties(java.util.Properties) SpringSessionRedisConnectionFactory(org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) RedisConnection(org.springframework.data.redis.connection.RedisConnection)

Example 64 with RedisConnectionFactory

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;
}
Also used : SpringSessionRedisConnectionFactory(org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Autowired(org.springframework.beans.factory.annotation.Autowired)

Example 65 with RedisConnectionFactory

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);
}
Also used : RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) RedisAvailable(org.springframework.integration.redis.rules.RedisAvailable) 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