org.springframework.data.redis.core.ReactiveRedisOperations Java Examples

The following examples show how to use org.springframework.data.redis.core.ReactiveRedisOperations. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 6 votes vote down vote up
@Test
void customRedisSerializerConfig() {
	registerAndRefresh(RedisConfig.class, CustomRedisSerializerConfig.class);

	ReactiveRedisSessionRepository repository = this.context.getBean(ReactiveRedisSessionRepository.class);
	@SuppressWarnings("unchecked")
	RedisSerializer<Object> redisSerializer = this.context.getBean("springSessionDefaultRedisSerializer",
			RedisSerializer.class);
	assertThat(repository).isNotNull();
	assertThat(redisSerializer).isNotNull();
	ReactiveRedisOperations redisOperations = (ReactiveRedisOperations) ReflectionTestUtils.getField(repository,
			"sessionRedisOperations");
	assertThat(redisOperations).isNotNull();
	RedisSerializationContext serializationContext = redisOperations.getSerializationContext();
	assertThat(ReflectionTestUtils.getField(serializationContext.getValueSerializationPair().getReader(),
			"serializer")).isEqualTo(redisSerializer);
	assertThat(ReflectionTestUtils.getField(serializationContext.getValueSerializationPair().getWriter(),
			"serializer")).isEqualTo(redisSerializer);
	assertThat(ReflectionTestUtils.getField(serializationContext.getHashValueSerializationPair().getReader(),
			"serializer")).isEqualTo(redisSerializer);
	assertThat(ReflectionTestUtils.getField(serializationContext.getHashValueSerializationPair().getWriter(),
			"serializer")).isEqualTo(redisSerializer);
}
 
Example #2
Source File: RedisWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void springSessionRedisOperationsResolvingConfiguration() {
	registerAndRefresh(RedisConfig.class, SpringSessionRedisOperationsResolvingConfig.class);

	ReactiveRedisSessionRepository repository = this.context.getBean(ReactiveRedisSessionRepository.class);
	assertThat(repository).isNotNull();
	ReactiveRedisOperations<String, Object> springSessionRedisOperations = this.context
			.getBean(SpringSessionRedisOperationsResolvingConfig.class).getSpringSessionRedisOperations();
	assertThat(springSessionRedisOperations).isNotNull();
	assertThat((ReactiveRedisOperations) ReflectionTestUtils.getField(repository, "sessionRedisOperations"))
			.isEqualTo(springSessionRedisOperations);
}
 
Example #3
Source File: RedisWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void qualifiedConnectionFactoryRedisConfig() {
	registerAndRefresh(RedisConfig.class, QualifiedConnectionFactoryRedisConfig.class);

	ReactiveRedisSessionRepository repository = this.context.getBean(ReactiveRedisSessionRepository.class);
	ReactiveRedisConnectionFactory redisConnectionFactory = this.context.getBean("qualifiedRedisConnectionFactory",
			ReactiveRedisConnectionFactory.class);
	assertThat(repository).isNotNull();
	assertThat(redisConnectionFactory).isNotNull();
	ReactiveRedisOperations redisOperations = (ReactiveRedisOperations) ReflectionTestUtils.getField(repository,
			"sessionRedisOperations");
	assertThat(redisOperations).isNotNull();
	assertThat(ReflectionTestUtils.getField(redisOperations, "connectionFactory"))
			.isEqualTo(redisConnectionFactory);
}
 
Example #4
Source File: RedisWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void primaryConnectionFactoryRedisConfig() {
	registerAndRefresh(RedisConfig.class, PrimaryConnectionFactoryRedisConfig.class);

	ReactiveRedisSessionRepository repository = this.context.getBean(ReactiveRedisSessionRepository.class);
	ReactiveRedisConnectionFactory redisConnectionFactory = this.context.getBean("primaryRedisConnectionFactory",
			ReactiveRedisConnectionFactory.class);
	assertThat(repository).isNotNull();
	assertThat(redisConnectionFactory).isNotNull();
	ReactiveRedisOperations redisOperations = (ReactiveRedisOperations) ReflectionTestUtils.getField(repository,
			"sessionRedisOperations");
	assertThat(redisOperations).isNotNull();
	assertThat(ReflectionTestUtils.getField(redisOperations, "connectionFactory"))
			.isEqualTo(redisConnectionFactory);
}
 
