|
27 | 27 | import org.springframework.data.redis.connection.RedisNode.NodeType;
|
28 | 28 |
|
29 | 29 | /**
|
| 30 | + * Unit tests for {@link Converters}. |
| 31 | + * |
30 | 32 | * @author Christoph Strobl
|
31 | 33 | * @author Mark Paluch
|
32 | 34 | */
|
@@ -56,6 +58,8 @@ public class ConvertersUnitTests {
|
56 | 58 |
|
57 | 59 | private static final String CLUSTER_NODE_IMPORTING_SLOT = "ef570f86c7b1a953846668debc177a3a16733420 127.0.0.1:6379 myself,master - 0 0 1 connected [5461-<-0f2ee5df45d18c50aca07228cc18b1da96fd5e84]";
|
58 | 60 |
|
| 61 | + private static final String CLUSTER_NODE_WITHOUT_HOST = "ef570f86c7b1a953846668debc177a3a16733420 :6379 fail,master - 0 0 1 connected"; |
| 62 | + |
59 | 63 | @Test // DATAREDIS-315
|
60 | 64 | public void toSetOfRedis30ClusterNodesShouldConvertSingleStringNodesResponseCorrectly() {
|
61 | 65 |
|
@@ -194,6 +198,23 @@ public void toSetOfRedisClusterNodesShouldIgnoreImportingSlot() {
|
194 | 198 | RedisClusterNode node = nodes.next();
|
195 | 199 | assertThat(node.getId()).isEqualTo("ef570f86c7b1a953846668debc177a3a16733420");
|
196 | 200 | assertThat(node.getHost()).isEqualTo("127.0.0.1");
|
| 201 | + assertThat(node.hasValidHost()).isTrue(); |
| 202 | + assertThat(node.getPort()).isEqualTo(6379); |
| 203 | + assertThat(node.getType()).isEqualTo(NodeType.MASTER); |
| 204 | + assertThat(node.getFlags()).contains(Flag.MASTER); |
| 205 | + assertThat(node.getLinkState()).isEqualTo(LinkState.CONNECTED); |
| 206 | + assertThat(node.getSlotRange().getSlots().size()).isEqualTo(0); |
| 207 | + } |
| 208 | + |
| 209 | + @Test // GH-1985 |
| 210 | + public void toSetOfRedisClusterNodesShouldAllowEmptyHostname() { |
| 211 | + |
| 212 | + Iterator<RedisClusterNode> nodes = Converters.toSetOfRedisClusterNodes(CLUSTER_NODE_WITHOUT_HOST).iterator(); |
| 213 | + |
| 214 | + RedisClusterNode node = nodes.next(); |
| 215 | + assertThat(node.getId()).isEqualTo("ef570f86c7b1a953846668debc177a3a16733420"); |
| 216 | + assertThat(node.getHost()).isEmpty(); |
| 217 | + assertThat(node.hasValidHost()).isFalse(); |
197 | 218 | assertThat(node.getPort()).isEqualTo(6379);
|
198 | 219 | assertThat(node.getType()).isEqualTo(NodeType.MASTER);
|
199 | 220 | assertThat(node.getFlags()).contains(Flag.MASTER);
|
|
0 commit comments