|
15 | 15 | */
|
16 | 16 | package com.datastax.driver.core;
|
17 | 17 |
|
| 18 | +import static org.assertj.core.api.Assertions.assertThat; |
18 | 19 | import static org.testng.Assert.assertNotNull;
|
19 | 20 | import static org.testng.Assert.assertNull;
|
20 | 21 | import static org.testng.Assert.assertTrue;
|
@@ -87,4 +88,77 @@ public void createUnspecifiedStrategyTest() throws Exception {
|
87 | 88 |
|
88 | 89 | assertNull(strategy);
|
89 | 90 | }
|
| 91 | + |
| 92 | + @Test(groups = "unit") |
| 93 | + public void simpleStrategyEqualsTest() { |
| 94 | + ReplicationStrategy rf3_1 = |
| 95 | + ReplicationStrategy.create( |
| 96 | + ImmutableMap.<String, String>builder() |
| 97 | + .put("class", "SimpleStrategy") |
| 98 | + .put("replication_factor", "3") |
| 99 | + .build()); |
| 100 | + |
| 101 | + ReplicationStrategy rf3_2 = |
| 102 | + ReplicationStrategy.create( |
| 103 | + ImmutableMap.<String, String>builder() |
| 104 | + .put("class", "SimpleStrategy") |
| 105 | + .put("replication_factor", "3") |
| 106 | + .build()); |
| 107 | + |
| 108 | + ReplicationStrategy rf2_1 = |
| 109 | + ReplicationStrategy.create( |
| 110 | + ImmutableMap.<String, String>builder() |
| 111 | + .put("class", "SimpleStrategy") |
| 112 | + .put("replication_factor", "2") |
| 113 | + .build()); |
| 114 | + |
| 115 | + //noinspection EqualsWithItself |
| 116 | + assertThat(rf3_1).isEqualTo(rf3_1); |
| 117 | + assertThat(rf3_1).isEqualTo(rf3_2); |
| 118 | + assertThat(rf3_1).isNotEqualTo(rf2_1); |
| 119 | + } |
| 120 | + |
| 121 | + public void networkTopologyStrategyEqualsTest() { |
| 122 | + ReplicationStrategy network_dc1x2_dc2x2_1 = |
| 123 | + ReplicationStrategy.create( |
| 124 | + ImmutableMap.<String, String>builder() |
| 125 | + .put("class", "NetworkTopologyStrategy") |
| 126 | + .put("dc1", "2") |
| 127 | + .put("dc2", "2") |
| 128 | + .build()); |
| 129 | + ReplicationStrategy network_dc1x2_dc2x2_2 = |
| 130 | + ReplicationStrategy.create( |
| 131 | + ImmutableMap.<String, String>builder() |
| 132 | + .put("class", "NetworkTopologyStrategy") |
| 133 | + .put("dc1", "2") |
| 134 | + .put("dc2", "2") |
| 135 | + .build()); |
| 136 | + ReplicationStrategy network_dc1x1_dc2x2_1 = |
| 137 | + ReplicationStrategy.create( |
| 138 | + ImmutableMap.<String, String>builder() |
| 139 | + .put("class", "NetworkTopologyStrategy") |
| 140 | + .put("dc1", "1") |
| 141 | + .put("dc2", "2") |
| 142 | + .build()); |
| 143 | + ReplicationStrategy network_dc1x2_dc3x2_1 = |
| 144 | + ReplicationStrategy.create( |
| 145 | + ImmutableMap.<String, String>builder() |
| 146 | + .put("class", "NetworkTopologyStrategy") |
| 147 | + .put("dc1", "2") |
| 148 | + .put("dc3", "2") |
| 149 | + .build()); |
| 150 | + ReplicationStrategy network_dc1x2_1 = |
| 151 | + ReplicationStrategy.create( |
| 152 | + ImmutableMap.<String, String>builder() |
| 153 | + .put("class", "NetworkTopologyStrategy") |
| 154 | + .put("dc1", "2") |
| 155 | + .build()); |
| 156 | + |
| 157 | + //noinspection EqualsWithItself |
| 158 | + assertThat(network_dc1x2_dc2x2_1).isEqualTo(network_dc1x2_dc2x2_1); |
| 159 | + assertThat(network_dc1x2_dc2x2_1).isEqualTo(network_dc1x2_dc2x2_2); |
| 160 | + assertThat(network_dc1x2_dc2x2_1).isNotEqualTo(network_dc1x1_dc2x2_1); |
| 161 | + assertThat(network_dc1x2_dc2x2_1).isNotEqualTo(network_dc1x2_dc3x2_1); |
| 162 | + assertThat(network_dc1x2_dc2x2_1).isNotEqualTo(network_dc1x2_1); |
| 163 | + } |
90 | 164 | }
|
0 commit comments