cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject [2/2] git commit: fix NPE in DefsTest and DatabaseDescriptorTest caused by not initialized (started) Gossiper
Date Thu, 23 Feb 2012 15:31:16 GMT
fix NPE in DefsTest and DatabaseDescriptorTest caused by not initialized (started) Gossiper


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

Branch: refs/heads/cassandra-1.1
Commit: 44d6f49bb051a3a49fb2b758b6fb8016a1845f13
Parents: 9dbb1b7
Author: Pavel Yaskevich <xedin@apache.org>
Authored: Thu Feb 23 18:07:59 2012 +0300
Committer: Pavel Yaskevich <xedin@apache.org>
Committed: Thu Feb 23 18:28:15 2012 +0300

----------------------------------------------------------------------
 .../cassandra/config/DatabaseDescriptorTest.java   |   42 +++++++++------
 test/unit/org/apache/cassandra/db/DefsTest.java    |   15 +++++
 2 files changed, 41 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/44d6f49b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
index 084ed9b..1cb2b64 100644
--- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
+++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.config;
 
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.db.migration.AddKeyspace;
+import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.locator.SimpleStrategy;
 import org.apache.cassandra.thrift.InvalidRequestException;
 
@@ -64,25 +65,34 @@ public class DatabaseDescriptorTest
         CleanupHelper.cleanupAndLeaveDirs();
         DatabaseDescriptor.loadSchemas();
         assert Schema.instance.getNonSystemTables().size() == 0;
-        
-        // add a few.
-        AddKeyspace ks0 = new AddKeyspace(KSMetaData.testMetadata("ks0", SimpleStrategy.class,
KSMetaData.optsWithRF(3)));
-        ks0.apply();
-        AddKeyspace ks1 = new AddKeyspace(KSMetaData.testMetadata("ks1", SimpleStrategy.class,
KSMetaData.optsWithRF(3)));
-        ks1.apply();
 
-        assert Schema.instance.getTableDefinition("ks0") != null;
-        assert Schema.instance.getTableDefinition("ks1") != null;
+        Gossiper.instance.start((int)(System.currentTimeMillis() / 1000));
 
-        Schema.instance.clearTableDefinition(Schema.instance.getTableDefinition("ks0"));
-        Schema.instance.clearTableDefinition(Schema.instance.getTableDefinition("ks1"));
+        try
+        {
+            // add a few.
+            AddKeyspace ks0 = new AddKeyspace(KSMetaData.testMetadata("ks0", SimpleStrategy.class,
KSMetaData.optsWithRF(3)));
+            ks0.apply();
+            AddKeyspace ks1 = new AddKeyspace(KSMetaData.testMetadata("ks1", SimpleStrategy.class,
KSMetaData.optsWithRF(3)));
+            ks1.apply();
 
-        assert Schema.instance.getTableDefinition("ks0") == null;
-        assert Schema.instance.getTableDefinition("ks1") == null;
-        
-        DatabaseDescriptor.loadSchemas();
+            assert Schema.instance.getTableDefinition("ks0") != null;
+            assert Schema.instance.getTableDefinition("ks1") != null;
+
+            Schema.instance.clearTableDefinition(Schema.instance.getTableDefinition("ks0"));
+            Schema.instance.clearTableDefinition(Schema.instance.getTableDefinition("ks1"));
+
+            assert Schema.instance.getTableDefinition("ks0") == null;
+            assert Schema.instance.getTableDefinition("ks1") == null;
 
-        assert Schema.instance.getTableDefinition("ks0") != null;
-        assert Schema.instance.getTableDefinition("ks1") != null;
+            DatabaseDescriptor.loadSchemas();
+
+            assert Schema.instance.getTableDefinition("ks0") != null;
+            assert Schema.instance.getTableDefinition("ks1") != null;
+        }
+        finally
+        {
+            Gossiper.instance.stop();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/44d6f49b/test/unit/org/apache/cassandra/db/DefsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/DefsTest.java b/test/unit/org/apache/cassandra/db/DefsTest.java
index bd3dfa1..9bfa82c 100644
--- a/test/unit/org/apache/cassandra/db/DefsTest.java
+++ b/test/unit/org/apache/cassandra/db/DefsTest.java
@@ -39,6 +39,7 @@ import org.apache.cassandra.db.migration.DropKeyspace;
 import org.apache.cassandra.db.migration.Migration;
 import org.apache.cassandra.db.migration.UpdateColumnFamily;
 import org.apache.cassandra.db.migration.UpdateKeyspace;
+import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.io.sstable.Component;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.sstable.SSTableDeletingTask;
@@ -49,10 +50,24 @@ import org.apache.cassandra.thrift.ColumnDef;
 import org.apache.cassandra.thrift.IndexType;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class DefsTest extends CleanupHelper
 {
+    @BeforeClass
+    public static void startGossiper()
+    {
+        Gossiper.instance.start((int) (System.currentTimeMillis() / 1000));
+    }
+
+    @AfterClass
+    public static void stopGossiper()
+    {
+        Gossiper.instance.stop();
+    }
+
     @Test
     public void ensureStaticCFMIdsAreLessThan1000()
     {


Mime
View raw message