cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject git commit: Fix unit tests in trunk that didn't define their own schemas
Date Wed, 13 Aug 2014 15:15:34 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 231ad7a4e -> b6ce0a6bb


Fix unit tests in trunk that didn't define their own schemas

Patch by Lyuben Todorov; reviewed by tjake for CASSANDRA-7760


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

Branch: refs/heads/trunk
Commit: b6ce0a6bbbadfeba5dc5a0fd9ddfe227aa0ac5fd
Parents: 231ad7a
Author: Jake Luciani <jake@apache.org>
Authored: Wed Aug 13 11:13:55 2014 -0400
Committer: Jake Luciani <jake@apache.org>
Committed: Wed Aug 13 11:13:55 2014 -0400

----------------------------------------------------------------------
 .../db/index/PerRowSecondaryIndexTest.java      |  6 +++---
 .../cassandra/tools/SSTableExportTest.java      | 21 ++++++++++----------
 .../cassandra/tools/SSTableImportTest.java      | 11 +++++-----
 3 files changed, 20 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b6ce0a6b/test/unit/org/apache/cassandra/db/index/PerRowSecondaryIndexTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/index/PerRowSecondaryIndexTest.java b/test/unit/org/apache/cassandra/db/index/PerRowSecondaryIndexTest.java
index dfacfe2..b2cc1a4 100644
--- a/test/unit/org/apache/cassandra/db/index/PerRowSecondaryIndexTest.java
+++ b/test/unit/org/apache/cassandra/db/index/PerRowSecondaryIndexTest.java
@@ -147,18 +147,18 @@ public class PerRowSecondaryIndexTest
     public void testInvalidSearch() throws IOException
     {
         Mutation rm;
-        rm = new Mutation("PerRowSecondaryIndex", ByteBufferUtil.bytes("k4"));
+        rm = new Mutation(KEYSPACE1, ByteBufferUtil.bytes("k4"));
         rm.add("Indexed1", Util.cellname("indexed"), ByteBufferUtil.bytes("foo"), 1);
         rm.apply();
         
         // test we can search:
-        UntypedResultSet result = QueryProcessor.executeInternal("SELECT * FROM \"PerRowSecondaryIndex\".\"Indexed1\"
WHERE indexed = 'foo'");
+        UntypedResultSet result = QueryProcessor.executeInternal(String.format("SELECT *
FROM \"%s\".\"Indexed1\" WHERE indexed = 'foo'", KEYSPACE1));
         assertEquals(1, result.size());
 
         // test we can't search if the searcher doesn't validate the expression:
         try
         {
-            QueryProcessor.executeInternal("SELECT * FROM \"PerRowSecondaryIndex\".\"Indexed1\"
WHERE indexed = 'invalid'");
+            QueryProcessor.executeInternal(String.format("SELECT * FROM \"%s\".\"Indexed1\"
WHERE indexed = 'invalid'", KEYSPACE1));
             fail("Query should have been invalid!");
         }
         catch (Exception e)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b6ce0a6b/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/tools/SSTableExportTest.java b/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
index f1b7564..2009c0c 100644
--- a/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
+++ b/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
@@ -83,7 +83,8 @@ public class SSTableExportTest
                                     SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD),
                                     CFMetaData.denseCFMetaData(KEYSPACE1, CF_COUNTER, BytesType.instance).defaultValidator(CounterColumnType.instance),
                                     SchemaLoader.standardCFMD(KEYSPACE1, CF_UUID).keyValidator(UUIDType.instance),
-                                    CFMetaData.denseCFMetaData(KEYSPACE1, CF_VALSWITHQUOTES,
BytesType.instance).defaultValidator(UTF8Type.instance));
+                                    CFMetaData.denseCFMetaData(KEYSPACE1, CF_VALSWITHQUOTES,
BytesType.instance).defaultValidator(UTF8Type.instance),
+                                    SchemaLoader.standardCFMD(KEYSPACE1, "AsciiKeys").keyValidator(AsciiType.instance));
     }
 
     public String asHex(String str)
@@ -157,7 +158,7 @@ public class SSTableExportTest
         // Export to JSON and verify
         File tempJson = File.createTempFile("Standard1", ".json");
         SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[]{asHex("rowExclude")},
-                CFMetaData.sparseCFMetaData("Keyspace1", "Standard1", BytesType.instance));
+                CFMetaData.sparseCFMetaData(KEYSPACE1, "Standard1", BytesType.instance));
 
         JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
         assertEquals("unexpected number of rows", 2, json.size());
@@ -207,7 +208,7 @@ public class SSTableExportTest
         // Export to JSON and verify
         File tempJson = File.createTempFile("Standard1", ".json");
         SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[]{asHex("rowExclude")},
-                CFMetaData.sparseCFMetaData("Keyspace1", "Standard1", BytesType.instance));
+                CFMetaData.sparseCFMetaData(KEYSPACE1, "Standard1", BytesType.instance));
 
         // Import JSON to another SSTable file
         File tempSS2 = tempSSTableFile(KEYSPACE1, "Standard1");
@@ -242,7 +243,7 @@ public class SSTableExportTest
         // Export to JSON and verify
         File tempJson = File.createTempFile("Counter1", ".json");
         SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[0],
