HBASE-14670 Remove deprecated HBaseTestCase from TestBlocksRead
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/418c4422 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/418c4422 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/418c4422 Branch: refs/heads/hbase-12439 Commit: 418c4422f7fc99ce58bd10c20090f34211da3b13 Parents: 6875e6d Author: Jonathan M Hsieh <jmhs...@apache.org> Authored: Sat Oct 24 05:35:00 2015 -0700 Committer: Jonathan M Hsieh <jmhs...@apache.org> Committed: Sat Oct 24 05:35:00 2015 -0700 ---------------------------------------------------------------------- .../hbase/regionserver/TestBlocksRead.java | 58 ++++++++------------ 1 file changed, 22 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/418c4422/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java index c4b26b9..900d4ff 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java @@ -26,11 +26,10 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; -import org.apache.hadoop.hbase.HBaseConfiguration; -import org.apache.hadoop.hbase.HBaseTestCase; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; @@ -48,44 +47,35 @@ import org.apache.hadoop.hbase.io.hfile.CacheConfig; import org.apache.hadoop.hbase.io.hfile.HFile; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.*; import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; + +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertEquals; @Category({RegionServerTests.class, MediumTests.class}) -public class TestBlocksRead extends HBaseTestCase { +public class TestBlocksRead { private static final Log LOG = LogFactory.getLog(TestBlocksRead.class); + @Rule public TestName testName = new TestName(); + static final BloomType[] BLOOM_TYPE = new BloomType[] { BloomType.ROWCOL, BloomType.ROW, BloomType.NONE }; private static BlockCache blockCache; - - private HBaseConfiguration getConf() { - HBaseConfiguration conf = new HBaseConfiguration(); - - // disable compactions in this test. - conf.setInt("hbase.hstore.compactionThreshold", 10000); - return conf; - } - Region region = null; - private HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + private static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private final String DIR = TEST_UTIL.getDataTestDir("TestBlocksRead").toString(); + private Configuration conf = TEST_UTIL.getConfiguration(); - /** - * @see org.apache.hadoop.hbase.HBaseTestCase#setUp() - */ - @SuppressWarnings("deprecation") - @Before - protected void setUp() throws Exception { - super.setUp(); + @BeforeClass + public static void setUp() throws Exception { + // disable compactions in this test. + TEST_UTIL.getConfiguration().setInt("hbase.hstore.compactionThreshold", 10000); } - @SuppressWarnings("deprecation") - @After - protected void tearDown() throws Exception { - super.tearDown(); + @AfterClass + public static void tearDown() throws Exception { EnvironmentEdgeManagerTestHelper.reset(); } @@ -99,7 +89,7 @@ public class TestBlocksRead extends HBaseTestCase { * @return created and initialized region. */ private Region initHRegion(byte[] tableName, String callingMethod, - HBaseConfiguration conf, String family) throws IOException { + Configuration conf, String family) throws IOException { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); HColumnDescriptor familyDesc; for (int i = 0; i < BLOOM_TYPE.length; i++) { @@ -223,8 +213,7 @@ public class TestBlocksRead extends HBaseTestCase { byte[] TABLE = Bytes.toBytes("testBlocksRead"); String FAMILY = "cf1"; Cell kvs[]; - HBaseConfiguration conf = getConf(); - this.region = initHRegion(TABLE, getName(), conf, FAMILY); + this.region = initHRegion(TABLE, testName.getMethodName(), conf, FAMILY); try { putData(FAMILY, "row", "col1", 1); @@ -280,8 +269,7 @@ public class TestBlocksRead extends HBaseTestCase { byte[] TABLE = Bytes.toBytes("testLazySeekBlocksRead"); String FAMILY = "cf1"; Cell kvs[]; - HBaseConfiguration conf = getConf(); - this.region = initHRegion(TABLE, getName(), conf, FAMILY); + this.region = initHRegion(TABLE, testName.getMethodName(), conf, FAMILY); try { // File 1 @@ -388,8 +376,7 @@ public class TestBlocksRead extends HBaseTestCase { byte [] TABLE = Bytes.toBytes("testBlocksReadWhenCachingDisabled"); String FAMILY = "cf1"; - HBaseConfiguration conf = getConf(); - this.region = initHRegion(TABLE, getName(), conf, FAMILY); + this.region = initHRegion(TABLE, testName.getMethodName(), conf, FAMILY); try { putData(FAMILY, "row", "col1", 1); @@ -433,8 +420,7 @@ public class TestBlocksRead extends HBaseTestCase { byte[] TABLE = Bytes.toBytes("testLazySeekBlocksReadWithDelete"); String FAMILY = "cf1"; Cell kvs[]; - HBaseConfiguration conf = getConf(); - this.region = initHRegion(TABLE, getName(), conf, FAMILY); + this.region = initHRegion(TABLE, testName.getMethodName(), conf, FAMILY); try { deleteFamily(FAMILY, "row", 200); for (int i = 0; i < 100; i++) {