From 743bc751b8c27b3122c091a7efafa288ed74bd8e Mon Sep 17 00:00:00 2001 From: Ashish Singhi Date: Tue, 9 Dec 2014 10:26:10 +0530 Subject: [PATCH] HBASE-12653 Move TestRegionServerOnlineConfigChange & TestConfigurationManager to Junit4 tests --- .../hbase/conf/TestConfigurationManager.java | 8 +++-- .../TestRegionServerOnlineConfigChange.java | 41 +++++++++++++--------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/conf/TestConfigurationManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/conf/TestConfigurationManager.java index 51552a5..fe56344 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/conf/TestConfigurationManager.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/conf/TestConfigurationManager.java @@ -18,17 +18,19 @@ package org.apache.hadoop.hbase.conf; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.junit.Test; import org.junit.experimental.categories.Category; @Category({SmallTests.class, ClientTests.class}) -public class TestConfigurationManager extends TestCase { +public class TestConfigurationManager { public static final Log LOG = LogFactory.getLog(TestConfigurationManager.class); class DummyConfigurationObserver implements ConfigurationObserver { @@ -66,6 +68,7 @@ public class TestConfigurationManager extends TestCase { * Test if observers get notified by the ConfigurationManager * when the Configuration is reloaded. */ + @Test public void testCheckIfObserversNotified() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager(); @@ -101,6 +104,7 @@ public class TestConfigurationManager extends TestCase { /** * Test if out-of-scope observers are deregistered on GC. */ + @Test public void testDeregisterOnOutOfScope() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerOnlineConfigChange.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerOnlineConfigChange.java index 6aa2526..c58e9c6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerOnlineConfigChange.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerOnlineConfigChange.java @@ -18,7 +18,9 @@ package org.apache.hadoop.hbase.regionserver; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -30,6 +32,9 @@ import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; import org.junit.experimental.categories.Category; import java.io.IOException; @@ -41,25 +46,25 @@ import java.io.IOException; */ @Category({MediumTests.class}) -public class TestRegionServerOnlineConfigChange extends TestCase { - static final Log LOG = +public class TestRegionServerOnlineConfigChange { + private static final Log LOG = LogFactory.getLog(TestRegionServerOnlineConfigChange.class.getName()); - HBaseTestingUtility hbaseTestingUtility = new HBaseTestingUtility(); - Configuration conf = null; + private static HBaseTestingUtility hbaseTestingUtility = new HBaseTestingUtility(); + private static Configuration conf = null; - HTable t1 = null; - HRegionServer rs1 = null; - byte[] r1name = null; - HRegion r1 = null; + private static HTable t1 = null; + private static HRegionServer rs1 = null; + private static byte[] r1name = null; + private static HRegion r1 = null; - final String table1Str = "table1"; - final String columnFamily1Str = "columnFamily1"; - final byte[] TABLE1 = Bytes.toBytes(table1Str); - final byte[] COLUMN_FAMILY1 = Bytes.toBytes(columnFamily1Str); + private final static String table1Str = "table1"; + private final static String columnFamily1Str = "columnFamily1"; + private final static byte[] TABLE1 = Bytes.toBytes(table1Str); + private final static byte[] COLUMN_FAMILY1 = Bytes.toBytes(columnFamily1Str); - @Override - public void setUp() throws Exception { + @BeforeClass + public static void setUp() throws Exception { conf = hbaseTestingUtility.getConfiguration(); hbaseTestingUtility.startMiniCluster(1,1); t1 = hbaseTestingUtility.createTable(TABLE1, COLUMN_FAMILY1); @@ -71,8 +76,8 @@ public class TestRegionServerOnlineConfigChange extends TestCase { r1 = rs1.getRegion(r1name); } - @Override - public void tearDown() throws Exception { + @AfterClass + public static void tearDown() throws Exception { hbaseTestingUtility.shutdownMiniCluster(); } @@ -80,6 +85,7 @@ public class TestRegionServerOnlineConfigChange extends TestCase { * Check if the number of compaction threads changes online * @throws IOException */ + @Test public void testNumCompactionThreadsOnlineChange() throws IOException { assertTrue(rs1.compactSplitThread != null); int newNumSmallThreads = @@ -105,6 +111,7 @@ public class TestRegionServerOnlineConfigChange extends TestCase { * * @throws IOException */ + @Test public void testCompactionConfigurationOnlineChange() throws IOException { String strPrefix = "hbase.hstore.compaction."; Store s = r1.getStore(COLUMN_FAMILY1); -- 1.9.2.msysgit.0