cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r963936 - /cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
Date Wed, 14 Jul 2010 03:41:12 GMT
Author: jbellis
Date: Wed Jul 14 03:41:12 2010
New Revision: 963936

URL: http://svn.apache.org/viewvc?rev=963936&view=rev
Log:
revert unit test accidentally included in previous commit

Modified:
    cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java

Modified: cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=963936&r1=963935&r2=963936&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
(original)
+++ cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
Wed Jul 14 03:41:12 2010
@@ -19,7 +19,6 @@
 package org.apache.cassandra.db;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.util.*;
 import java.util.concurrent.ExecutionException;
 
@@ -30,7 +29,6 @@ import org.junit.Test;
 import static junit.framework.Assert.assertEquals;
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.Util;
-import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.WrappedRunnable;
 
@@ -140,60 +138,44 @@ public class ColumnFamilyStoreTest exten
     @Test
     public void testWrappedRangeQuery() throws IOException, ExecutionException, InterruptedException
     {
-        ColumnFamilyStore cfs = insert("key1", "key2", "key3", "key4", "key5");
-        IPartitioner p = StorageService.getPartitioner();
-        RangeSliceReply result;
-
-        result = getRangeSlice(cfs, p.getToken("key15"), p.getToken("key1"));
-        assertKeys(result.rows, Arrays.asList("key2", "key3", "key4", "key5", "key1"));
-
-        result = getRangeSlice(cfs, p.getToken("key3"), p.getToken("key3"));
-        assertKeys(result.rows, Arrays.asList("key4", "key5", "key1", "key2", "key3"));
+        ColumnFamilyStore cfs = insertKey1Key2();
 
-        result = getRangeSlice(cfs, p.getToken("key25"), p.getToken("key25"));
-        assertKeys(result.rows, Arrays.asList("key3", "key4", "key5", "key1", "key2"));
-    }
-
-    private RangeSliceReply getRangeSlice(ColumnFamilyStore cfs, Token start, Token end)
throws IOException, ExecutionException, InterruptedException
-    {
-        return cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
-                                 new Range(start, end),
-                                 10,
-                                 null,
-                                 Arrays.asList("asdf".getBytes()));
-    }
-
-    private void assertKeys(List<Row> rows, List<String> keys) throws UnsupportedEncodingException
-    {
-        assertEquals(keys.size(), rows.size());
-        for (int i = 0; i < keys.size(); i++)
-        {
-            assertEquals(keys.get(i), rows.get(i).key);
-        }
+        IPartitioner p = StorageService.getPartitioner();
+        RangeSliceReply result = cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
+                                                   new Range(p.getToken("key15"), p.getToken("key1")),
+                                                   10,
+                                                   null,
+                                                   Arrays.asList("asdf".getBytes()));
+        assertEquals(2, result.rows.size());
     }
 
     @Test
     public void testSkipStartKey() throws IOException, ExecutionException, InterruptedException
     {
-        ColumnFamilyStore cfs = insert("key1", "key2");
-        IPartitioner p = StorageService.getPartitioner();
+        ColumnFamilyStore cfs = insertKey1Key2();
 
-        RangeSliceReply result = getRangeSlice(cfs, p.getToken("key1"), p.getToken("key2"));
-        assertKeys(result.rows, Arrays.asList("key2"));
+        IPartitioner p = StorageService.getPartitioner();
+        RangeSliceReply result = cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
+                                                   new Range(p.getToken("key1"), p.getToken("key2")),
+                                                   10,
+                                                   null,
+                                                   Arrays.asList("asdf".getBytes()));
+        assertEquals(1, result.rows.size());
+        assert result.rows.get(0).key.equals("key2");
     }
 
-    private ColumnFamilyStore insert(String... keys) throws IOException, ExecutionException,
InterruptedException
+    private ColumnFamilyStore insertKey1Key2() throws IOException, ExecutionException, InterruptedException
     {
         List<RowMutation> rms = new LinkedList<RowMutation>();
         RowMutation rm;
-        for (String key : keys)
-        {
-            rm = new RowMutation("Keyspace2", key);
-            rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(),
0);
-            rms.add(rm);
-        }
+        rm = new RowMutation("Keyspace2", "key1");
+        rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(),
0);
+        rms.add(rm);
+        Util.writeColumnFamily(rms);
 
+        rm = new RowMutation("Keyspace2", "key2");
+        rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(),
0);
+        rms.add(rm);
         return Util.writeColumnFamily(rms);
     }
-
 }



Mime
View raw message