You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2010/07/08 23:12:07 UTC

svn commit: r961938 - /cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java

Author: jbellis
Date: Thu Jul  8 21:12:07 2010
New Revision: 961938

URL: http://svn.apache.org/viewvc?rev=961938&view=rev
Log:
improve index scan unit test.  patch by mdennis; reviewed by jbellis for CASSANDRA-1154

Modified:
    cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=961938&r1=961937&r2=961938&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java Thu Jul  8 21:12:07 2010
@@ -168,7 +168,19 @@ public class ColumnFamilyStoreTest exten
     public void testIndexScan() throws IOException
     {
         RowMutation rm;
-        rm = new RowMutation("Keyspace1", "k".getBytes());
+
+        rm = new RowMutation("Keyspace1", "k1".getBytes());
+        rm.add(new QueryPath("Indexed1", null, "notbirthdate".getBytes("UTF8")), FBUtilities.toByteArray(1L), new TimestampClock(0));
+        rm.add(new QueryPath("Indexed1", null, "birthdate".getBytes("UTF8")), FBUtilities.toByteArray(1L), new TimestampClock(0));
+        rm.apply();
+
+        rm = new RowMutation("Keyspace1", "k2".getBytes());
+        rm.add(new QueryPath("Indexed1", null, "notbirthdate".getBytes("UTF8")), FBUtilities.toByteArray(2L), new TimestampClock(0));
+        rm.add(new QueryPath("Indexed1", null, "birthdate".getBytes("UTF8")), FBUtilities.toByteArray(2L), new TimestampClock(0));
+        rm.apply();
+
+        rm = new RowMutation("Keyspace1", "k3".getBytes());
+        rm.add(new QueryPath("Indexed1", null, "notbirthdate".getBytes("UTF8")), FBUtilities.toByteArray(1L), new TimestampClock(0));
         rm.add(new QueryPath("Indexed1", null, "birthdate".getBytes("UTF8")), FBUtilities.toByteArray(1L), new TimestampClock(0));
         rm.apply();
 
@@ -176,7 +188,13 @@ public class ColumnFamilyStoreTest exten
         IndexClause clause = new IndexClause(Arrays.asList(expr), 100);
         IFilter filter = new IdentityQueryFilter();
         List<Row> rows = Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, filter);
-        assert rows != null && rows.size() > 0;
+
+        assert rows != null;
+        assert rows.size() == 2;
+        assert Arrays.equals("k1".getBytes(), rows.get(0).key.key);
+        assert Arrays.equals("k3".getBytes(), rows.get(1).key.key);
+        assert Arrays.equals(FBUtilities.toByteArray(1L), rows.get(0).cf.getColumn("birthdate".getBytes("UTF8")).value());
+        assert Arrays.equals(FBUtilities.toByteArray(1L), rows.get(1).cf.getColumn("birthdate".getBytes("UTF8")).value());
     }
 
     private ColumnFamilyStore insertKey1Key2() throws IOException, ExecutionException, InterruptedException