Example #5
Source File: RedisWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void qualifiedAndPrimaryConnectionFactoryRedisConfig() {
	registerAndRefresh(RedisConfig.class, QualifiedAndPrimaryConnectionFactoryRedisConfig.class);

	ReactiveRedisSessionRepository repository = this.context.getBean(ReactiveRedisSessionRepository.class);
	ReactiveRedisConnectionFactory redisConnectionFactory = this.context.getBean("qualifiedRedisConnectionFactory",
			ReactiveRedisConnectionFactory.class);
	assertThat(repository).isNotNull();
	assertThat(redisConnectionFactory).isNotNull();
	ReactiveRedisOperations redisOperations = (ReactiveRedisOperations) ReflectionTestUtils.getField(repository,
			"sessionRedisOperations");
	assertThat(redisOperations).isNotNull();
	assertThat(ReflectionTestUtils.getField(redisOperations, "connectionFactory"))
			.isEqualTo(redisConnectionFactory);
}
 
Example #6
Source File: RedisWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void namedConnectionFactoryRedisConfig() {
	registerAndRefresh(RedisConfig.class, NamedConnectionFactoryRedisConfig.class);

	ReactiveRedisSessionRepository repository = this.context.getBean(ReactiveRedisSessionRepository.class);
	ReactiveRedisConnectionFactory redisConnectionFactory = this.context.getBean("redisConnectionFactory",
			ReactiveRedisConnectionFactory.class);
	assertThat(repository).isNotNull();
	assertThat(redisConnectionFactory).isNotNull();
	ReactiveRedisOperations redisOperations = (ReactiveRedisOperations) ReflectionTestUtils.getField(repository,
			"sessionRedisOperations");
	assertThat(redisOperations).isNotNull();
	assertThat(ReflectionTestUtils.getField(redisOperations, "connectionFactory"))
			.isEqualTo(redisConnectionFactory);
}
 
Example #7
Source File: JetLinksConfiguration.java    From jetlinks-community with Apache License 2.0 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = "hsweb.user-token")
public UserTokenManager userTokenManager(ReactiveRedisOperations<Object,Object> template) {
    return new RedisUserTokenManager(template);
}
 
Example #8
Source File: DemoApplication.java    From spring-reactive-sample with GNU General Public License v3.0 4 votes vote down vote up
public PostRepository(ReactiveRedisOperations<String, Post> template) {
    this.template = template;
}
 
Example #9
Source File: RedisWebSessionConfigurationTests.java    From spring-session with Apache License 2.0 4 votes vote down vote up
ReactiveRedisOperations<String, Object> getSpringSessionRedisOperations() {
	return this.springSessionRedisOperations;
}
 
Example #10
Source File: ReactiveRedisSessionRepository.java    From spring-session with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new {@link ReactiveRedisSessionRepository} instance.
 * @param sessionRedisOperations the {@link ReactiveRedisOperations} to use for
 * managing sessions
 */
public ReactiveRedisSessionRepository(ReactiveRedisOperations<String, Object> sessionRedisOperations) {
	Assert.notNull(sessionRedisOperations, "sessionRedisOperations cannot be null");
	this.sessionRedisOperations = sessionRedisOperations;
}
 
Example #11
Source File: ReactiveRedisSessionRepository.java    From spring-session with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the {@link ReactiveRedisOperations} used for sessions.
 * @return the {@link ReactiveRedisOperations} used for sessions
 */
public ReactiveRedisOperations<String, Object> getSessionRedisOperations() {
	return this.sessionRedisOperations;
}
 
Example #12
Source File: ReactiveRedisOperationsSessionRepository.java    From spring-session with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new {@link ReactiveRedisOperationsSessionRepository} instance.
 * @param sessionRedisOperations the {@link ReactiveRedisOperations} to use for
 * managing sessions
 * @see ReactiveRedisSessionRepository#ReactiveRedisSessionRepository(ReactiveRedisOperations)
 */
public ReactiveRedisOperationsSessionRepository(ReactiveRedisOperations<String, Object> sessionRedisOperations) {
	super(sessionRedisOperations);
}