-                CFMetaData.sparseCFMetaData("Keyspace1", "Counter1", BytesType.instance));
+                CFMetaData.sparseCFMetaData(KEYSPACE1, "Counter1", BytesType.instance));
         JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
         assertEquals("unexpected number of rows", 1, json.size());
 
@@ -274,7 +275,7 @@ public class SSTableExportTest
         // Export to JSON and verify
         File tempJson = File.createTempFile("ValuesWithQuotes", ".json");
         SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[0],
-                CFMetaData.sparseCFMetaData("Keyspace1", "ValuesWithQuotes", BytesType.instance));
+                CFMetaData.sparseCFMetaData(KEYSPACE1, "ValuesWithQuotes", BytesType.instance));
 
         JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
         assertEquals("unexpected number of rows", 1, json.size());
@@ -306,7 +307,7 @@ public class SSTableExportTest
         // Export to JSON and verify
         File tempJson = File.createTempFile("CFWithDeletionInfo", ".json");
         SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[0],
-                CFMetaData.sparseCFMetaData("Keyspace1", "Counter1", BytesType.instance));
+                CFMetaData.sparseCFMetaData(KEYSPACE1, "Counter1", BytesType.instance));
 
         JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
         assertEquals("unexpected number of rows", 1, json.size());
@@ -366,7 +367,7 @@ public class SSTableExportTest
         // Export to JSON and verify
         File tempJson = File.createTempFile("CFWithColumnNameEqualToDefaultKeyAlias", ".json");
         SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[0],
-                CFMetaData.sparseCFMetaData("Keyspace1", "UUIDKeys", BytesType.instance));
+                CFMetaData.sparseCFMetaData(KEYSPACE1, "UUIDKeys", BytesType.instance));
 
         JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
         assertEquals(1, json.size());
@@ -384,8 +385,8 @@ public class SSTableExportTest
     @Test
     public void testAsciiKeyValidator() throws IOException, ParseException
     {
-        File tempSS = tempSSTableFile("Keyspace1", "AsciiKeys");
-        ColumnFamily cfamily = ArrayBackedSortedColumns.factory.create("Keyspace1", "AsciiKeys");
+        File tempSS = tempSSTableFile(KEYSPACE1, "AsciiKeys");
+        ColumnFamily cfamily = ArrayBackedSortedColumns.factory.create(KEYSPACE1, "AsciiKeys");
         SSTableWriter writer = new SSTableWriter(tempSS.getPath(), 2, ActiveRepairService.UNREPAIRED_SSTABLE);
 
         // Add a row
@@ -398,7 +399,7 @@ public class SSTableExportTest
         SSTableExport.export(reader,
                              new PrintStream(tempJson.getPath()),
                              new String[0],
-                             CFMetaData.sparseCFMetaData("Keyspace1", "AsciiKeys", BytesType.instance));
+                             CFMetaData.sparseCFMetaData(KEYSPACE1, "AsciiKeys", BytesType.instance));
 
         JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
         assertEquals(1, json.size());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b6ce0a6b/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/tools/SSTableImportTest.java b/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
index 8ea0ab8..5c4318a 100644
--- a/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
+++ b/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
@@ -66,7 +66,8 @@ public class SSTableImportTest
                                     SimpleStrategy.class,
                                     KSMetaData.optsWithRF(1),
                                     SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD),
-                                    CFMetaData.denseCFMetaData(KEYSPACE1, CF_COUNTER, BytesType.instance).defaultValidator(CounterColumnType.instance));
+                                    CFMetaData.denseCFMetaData(KEYSPACE1, CF_COUNTER, BytesType.instance).defaultValidator(CounterColumnType.instance),
+                                    SchemaLoader.standardCFMD(KEYSPACE1, "AsciiKeys").keyValidator(AsciiType.instance));
     }
 
     @Test
@@ -173,8 +174,8 @@ public class SSTableImportTest
     {
         // Import JSON to temp SSTable file
         String jsonUrl = resourcePath("SimpleCF.json");
-        File tempSS = tempSSTableFile("Keyspace1", "AsciiKeys");
-        new SSTableImport(true).importJson(jsonUrl, "Keyspace1", "AsciiKeys", tempSS.getPath());
+        File tempSS = tempSSTableFile(KEYSPACE1, "AsciiKeys");
+        new SSTableImport(true).importJson(jsonUrl, KEYSPACE1, "AsciiKeys", tempSS.getPath());
 
         // Verify results
         SSTableReader reader = SSTableReader.open(Descriptor.fromFilename(tempSS.getPath()));
@@ -192,10 +193,10 @@ public class SSTableImportTest
     {
         // Import JSON to temp SSTable file
         String jsonUrl = resourcePath("SimpleCF.json");
-        File tempSS = tempSSTableFile("Keyspace1", "AsciiKeys");
+        File tempSS = tempSSTableFile(KEYSPACE1, "AsciiKeys");
         // To ignore current key validator
         System.setProperty("skip.key.validator", "true");
-        new SSTableImport(true).importJson(jsonUrl, "Keyspace1", "AsciiKeys", tempSS.getPath());
+        new SSTableImport(true).importJson(jsonUrl, KEYSPACE1, "AsciiKeys", tempSS.getPath());
 
         // Verify results
         SSTableReader reader = SSTableReader.open(Descriptor.fromFilename(tempSS.getPath()));


Mime
View raw message