cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Fix TokenMetadataTest
Date Tue, 19 Nov 2013 16:21:29 GMT
Updated Branches:
  refs/heads/cassandra-1.2 582a16eff -> 0a5a766d5


Fix TokenMetadataTest


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0a5a766d
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0a5a766d
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0a5a766d

Branch: refs/heads/cassandra-1.2
Commit: 0a5a766d52f3c06399bfa8826df836b3dc070a20
Parents: 582a16e
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Nov 19 17:21:19 2013 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Nov 19 17:21:19 2013 +0100

----------------------------------------------------------------------
 .../cassandra/locator/TokenMetadataTest.java    | 30 ++++++++++----------
 1 file changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0a5a766d/test/unit/org/apache/cassandra/locator/TokenMetadataTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/locator/TokenMetadataTest.java b/test/unit/org/apache/cassandra/locator/TokenMetadataTest.java
index 9f93b2f..f2dc381 100644
--- a/test/unit/org/apache/cassandra/locator/TokenMetadataTest.java
+++ b/test/unit/org/apache/cassandra/locator/TokenMetadataTest.java
@@ -37,21 +37,20 @@ public class TokenMetadataTest
     public final static String ONE = "1";
     public final static String SIX = "6";
 
-    public static ArrayList<Token> RING;
+    static TokenMetadata tmd;
 
     @BeforeClass
     public static void beforeClass() throws Throwable
     {
-        TokenMetadata tmd = StorageService.instance.getTokenMetadata();
+        tmd = StorageService.instance.getTokenMetadata();
         tmd.updateNormalToken(token(ONE), InetAddress.getByName("127.0.0.1"));
         tmd.updateNormalToken(token(SIX), InetAddress.getByName("127.0.0.6"));
-        RING = tmd.sortedTokens();
     }
 
-    private void testRingIterator(String start, boolean includeMin, String... expected)
+    private void testRingIterator(ArrayList<Token> ring, String start, boolean includeMin,
String... expected)
     {
         ArrayList<Token> actual = new ArrayList<Token>();
-        Iterators.addAll(actual, TokenMetadata.ringIterator(RING, token(start), includeMin));
+        Iterators.addAll(actual, TokenMetadata.ringIterator(ring, token(start), includeMin));
         assertEquals(actual.toString(), expected.length, actual.size());
         for (int i = 0; i < expected.length; i++)
             assertEquals("Mismatch at index " + i + ": " + actual, token(expected[i]), actual.get(i));
@@ -60,25 +59,26 @@ public class TokenMetadataTest
     @Test
     public void testRingIterator()
     {
-        testRingIterator("2", false, "6", "1");
-        testRingIterator("7", false, "1", "6");
-        testRingIterator("0", false, "1", "6");
-        testRingIterator("", false, "1", "6");
+        ArrayList<Token> ring = tmd.sortedTokens();
+        testRingIterator(ring, "2", false, "6", "1");
+        testRingIterator(ring, "7", false, "1", "6");
+        testRingIterator(ring, "0", false, "1", "6");
+        testRingIterator(ring, "", false, "1", "6");
     }
 
     @Test
     public void testRingIteratorIncludeMin()
     {
-        testRingIterator("2", true, "6", "", "1");
-        testRingIterator("7", true, "", "1", "6");
-        testRingIterator("0", true, "1", "6", "");
-        testRingIterator("", true, "1", "6", "");
+        ArrayList<Token> ring = tmd.sortedTokens();
+        testRingIterator(ring, "2", true, "6", "", "1");
+        testRingIterator(ring, "7", true, "", "1", "6");
+        testRingIterator(ring, "0", true, "1", "6", "");
+        testRingIterator(ring, "", true, "1", "6", "");
     }
 
     @Test
     public void testRingIteratorEmptyRing()
     {
-        RING.clear();
-        testRingIterator("2", false);
+        testRingIterator(new ArrayList<Token>(), "2", false);
     }
 }


Mime
View raw message