kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | c47a44c177703a64d18e2c1fb254fed92a08dbfd2a6144948696a4f30d83d421 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-10-14 19:26 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-10-14 19:26 +02:00 |
| Parents | 746d27b05c5b |
5 files changed
modified driver-core/src/main/java/com/datastax/driver/core/PoolingOptionsTest.java +1 −1
| @@ -82,7 +82,7 @@ | ||
| 82 | 82 | // This is when refreshConnectedHost should have been invoked, it triggers pool creation when |
| 83 | 83 | // we switch the node from IGNORED to UP: |
| 84 | 84 | Mockito.verify(poolingOptions) |
| 85 | - .refreshConnectedHost(ClusterAssert.findHost(cluster, 3)); | |
| 85 | + .refreshConnectedHost(TestUtils.findHost(cluster, 3)); | |
| 86 | 86 | |
| 87 | 87 | } finally { |
| 88 | 88 | if (cluster != null) |
modified driver-core/src/test/java/com/datastax/driver/core/ClusterAssert.java +1 −13
| @@ -1,7 +1,6 @@ | ||
| 1 | 1 | package com.datastax.driver.core; |
| 2 | 2 | |
| 3 | 3 | import static org.assertj.core.api.Assertions.assertThat; |
| 4 | -import static org.testng.Assert.fail; | |
| 5 | 4 | import org.assertj.core.api.AbstractAssert; |
| 6 | 5 | |
| 7 | 6 | public class ClusterAssert extends AbstractAssert<ClusterAssert, Cluster> { |
| @@ -19,19 +18,8 @@ | ||
| 19 | 18 | public HostAssert host(int hostNumber) { |
| 20 | 19 | // TODO at some point this won't work anymore if we have assertions that wait for a node to |
| 21 | 20 | // join the cluster, e.g. assertThat(cluster).node(3).comesUp(). |
| 22 | - Host host = findHost(actual, hostNumber); | |
| 21 | + Host host = TestUtils.findHost(actual, hostNumber); | |
| 23 | 22 | |
| 24 | 23 | return new HostAssert(host, actual); |
| 25 | 24 | } |
| 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 | - } | |
| 37 | 25 | } |
modified driver-core/src/test/java/com/datastax/driver/core/SessionAssert.java +2 −2
| @@ -12,13 +12,13 @@ | ||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | public SessionAssert hasPoolFor(int hostNumber) { |
| 15 | - Host host = ClusterAssert.findHost(actual.cluster, hostNumber); | |
| 15 | + Host host = TestUtils.findHost(actual.cluster, hostNumber); | |
| 16 | 16 | assertThat(actual.pools.containsKey(host)).isTrue(); |
| 17 | 17 | return this; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public SessionAssert hasNoPoolFor(int hostNumber) { |
| 21 | - Host host = ClusterAssert.findHost(actual.cluster, hostNumber); | |
| 21 | + Host host = TestUtils.findHost(actual.cluster, hostNumber); | |
| 22 | 22 | assertThat(actual.pools.containsKey(host)).isFalse(); |
| 23 | 23 | return this; |
| 24 | 24 | } |
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +13 −0
| @@ -21,6 +21,8 @@ | ||
| 21 | 21 | import java.nio.ByteBuffer; |
| 22 | 22 | import java.util.*; |
| 23 | 23 | |
| 24 | +import static org.testng.Assert.fail; | |
| 25 | + | |
| 24 | 26 | import org.slf4j.Logger; |
| 25 | 27 | import org.slf4j.LoggerFactory; |
| 26 | 28 | import org.testng.SkipException; |
| @@ -369,4 +371,15 @@ | ||
| 369 | 371 | throw new SkipException(skipString); |
| 370 | 372 | } |
| 371 | 373 | } |
| 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 | + } | |
| 372 | 385 | } |
modified driver-core/src/test/java/com/datastax/driver/core/policies/DCAwareRoundRobinPolicyTest.java +2 −2
| @@ -5,8 +5,8 @@ | ||
| 5 | 5 | |
| 6 | 6 | import com.datastax.driver.core.CCMBridge; |
| 7 | 7 | import com.datastax.driver.core.Cluster; |
| 8 | -import com.datastax.driver.core.ClusterAssert; | |
| 9 | 8 | import com.datastax.driver.core.Host; |
| 9 | +import com.datastax.driver.core.TestUtils; | |
| 10 | 10 | |
| 11 | 11 | public class DCAwareRoundRobinPolicyTest { |
| 12 | 12 | |
| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | cluster.init(); |
| 30 | 30 | |
| 31 | 31 | // 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); | |
| 33 | 33 | assertEquals(policy.localDc, host1.getDatacenter()); |
| 34 | 34 | |
| 35 | 35 | } finally { |