Elffuss BraidHub

kikocis/java-driver public

Move test method.
Changesetc47a44c177703a64d18e2c1fb254fed92a08dbfd2a6144948696a4f30d83d421
Authorolim7t <omichallat+github@gmail.com> · 2014-10-14 19:26 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-10-14 19:26 +02:00
Parents746d27b05c5b

Browse the files at this changeset

5 files changed

modified driver-core/src/main/java/com/datastax/driver/core/PoolingOptionsTest.java +1 −1
@@ -82,7 +82,7 @@
8282 // This is when refreshConnectedHost should have been invoked, it triggers pool creation when
8383 // we switch the node from IGNORED to UP:
8484 Mockito.verify(poolingOptions)
85- .refreshConnectedHost(ClusterAssert.findHost(cluster, 3));
85+ .refreshConnectedHost(TestUtils.findHost(cluster, 3));
8686
8787 } finally {
8888 if (cluster != null)
modified driver-core/src/test/java/com/datastax/driver/core/ClusterAssert.java +1 −13
@@ -1,7 +1,6 @@
11 package com.datastax.driver.core;
22
33 import static org.assertj.core.api.Assertions.assertThat;
4-import static org.testng.Assert.fail;
54 import org.assertj.core.api.AbstractAssert;
65
76 public class ClusterAssert extends AbstractAssert<ClusterAssert, Cluster> {
@@ -19,19 +18,8 @@
1918 public HostAssert host(int hostNumber) {
2019 // TODO at some point this won't work anymore if we have assertions that wait for a node to
2120 // join the cluster, e.g. assertThat(cluster).node(3).comesUp().
22- Host host = findHost(actual, hostNumber);
21+ Host host = TestUtils.findHost(actual, hostNumber);
2322
2423 return new HostAssert(host, actual);
2524 }
26-
27- /** Utility method to find the {@code Host} object corresponding to a node in a cluster. */
28- public static Host findHost(Cluster cluster, int hostNumber) {
29- String address = CCMBridge.ipOfNode(hostNumber);
30- for (Host host : cluster.getMetadata().getAllHosts()) {
31- if (host.getAddress().getHostAddress().equals(address))
32- return host;
33- }
34- fail(address + " not found in cluster metadata");
35- return null; // never reached
36- }
3725 }
modified driver-core/src/test/java/com/datastax/driver/core/SessionAssert.java +2 −2
@@ -12,13 +12,13 @@
1212 }
1313
1414 public SessionAssert hasPoolFor(int hostNumber) {
15- Host host = ClusterAssert.findHost(actual.cluster, hostNumber);
15+ Host host = TestUtils.findHost(actual.cluster, hostNumber);
1616 assertThat(actual.pools.containsKey(host)).isTrue();
1717 return this;
1818 }
1919
2020 public SessionAssert hasNoPoolFor(int hostNumber) {
21- Host host = ClusterAssert.findHost(actual.cluster, hostNumber);
21+ Host host = TestUtils.findHost(actual.cluster, hostNumber);
2222 assertThat(actual.pools.containsKey(host)).isFalse();
2323 return this;
2424 }
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +13 −0
@@ -21,6 +21,8 @@
2121 import java.nio.ByteBuffer;
2222 import java.util.*;
2323
24+import static org.testng.Assert.fail;
25+
2426 import org.slf4j.Logger;
2527 import org.slf4j.LoggerFactory;
2628 import org.testng.SkipException;
@@ -369,4 +371,15 @@
369371 throw new SkipException(skipString);
370372 }
371373 }
374+
375+ /** Utility method to find the {@code Host} object corresponding to a node in a cluster. */
376+ public static Host findHost(Cluster cluster, int hostNumber) {
377+ String address = CCMBridge.ipOfNode(hostNumber);
378+ for (Host host : cluster.getMetadata().getAllHosts()) {
379+ if (host.getAddress().getHostAddress().equals(address))
380+ return host;
381+ }
382+ fail(address + " not found in cluster metadata");
383+ return null; // never reached
384+ }
372385 }
modified driver-core/src/test/java/com/datastax/driver/core/policies/DCAwareRoundRobinPolicyTest.java +2 −2
@@ -5,8 +5,8 @@
55
66 import com.datastax.driver.core.CCMBridge;
77 import com.datastax.driver.core.Cluster;
8-import com.datastax.driver.core.ClusterAssert;
98 import com.datastax.driver.core.Host;
9+import com.datastax.driver.core.TestUtils;
1010
1111 public class DCAwareRoundRobinPolicyTest {
1212
@@ -29,7 +29,7 @@
2929 cluster.init();
3030
3131 // Policy's localDC should be the one from the contact point
32- Host host1 = ClusterAssert.findHost(cluster, 1);
32+ Host host1 = TestUtils.findHost(cluster, 1);
3333 assertEquals(policy.localDc, host1.getDatacenter());
3434
3535 } finally {