Polishing.

Organize source code and cleanup compiler warnings.

See #2594
Original pull request: #2669
This commit is contained in:
John Blum
2023-08-08 16:16:15 -07:00
committed by Mark Paluch
parent 76c1830c57
commit 2eaf1746da
8 changed files with 1311 additions and 1157 deletions

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2015-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.connection.lettuce;
import io.lettuce.core.RedisURI;
/**
* Unit tests for the {@link LettuceConnectionFactory#createRedisConfiguration(RedisURI)} factory method.
*
* @author Chris Bono
*/
class LettuceConnectionFactoryRedisURITests {
}

View File

@@ -38,6 +38,7 @@ import io.lettuce.core.resource.ClientResources;
import reactor.test.StepVerifier;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
@@ -64,6 +65,8 @@ import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.test.extension.LettuceTestClientResources;
import org.springframework.test.util.ReflectionTestUtils;
import org.assertj.core.api.InstanceOfAssertFactories;
/**
* Unit tests for {@link LettuceConnectionFactory}.
*
@@ -1125,6 +1128,7 @@ class LettuceConnectionFactoryUnitTests {
@Test // GH-2116
void createRedisConfigurationRequiresRedisUri() {
assertThatIllegalArgumentException()
.isThrownBy(() -> LettuceConnectionFactory.createRedisConfiguration((RedisURI) null))
.withMessage("RedisURI must not be null");
@@ -1236,6 +1240,35 @@ class LettuceConnectionFactoryUnitTests {
assertThat(connectionFactory.isRunning()).isTrue();
}
@Test // GH-2594
void createRedisConfigurationWithNullInvalidRedisUriString() {
Arrays.asList(" ", "", null).forEach(redisUri ->
assertThatIllegalArgumentException()
.isThrownBy(() -> LettuceConnectionFactory.createRedisConfiguration(redisUri))
.withMessage("RedisURI must not be null or empty")
.withNoCause());
}
@Test
public void createRedisConfigurationWithValidRedisUriString() {
RedisConfiguration redisConfiguration =
LettuceConnectionFactory.createRedisConfiguration("redis://skullbox:6789");
assertThat(redisConfiguration).isInstanceOf(RedisStandaloneConfiguration.class);
assertThat(redisConfiguration)
.asInstanceOf(InstanceOfAssertFactories.type(RedisStandaloneConfiguration.class))
.extracting(RedisStandaloneConfiguration::getHostName)
.isEqualTo("skullbox");
assertThat(redisConfiguration)
.asInstanceOf(InstanceOfAssertFactories.type(RedisStandaloneConfiguration.class))
.extracting(RedisStandaloneConfiguration::getPort)
.isEqualTo(6789);
}
static class CustomRedisConfiguration implements RedisConfiguration, WithHostAndPort {
private String hostName;