32
32
*
33
33
* @author Christoph Strobl
34
34
* @author Mark Paluch
35
+ * @author John Blum
35
36
*/
36
37
class RedisClusterConfigurationUnitTests {
37
38
38
39
private static final String HOST_AND_PORT_1 = "127.0.0.1:123" ;
39
40
private static final String HOST_AND_PORT_2 = "localhost:456" ;
40
41
private static final String HOST_AND_PORT_3 = "localhost:789" ;
42
+ private static final String HOST_AND_PORT_4 = "[fe80::a00:27ff:fe4b:ee48]:6379" ;
43
+ private static final String HOST_AND_PORT_5 = "[fe80:1234:1a2b:0:27ff:fe4b:0:ee48]:6380" ;
41
44
private static final String HOST_AND_NO_PORT = "localhost" ;
42
45
43
46
@ Test // DATAREDIS-315
@@ -81,13 +84,13 @@ void shouldThrowExecptionOnInvalidHostAndPortString() {
81
84
@ Test // DATAREDIS-315
82
85
void shouldThrowExceptionWhenListOfHostAndPortIsNull () {
83
86
assertThatIllegalArgumentException ()
84
- .isThrownBy (() -> new RedisClusterConfiguration (Collections .< String > singleton (null )));
87
+ .isThrownBy (() -> new RedisClusterConfiguration (Collections .singleton (null )));
85
88
}
86
89
87
90
@ Test // DATAREDIS-315
88
91
void shouldNotFailWhenListOfHostAndPortIsEmpty () {
89
92
90
- RedisClusterConfiguration config = new RedisClusterConfiguration (Collections .< String > emptySet ());
93
+ RedisClusterConfiguration config = new RedisClusterConfiguration (Collections .emptySet ());
91
94
92
95
assertThat (config .getClusterNodes ().size ()).isEqualTo (0 );
93
96
}
@@ -120,7 +123,7 @@ void shouldBeCreatedCorrectlyGivenValidPropertySourceWithSingleHostPort() {
120
123
}
121
124
122
125
@ Test // DATAREDIS-315
123
- void shouldBeCreatedCorrecltyGivenValidPropertySourceWithMultipleHostPort () {
126
+ void shouldBeCreatedCorrectlyGivenValidPropertySourceWithMultipleHostPort () {
124
127
125
128
MockPropertySource propertySource = new MockPropertySource ();
126
129
propertySource .setProperty ("spring.redis.cluster.nodes" ,
@@ -134,4 +137,19 @@ void shouldBeCreatedCorrecltyGivenValidPropertySourceWithMultipleHostPort() {
134
137
new RedisNode ("localhost" , 789 ));
135
138
}
136
139
140
+ @ Test // GH-2360
141
+ public void shouldBeCreatedCorrectlyGivenValidPropertySourceWithMultipleIPv6AddressesAndPorts () {
142
+
143
+ MockPropertySource propertySource = new MockPropertySource ();
144
+
145
+ propertySource .setProperty ("spring.redis.cluster.nodes" ,
146
+ StringUtils .collectionToCommaDelimitedString (Arrays .asList (HOST_AND_PORT_4 , HOST_AND_PORT_5 )));
147
+ propertySource .setProperty ("spring.redis.cluster.max-redirects" , 2 );
148
+
149
+ RedisClusterConfiguration configuration = new RedisClusterConfiguration (propertySource );
150
+
151
+ assertThat (configuration .getMaxRedirects ()).isEqualTo (2 );
152
+ assertThat (configuration .getClusterNodes ()).contains (new RedisNode ("fe80::a00:27ff:fe4b:ee48" , 6379 ),
153
+ new RedisNode ("fe80:1234:1a2b:0:27ff:fe4b:0:ee48" , 6380 ));
154
+ }
137
155
}
0 commit comments