kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 485fdbbd739f1cb86acde6eafef0a7d7cf16aa194221d2df55efa0ede964fabc |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-08-18 19:32 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-08-18 19:32 +02:00 |
| Parents | 0af3381a972a |
1 file changed
added driver-core/src/test/java/com/datastax/driver/core/TokenMapTest.java +37 −0
| @@ -0,0 +1,37 @@ | ||
| 1 | +package com.datastax.driver.core; | |
| 2 | + | |
| 3 | +import java.nio.ByteBuffer; | |
| 4 | +import java.util.Set; | |
| 5 | + | |
| 6 | +import org.testng.annotations.*; | |
| 7 | + | |
| 8 | +import static org.testng.Assert.assertFalse; | |
| 9 | + | |
| 10 | +import com.datastax.driver.core.CCMBridge.CCMCluster; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Tests that the token map is correctly initialized at startup (JAVA-415). | |
| 14 | + */ | |
| 15 | +public class TokenMapTest { | |
| 16 | + CCMCluster ccmCluster = null; | |
| 17 | + Cluster cluster = null; | |
| 18 | + | |
| 19 | + @BeforeMethod(groups = "short") | |
| 20 | + public void setup() { | |
| 21 | + ccmCluster = CCMBridge.buildCluster(1, Cluster.builder()); | |
| 22 | + cluster = ccmCluster.cluster; | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Test(groups = "short") | |
| 26 | + public void initTest() { | |
| 27 | + // If the token map is initialized correctly, we should get replicas for any partition key | |
| 28 | + ByteBuffer anyKey = ByteBuffer.wrap(new byte[]{}); | |
| 29 | + Set<Host> replicas = cluster.getMetadata().getReplicas("system", anyKey); | |
| 30 | + assertFalse(replicas.isEmpty()); | |
| 31 | + } | |
| 32 | + | |
| 33 | + @AfterMethod(groups = "short") | |
| 34 | + public void teardown() { | |
| 35 | + ccmCluster.discard(); | |
| 36 | + } | |
| 37 | +} |