http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java index dcccfd1..91f7971 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi.java @@ -51,7 +51,6 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.JVMClusterUtil; import org.apache.hadoop.hbase.util.Threads; -import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -204,14 +203,14 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase { rs -> { ServerName serverName = rs.getServerName(); try { - Assert.assertEquals(admin.getRegions(serverName).get().size(), rs + assertEquals(admin.getRegions(serverName).get().size(), rs .getRegions().size()); } catch (Exception e) { fail("admin.getOnlineRegions() method throws a exception: " + e.getMessage()); } regionServerCount.incrementAndGet(); }); - Assert.assertEquals(regionServerCount.get(), 2); + assertEquals(2, regionServerCount.get()); } @Test @@ -229,7 +228,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase { ASYNC_CONN.getTable(tableName) .put(new Put(hri.getStartKey()).addColumn(FAMILY, FAMILY_0, Bytes.toBytes("value-1"))) .join(); - Assert.assertTrue(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreSize() > 0); + assertTrue(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreSize() > 0); // flush region and wait flush operation finished. LOG.info("flushing region: " + Bytes.toStringBinary(hri.getRegionName())); admin.flushRegion(hri.getRegionName()).get(); @@ -239,20 +238,20 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase { Threads.sleep(50); } // check the memstore. - Assert.assertEquals(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreSize(), 0); + assertEquals(0, regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreSize()); // write another put into the specific region ASYNC_CONN.getTable(tableName) .put(new Put(hri.getStartKey()).addColumn(FAMILY, FAMILY_0, Bytes.toBytes("value-2"))) .join(); - Assert.assertTrue(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreSize() > 0); + assertTrue(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreSize() > 0); admin.flush(tableName).get(); Threads.sleepWithoutInterrupt(500); while (regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreSize() > 0) { Threads.sleep(50); } // check the memstore. - Assert.assertEquals(regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreSize(), 0); + assertEquals(0, regionServer.getOnlineRegion(hri.getRegionName()).getMemStoreSize()); } @Test @@ -421,7 +420,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase { LOG.error(e.toString(), e); } } - assertEquals(count, 2); + assertEquals(2, count); } private void waitUntilMobCompactionFinished(TableName tableName) @@ -471,23 +470,23 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase { .map(rsThread -> rsThread.getRegionServer()).collect(Collectors.toList()); List<Region> regions = new ArrayList<>(); rsList.forEach(rs -> regions.addAll(rs.getRegions(tableName))); - Assert.assertEquals(regions.size(), 1); + assertEquals(1, regions.size()); int countBefore = countStoreFilesInFamilies(regions, families); - Assert.assertTrue(countBefore > 0); + assertTrue(countBefore > 0); // Minor compaction for all region servers. for (HRegionServer rs : rsList) admin.compactRegionServer(rs.getServerName()).get(); Thread.sleep(5000); int countAfterMinorCompaction = countStoreFilesInFamilies(regions, families); - Assert.assertTrue(countAfterMinorCompaction < countBefore); + assertTrue(countAfterMinorCompaction < countBefore); // Major compaction for all region servers. for (HRegionServer rs : rsList) admin.majorCompactRegionServer(rs.getServerName()).get(); Thread.sleep(5000); int countAfterMajorCompaction = countStoreFilesInFamilies(regions, families); - Assert.assertEquals(countAfterMajorCompaction, 3); + assertEquals(3, countAfterMajorCompaction); } @Test @@ -512,7 +511,7 @@ public class TestAsyncRegionAdminApi extends TestAsyncAdminBase { .getHBaseCluster() .getLiveRegionServerThreads() .forEach(rsThread -> regions.addAll(rsThread.getRegionServer().getRegions(tableName))); - Assert.assertEquals(regions.size(), 1); + assertEquals(1, regions.size()); int countBefore = countStoreFilesInFamilies(regions, families); int countBeforeSingleFamily = countStoreFilesInFamily(regions, family);
http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApiWithClusters.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApiWithClusters.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApiWithClusters.java index 9ceb172..efea20e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApiWithClusters.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncReplicationAdminApiWithClusters.java @@ -81,6 +81,7 @@ public class TestAsyncReplicationAdminApiWithClusters extends TestAsyncAdminBase ASYNC_CONN.getAdmin().addReplicationPeer(ID_SECOND, rpc).join(); } + @Override @After public void tearDown() throws Exception { Pattern pattern = Pattern.compile(tableName.getNameAsString() + ".*"); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java index 5014e96..7501192 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncSnapshotAdminApi.java @@ -18,22 +18,25 @@ package org.apache.hadoop.hbase.client; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.regex.Pattern; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.util.Bytes; import org.junit.After; -import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.regex.Pattern; - @RunWith(Parameterized.class) @Category({ LargeTests.class, ClientTests.class }) public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase { @@ -65,19 +68,19 @@ public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase { admin.snapshot(snapshotName2, tableName).get(); List<SnapshotDescription> snapshots = syncAdmin.listSnapshots(); Collections.sort(snapshots, (snap1, snap2) -> { - Assert.assertNotNull(snap1); - Assert.assertNotNull(snap1.getName()); - Assert.assertNotNull(snap2); - Assert.assertNotNull(snap2.getName()); + assertNotNull(snap1); + assertNotNull(snap1.getName()); + assertNotNull(snap2); + assertNotNull(snap2.getName()); return snap1.getName().compareTo(snap2.getName()); }); - Assert.assertEquals(snapshotName1, snapshots.get(0).getName()); - Assert.assertEquals(tableName, snapshots.get(0).getTableName()); - Assert.assertEquals(SnapshotType.FLUSH, snapshots.get(0).getType()); - Assert.assertEquals(snapshotName2, snapshots.get(1).getName()); - Assert.assertEquals(tableName, snapshots.get(1).getTableName()); - Assert.assertEquals(SnapshotType.FLUSH, snapshots.get(1).getType()); + assertEquals(snapshotName1, snapshots.get(0).getName()); + assertEquals(tableName, snapshots.get(0).getTableName()); + assertEquals(SnapshotType.FLUSH, snapshots.get(0).getType()); + assertEquals(snapshotName2, snapshots.get(1).getName()); + assertEquals(tableName, snapshots.get(1).getTableName()); + assertEquals(SnapshotType.FLUSH, snapshots.get(1).getType()); } @Test @@ -93,10 +96,10 @@ public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase { admin.snapshot(snapshotName1, tableName).get(); List<SnapshotDescription> snapshots = syncAdmin.listSnapshots(); - Assert.assertEquals(snapshots.size(), 1); - Assert.assertEquals(snapshotName1, snapshots.get(0).getName()); - Assert.assertEquals(tableName, snapshots.get(0).getTableName()); - Assert.assertEquals(SnapshotType.FLUSH, snapshots.get(0).getType()); + assertEquals(1, snapshots.size()); + assertEquals(snapshotName1, snapshots.get(0).getName()); + assertEquals(tableName, snapshots.get(0).getTableName()); + assertEquals(SnapshotType.FLUSH, snapshots.get(0).getType()); // cloneSnapshot into a existed table. boolean failed = false; @@ -105,10 +108,10 @@ public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase { } catch (Exception e) { failed = true; } - Assert.assertTrue(failed); + assertTrue(failed); // cloneSnapshot into a new table. - Assert.assertTrue(!syncAdmin.tableExists(tableName2)); + assertTrue(!syncAdmin.tableExists(tableName2)); admin.cloneSnapshot(snapshotName1, tableName2).get(); syncAdmin.tableExists(tableName2); } @@ -120,12 +123,12 @@ public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase { Result result; int rowCount = 0; while ((result = scanner.next()) != null) { - Assert.assertArrayEquals(result.getRow(), Bytes.toBytes(rowCount)); - Assert.assertArrayEquals(result.getValue(Bytes.toBytes("f1"), Bytes.toBytes("cq")), + assertArrayEquals(result.getRow(), Bytes.toBytes(rowCount)); + assertArrayEquals(result.getValue(Bytes.toBytes("f1"), Bytes.toBytes("cq")), Bytes.toBytes(rowCount)); rowCount += 1; } - Assert.assertEquals(rowCount, expectedRowCount); + assertEquals(rowCount, expectedRowCount); } } } @@ -137,11 +140,11 @@ public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase { table.put(new Put(Bytes.toBytes(i)).addColumn(Bytes.toBytes("f1"), Bytes.toBytes("cq"), Bytes.toBytes(i))); } - Assert.assertEquals(admin.listSnapshots().get().size(), 0); + assertEquals(0, admin.listSnapshots().get().size()); admin.snapshot(snapshotName1, tableName).get(); admin.snapshot(snapshotName2, tableName).get(); - Assert.assertEquals(admin.listSnapshots().get().size(), 2); + assertEquals(2, admin.listSnapshots().get().size()); admin.disableTable(tableName).get(); admin.restoreSnapshot(snapshotName1, true).get(); @@ -161,29 +164,23 @@ public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase { table.put(new Put(Bytes.toBytes(i)).addColumn(Bytes.toBytes("f1"), Bytes.toBytes("cq"), Bytes.toBytes(i))); } - Assert.assertEquals(admin.listSnapshots().get().size(), 0); + assertEquals(0, admin.listSnapshots().get().size()); admin.snapshot(snapshotName1, tableName).get(); admin.snapshot(snapshotName2, tableName).get(); admin.snapshot(snapshotName3, tableName).get(); - Assert.assertEquals(admin.listSnapshots().get().size(), 3); - - Assert.assertEquals(admin.listSnapshots(Pattern.compile("(.*)")).get().size(), 3); - Assert.assertEquals(admin.listSnapshots(Pattern.compile("snapshotName(\\d+)")).get().size(), 3); - Assert.assertEquals(admin.listSnapshots(Pattern.compile("snapshotName[1|3]")).get().size(), 2); - Assert.assertEquals(admin.listSnapshots(Pattern.compile("snapshot(.*)")).get().size(), 3); - Assert.assertEquals( - admin.listTableSnapshots(Pattern.compile("testListSnapshots"), Pattern.compile("s(.*)")).get() - .size(), - 3); - Assert.assertEquals( - admin.listTableSnapshots(Pattern.compile("fakeTableName"), Pattern.compile("snap(.*)")).get() - .size(), - 0); - Assert.assertEquals( - admin.listTableSnapshots(Pattern.compile("test(.*)"), Pattern.compile("snap(.*)[1|3]")).get() - .size(), - 2); + assertEquals(3, admin.listSnapshots().get().size()); + + assertEquals(3, admin.listSnapshots(Pattern.compile("(.*)")).get().size()); + assertEquals(3, admin.listSnapshots(Pattern.compile("snapshotName(\\d+)")).get().size()); + assertEquals(2, admin.listSnapshots(Pattern.compile("snapshotName[1|3]")).get().size()); + assertEquals(3, admin.listSnapshots(Pattern.compile("snapshot(.*)")).get().size()); + assertEquals(3, admin.listTableSnapshots(Pattern.compile("testListSnapshots"), + Pattern.compile("s(.*)")).get().size()); + assertEquals(0, admin.listTableSnapshots(Pattern.compile("fakeTableName"), + Pattern.compile("snap(.*)")).get().size()); + assertEquals(2, admin.listTableSnapshots(Pattern.compile("test(.*)"), + Pattern.compile("snap(.*)[1|3]")).get().size()); } @Test @@ -193,29 +190,29 @@ public class TestAsyncSnapshotAdminApi extends TestAsyncAdminBase { table.put(new Put(Bytes.toBytes(i)).addColumn(Bytes.toBytes("f1"), Bytes.toBytes("cq"), Bytes.toBytes(i))); } - Assert.assertEquals(admin.listSnapshots().get().size(), 0); + assertEquals(0, admin.listSnapshots().get().size()); admin.snapshot(snapshotName1, tableName).get(); admin.snapshot(snapshotName2, tableName).get(); admin.snapshot(snapshotName3, tableName).get(); - Assert.assertEquals(admin.listSnapshots().get().size(), 3); + assertEquals(3, admin.listSnapshots().get().size()); admin.deleteSnapshot(snapshotName1).get(); - Assert.assertEquals(admin.listSnapshots().get().size(), 2); + assertEquals(2, admin.listSnapshots().get().size()); admin.deleteSnapshots(Pattern.compile("(.*)abc")).get(); - Assert.assertEquals(admin.listSnapshots().get().size(), 2); + assertEquals(2, admin.listSnapshots().get().size()); admin.deleteSnapshots(Pattern.compile("(.*)1")).get(); - Assert.assertEquals(admin.listSnapshots().get().size(), 2); + assertEquals(2, admin.listSnapshots().get().size()); admin.deleteTableSnapshots(Pattern.compile("(.*)"), Pattern.compile("(.*)1")).get(); - Assert.assertEquals(admin.listSnapshots().get().size(), 2); + assertEquals(2, admin.listSnapshots().get().size()); admin.deleteTableSnapshots(Pattern.compile("(.*)"), Pattern.compile("(.*)2")).get(); - Assert.assertEquals(admin.listSnapshots().get().size(), 1); + assertEquals(1, admin.listSnapshots().get().size()); admin.deleteTableSnapshots(Pattern.compile("(.*)"), Pattern.compile("(.*)3")).get(); - Assert.assertEquals(admin.listSnapshots().get().size(), 0); + assertEquals(0, admin.listSnapshots().get().size()); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java index 529346f..8b2dce3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi.java @@ -135,7 +135,7 @@ public class TestAsyncTableAdminApi extends TestAsyncAdminBase { admin.createTable(desc).join(); ModifyableTableDescriptor modifyableDesc = ((ModifyableTableDescriptor) desc); TableDescriptor confirmedHtd = admin.getDescriptor(tableName).get(); - assertEquals(modifyableDesc.compareTo((ModifyableTableDescriptor) confirmedHtd), 0); + assertEquals(0, modifyableDesc.compareTo((ModifyableTableDescriptor) confirmedHtd)); } @Test http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableBatch.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableBatch.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableBatch.java index f47e6e9..7848251 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableBatch.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableBatch.java @@ -212,13 +212,13 @@ public class TestAsyncTableBatch { .collect(Collectors.toList())).get(); List<Row> actions = new ArrayList<>(); actions.add(new Get(Bytes.toBytes(0))); - actions.add(new Put(Bytes.toBytes(1)).addColumn(FAMILY, CQ, Bytes.toBytes((long) 2))); + actions.add(new Put(Bytes.toBytes(1)).addColumn(FAMILY, CQ, Bytes.toBytes(2L))); actions.add(new Delete(Bytes.toBytes(2))); actions.add(new Increment(Bytes.toBytes(3)).addColumn(FAMILY, CQ, 1)); actions.add(new Append(Bytes.toBytes(4)).addColumn(FAMILY, CQ, Bytes.toBytes(4))); RowMutations rm = new RowMutations(Bytes.toBytes(5)); - rm.add(new Put(Bytes.toBytes(5)).addColumn(FAMILY, CQ, Bytes.toBytes((long) 100))); - rm.add(new Put(Bytes.toBytes(5)).addColumn(FAMILY, CQ1, Bytes.toBytes((long) 200))); + rm.add(new Put(Bytes.toBytes(5)).addColumn(FAMILY, CQ, Bytes.toBytes(100L))); + rm.add(new Put(Bytes.toBytes(5)).addColumn(FAMILY, CQ1, Bytes.toBytes(200L))); actions.add(rm); actions.add(new Get(Bytes.toBytes(6))); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAvoidCellReferencesIntoShippedBlocks.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAvoidCellReferencesIntoShippedBlocks.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAvoidCellReferencesIntoShippedBlocks.java index 521d2f5..ba61ab4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAvoidCellReferencesIntoShippedBlocks.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAvoidCellReferencesIntoShippedBlocks.java @@ -189,7 +189,7 @@ public class TestAvoidCellReferencesIntoShippedBlocks { try (ResultScanner scanner = table.getScanner(s)) { count = Iterables.size(scanner); } - assertEquals("Count all the rows ", count, 6); + assertEquals("Count all the rows ", 6, count); // all the cache is loaded // trigger a major compaction ScannerThread scannerThread = new ScannerThread(table, cache); @@ -200,7 +200,7 @@ public class TestAvoidCellReferencesIntoShippedBlocks { try (ResultScanner scanner = table.getScanner(s)) { count = Iterables.size(scanner); } - assertEquals("Count all the rows ", count, 6); + assertEquals("Count all the rows ", 6, count); } finally { table.close(); } @@ -215,6 +215,7 @@ public class TestAvoidCellReferencesIntoShippedBlocks { this.cache = cache; } + @Override public void run() { Scan s = new Scan().withStartRow(ROW4).withStopRow(ROW5).setCaching(1); try { @@ -346,7 +347,7 @@ public class TestAvoidCellReferencesIntoShippedBlocks { try (ResultScanner scanner = table.getScanner(s)) { count = Iterables.size(scanner); } - assertEquals("Count all the rows ", count, 6); + assertEquals("Count all the rows ", 6, count); // Scan from cache s = new Scan(); @@ -379,7 +380,7 @@ public class TestAvoidCellReferencesIntoShippedBlocks { iterator.next(); refBlockCount++; } - assertEquals("One block should be there ", refBlockCount, 1); + assertEquals("One block should be there ", 1, refBlockCount); // Rescan to prepopulate the data // cache this row. Scan s1 = new Scan(); @@ -392,7 +393,7 @@ public class TestAvoidCellReferencesIntoShippedBlocks { try { scanner = table.getScanner(s1); int count = Iterables.size(scanner); - assertEquals("Count the rows", count, 2); + assertEquals("Count the rows", 2, count); iterator = cache.iterator(); List<BlockCacheKey> newCacheList = new ArrayList<>(); while (iterator.hasNext()) { @@ -407,7 +408,7 @@ public class TestAvoidCellReferencesIntoShippedBlocks { } } - assertEquals("old blocks should still be found ", newBlockRefCount, 6); + assertEquals("old blocks should still be found ", 6, newBlockRefCount); latch.countDown(); } catch (IOException e) { @@ -423,7 +424,7 @@ public class TestAvoidCellReferencesIntoShippedBlocks { } } } - assertEquals("Count should give all rows ", count, 10); + assertEquals("Count should give all rows ", 10, count); } finally { table.close(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java index 62eb316..9103c51 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java @@ -127,7 +127,7 @@ public class TestClientPushback { regionStats.getMemStoreLoadPercent()); // check that the load reported produces a nonzero delay long backoffTime = backoffPolicy.getBackoffTime(server, regionName, serverStats); - assertNotEquals("Reported load does not produce a backoff", backoffTime, 0); + assertNotEquals("Reported load does not produce a backoff", 0, backoffTime); LOG.debug("Backoff calculated for " + region.getRegionInfo().getRegionNameAsString() + " @ " + server + " is " + backoffTime); @@ -166,13 +166,13 @@ public class TestClientPushback { MetricsConnection.RunnerStats runnerStats = conn.getConnectionMetrics().runnerStats; - assertEquals(runnerStats.delayRunners.getCount(), 1); - assertEquals(runnerStats.normalRunners.getCount(), 1); + assertEquals(1, runnerStats.delayRunners.getCount()); + assertEquals(1, runnerStats.normalRunners.getCount()); assertEquals("", runnerStats.delayIntevalHist.getSnapshot().getMean(), (double)backoffTime, 0.1); latch.await(backoffTime * 2, TimeUnit.MILLISECONDS); - assertNotEquals("AsyncProcess did not submit the work time", endTime.get(), 0); + assertNotEquals("AsyncProcess did not submit the work time", 0, endTime.get()); assertTrue("AsyncProcess did not delay long enough", endTime.get() - startTime >= backoffTime); } http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestConnectionImplementation.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestConnectionImplementation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestConnectionImplementation.java index 2ad49f8..f061fc9 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestConnectionImplementation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestConnectionImplementation.java @@ -120,6 +120,7 @@ public class TestConnectionImplementation { TEST_UTIL.shutdownMiniCluster(); } + @Test public void testClusterConnection() throws IOException { ThreadPoolExecutor otherPool = new ThreadPoolExecutor(1, 1, 5, TimeUnit.SECONDS, @@ -636,7 +637,7 @@ public class TestConnectionImplementation { LOG.info("Put done, exception caught: " + e.getClass()); Assert.assertEquals(1, e.getNumExceptions()); Assert.assertEquals(1, e.getCauses().size()); - Assert.assertArrayEquals(e.getRow(0).getRow(), ROW); + Assert.assertArrayEquals(ROW, e.getRow(0).getRow()); // Check that we unserialized the exception as expected Throwable cause = ClientExceptionsUtil.findException(e.getCause(0)); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java index 47516ec..b2eae85 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java @@ -171,6 +171,7 @@ public class TestFastFail { * will follow the killing of a regionserver so that we make sure that * some of threads go into PreemptiveFastFailExcception */ + @Override public Boolean call() throws Exception { try (Table table = connection.getTable(TableName.valueOf(tableName))) { Thread.sleep(Math.abs(random.nextInt()) % 250); // Add some jitter here @@ -275,7 +276,7 @@ public class TestFastFail { "All the failures should be coming from the secondput failure", numFailedThreads.get(), numThreadsReturnedFalse); assertEquals("Number of threads that threw execution exceptions " - + "otherwise should be 0", numThreadsThrewExceptions, 0); + + "otherwise should be 0", 0, numThreadsThrewExceptions); assertEquals("The regionservers that returned true should equal to the" + " number of successful threads", numThreadsReturnedTrue, numSuccessfullThreads.get()); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 3af245f..952905a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java @@ -203,125 +203,123 @@ public class TestFromClientSide { /** * Basic client side validation of HBASE-4536 */ - @Test - public void testKeepDeletedCells() throws Exception { - final TableName tableName = TableName.valueOf(name.getMethodName()); - final byte[] FAMILY = Bytes.toBytes("family"); - final byte[] C0 = Bytes.toBytes("c0"); - - final byte[] T1 = Bytes.toBytes("T1"); - final byte[] T2 = Bytes.toBytes("T2"); - final byte[] T3 = Bytes.toBytes("T3"); - HColumnDescriptor hcd = new HColumnDescriptor(FAMILY) - .setKeepDeletedCells(KeepDeletedCells.TRUE) - .setMaxVersions(3); - - HTableDescriptor desc = new HTableDescriptor(tableName); - desc.addFamily(hcd); - TEST_UTIL.getAdmin().createTable(desc); - Table h = TEST_UTIL.getConnection().getTable(tableName); - - long ts = System.currentTimeMillis(); - Put p = new Put(T1, ts); - p.addColumn(FAMILY, C0, T1); - h.put(p); - p = new Put(T1, ts+2); - p.addColumn(FAMILY, C0, T2); - h.put(p); - p = new Put(T1, ts+4); - p.addColumn(FAMILY, C0, T3); - h.put(p); - - Delete d = new Delete(T1, ts+3); - h.delete(d); - - d = new Delete(T1, ts+3); - d.addColumns(FAMILY, C0, ts+3); - h.delete(d); - - Get g = new Get(T1); - // does *not* include the delete - g.setTimeRange(0, ts+3); - Result r = h.get(g); - assertArrayEquals(T2, r.getValue(FAMILY, C0)); - - Scan s = new Scan(T1); - s.setTimeRange(0, ts+3); - s.setMaxVersions(); - ResultScanner scanner = h.getScanner(s); - Cell[] kvs = scanner.next().rawCells(); - assertArrayEquals(T2, CellUtil.cloneValue(kvs[0])); - assertArrayEquals(T1, CellUtil.cloneValue(kvs[1])); - scanner.close(); - - s = new Scan(T1); - s.setRaw(true); - s.setMaxVersions(); - scanner = h.getScanner(s); - kvs = scanner.next().rawCells(); - assertTrue(PrivateCellUtil.isDeleteFamily(kvs[0])); - assertArrayEquals(T3, CellUtil.cloneValue(kvs[1])); - assertTrue(CellUtil.isDelete(kvs[2])); - assertArrayEquals(T2, CellUtil.cloneValue(kvs[3])); - assertArrayEquals(T1, CellUtil.cloneValue(kvs[4])); - scanner.close(); - h.close(); - } - - /** - * Basic client side validation of HBASE-10118 - */ - @Test - public void testPurgeFutureDeletes() throws Exception { - final TableName tableName = TableName.valueOf(name.getMethodName()); - final byte[] ROW = Bytes.toBytes("row"); - final byte[] FAMILY = Bytes.toBytes("family"); - final byte[] COLUMN = Bytes.toBytes("column"); - final byte[] VALUE = Bytes.toBytes("value"); - - Table table = TEST_UTIL.createTable(tableName, FAMILY); - - // future timestamp - long ts = System.currentTimeMillis() * 2; - Put put = new Put(ROW, ts); - put.addColumn(FAMILY, COLUMN, VALUE); - table.put(put); - - Get get = new Get(ROW); - Result result = table.get(get); - assertArrayEquals(VALUE, result.getValue(FAMILY, COLUMN)); - - Delete del = new Delete(ROW); - del.addColumn(FAMILY, COLUMN, ts); - table.delete(del); - - get = new Get(ROW); - result = table.get(get); - assertNull(result.getValue(FAMILY, COLUMN)); - - // major compaction, purged future deletes - TEST_UTIL.getAdmin().flush(tableName); - TEST_UTIL.getAdmin().majorCompact(tableName); - - // waiting for the major compaction to complete - TEST_UTIL.waitFor(6000, new Waiter.Predicate<IOException>() { - @Override - public boolean evaluate() throws IOException { - return TEST_UTIL.getAdmin().getCompactionState(tableName) == - CompactionState.NONE; - } - }); - - put = new Put(ROW, ts); - put.addColumn(FAMILY, COLUMN, VALUE); - table.put(put); - - get = new Get(ROW); - result = table.get(get); - assertArrayEquals(VALUE, result.getValue(FAMILY, COLUMN)); - - table.close(); - } + @Test + public void testKeepDeletedCells() throws Exception { + final TableName tableName = TableName.valueOf(name.getMethodName()); + final byte[] FAMILY = Bytes.toBytes("family"); + final byte[] C0 = Bytes.toBytes("c0"); + + final byte[] T1 = Bytes.toBytes("T1"); + final byte[] T2 = Bytes.toBytes("T2"); + final byte[] T3 = Bytes.toBytes("T3"); + HColumnDescriptor hcd = + new HColumnDescriptor(FAMILY).setKeepDeletedCells(KeepDeletedCells.TRUE).setMaxVersions(3); + + HTableDescriptor desc = new HTableDescriptor(tableName); + desc.addFamily(hcd); + TEST_UTIL.getAdmin().createTable(desc); + Table h = TEST_UTIL.getConnection().getTable(tableName); + + long ts = System.currentTimeMillis(); + Put p = new Put(T1, ts); + p.addColumn(FAMILY, C0, T1); + h.put(p); + p = new Put(T1, ts + 2); + p.addColumn(FAMILY, C0, T2); + h.put(p); + p = new Put(T1, ts + 4); + p.addColumn(FAMILY, C0, T3); + h.put(p); + + Delete d = new Delete(T1, ts + 3); + h.delete(d); + + d = new Delete(T1, ts + 3); + d.addColumns(FAMILY, C0, ts + 3); + h.delete(d); + + Get g = new Get(T1); + // does *not* include the delete + g.setTimeRange(0, ts + 3); + Result r = h.get(g); + assertArrayEquals(T2, r.getValue(FAMILY, C0)); + + Scan s = new Scan(T1); + s.setTimeRange(0, ts + 3); + s.setMaxVersions(); + ResultScanner scanner = h.getScanner(s); + Cell[] kvs = scanner.next().rawCells(); + assertArrayEquals(T2, CellUtil.cloneValue(kvs[0])); + assertArrayEquals(T1, CellUtil.cloneValue(kvs[1])); + scanner.close(); + + s = new Scan(T1); + s.setRaw(true); + s.setMaxVersions(); + scanner = h.getScanner(s); + kvs = scanner.next().rawCells(); + assertTrue(PrivateCellUtil.isDeleteFamily(kvs[0])); + assertArrayEquals(T3, CellUtil.cloneValue(kvs[1])); + assertTrue(CellUtil.isDelete(kvs[2])); + assertArrayEquals(T2, CellUtil.cloneValue(kvs[3])); + assertArrayEquals(T1, CellUtil.cloneValue(kvs[4])); + scanner.close(); + h.close(); + } + + /** + * Basic client side validation of HBASE-10118 + */ + @Test + public void testPurgeFutureDeletes() throws Exception { + final TableName tableName = TableName.valueOf(name.getMethodName()); + final byte[] ROW = Bytes.toBytes("row"); + final byte[] FAMILY = Bytes.toBytes("family"); + final byte[] COLUMN = Bytes.toBytes("column"); + final byte[] VALUE = Bytes.toBytes("value"); + + Table table = TEST_UTIL.createTable(tableName, FAMILY); + + // future timestamp + long ts = System.currentTimeMillis() * 2; + Put put = new Put(ROW, ts); + put.addColumn(FAMILY, COLUMN, VALUE); + table.put(put); + + Get get = new Get(ROW); + Result result = table.get(get); + assertArrayEquals(VALUE, result.getValue(FAMILY, COLUMN)); + + Delete del = new Delete(ROW); + del.addColumn(FAMILY, COLUMN, ts); + table.delete(del); + + get = new Get(ROW); + result = table.get(get); + assertNull(result.getValue(FAMILY, COLUMN)); + + // major compaction, purged future deletes + TEST_UTIL.getAdmin().flush(tableName); + TEST_UTIL.getAdmin().majorCompact(tableName); + + // waiting for the major compaction to complete + TEST_UTIL.waitFor(6000, new Waiter.Predicate<IOException>() { + @Override + public boolean evaluate() throws IOException { + return TEST_UTIL.getAdmin().getCompactionState(tableName) == CompactionState.NONE; + } + }); + + put = new Put(ROW, ts); + put.addColumn(FAMILY, COLUMN, VALUE); + table.put(put); + + get = new Get(ROW); + result = table.get(get); + assertArrayEquals(VALUE, result.getValue(FAMILY, COLUMN)); + + table.close(); + } /** * Verifies that getConfiguration returns the same Configuration object used @@ -660,13 +658,13 @@ public class TestFromClientSide { ResultScanner scanner = ht.getScanner(scan); int expectedIndex = 1; for(Result result : ht.getScanner(scan)) { - assertEquals(result.size(), 1); + assertEquals(1, result.size()); assertTrue(Bytes.equals(CellUtil.cloneRow(result.rawCells()[0]), ROWS[expectedIndex])); assertTrue(Bytes.equals(CellUtil.cloneQualifier(result.rawCells()[0]), QUALIFIERS[expectedIndex])); expectedIndex++; } - assertEquals(expectedIndex, 6); + assertEquals(6, expectedIndex); scanner.close(); } @@ -693,11 +691,11 @@ public class TestFromClientSide { ResultScanner scanner = ht.getScanner(scan); int expectedIndex = 0; for(Result result : ht.getScanner(scan)) { - assertEquals(result.size(), 1); + assertEquals(1, result.size()); assertTrue(Bytes.toLong(result.getValue(FAMILY, QUALIFIER)) > 500); expectedIndex++; } - assertEquals(expectedIndex, 4); + assertEquals(4, expectedIndex); scanner.close(); } @@ -726,12 +724,12 @@ public class TestFromClientSide { ResultScanner scanner = ht.getScanner(scan); int count = 0; for(Result result : ht.getScanner(scan)) { - assertEquals(result.size(), 1); - assertEquals(result.rawCells()[0].getValueLength(), Bytes.SIZEOF_INT); - assertEquals(Bytes.toInt(CellUtil.cloneValue(result.rawCells()[0])), VALUE.length); + assertEquals(1, result.size()); + assertEquals(Bytes.SIZEOF_INT, result.rawCells()[0].getValueLength()); + assertEquals(VALUE.length, Bytes.toInt(CellUtil.cloneValue(result.rawCells()[0]))); count++; } - assertEquals(count, 10); + assertEquals(10, count); scanner.close(); } @@ -3499,7 +3497,9 @@ public class TestFromClientSide { private long [] makeStamps(int n) { long [] stamps = new long[n]; - for(int i=0;i<n;i++) stamps[i] = i+1; + for (int i = 0; i < n; i++) { + stamps[i] = i+1L; + } return stamps; } @@ -3969,8 +3969,8 @@ public class TestFromClientSide { put = new Put(row2); put.addColumn(CONTENTS_FAMILY, null, value); - assertEquals(put.size(), 1); - assertEquals(put.getFamilyCellMap().get(CONTENTS_FAMILY).size(), 1); + assertEquals(1, put.size()); + assertEquals(1, put.getFamilyCellMap().get(CONTENTS_FAMILY).size()); // KeyValue v1 expectation. Cast for now until we go all Cell all the time. TODO KeyValue kv = (KeyValue)put.getFamilyCellMap().get(CONTENTS_FAMILY).get(0); @@ -4794,22 +4794,22 @@ public class TestFromClientSide { // row doesn't exist, so using non-null value should be considered "not match". boolean ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifEquals(VALUE).thenPut(put1); - assertEquals(ok, false); + assertFalse(ok); // row doesn't exist, so using "ifNotExists" should be considered "match". ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER).ifNotExists().thenPut(put1); - assertEquals(ok, true); + assertTrue(ok); // row now exists, so using "ifNotExists" should be considered "not match". ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER).ifNotExists().thenPut(put1); - assertEquals(ok, false); + assertFalse(ok); Put put2 = new Put(ROW); put2.addColumn(FAMILY, QUALIFIER, value2); // row now exists, use the matching value to check ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER).ifEquals(VALUE).thenPut(put2); - assertEquals(ok, true); + assertTrue(ok); Put put3 = new Put(anotherrow); put3.addColumn(FAMILY, QUALIFIER, VALUE); @@ -4839,70 +4839,70 @@ public class TestFromClientSide { // row doesn't exist, so using "ifNotExists" should be considered "match". boolean ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER).ifNotExists().thenPut(put2); - assertEquals(ok, true); + assertTrue(ok); // cell = "bbbb", using "aaaa" to compare only LESS/LESS_OR_EQUAL/NOT_EQUAL // turns out "match" ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER, value1).thenPut(put2); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.EQUAL, value1).thenPut(put2); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER_OR_EQUAL, value1).thenPut(put2); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS, value1).thenPut(put2); - assertEquals(ok, true); + assertTrue(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS_OR_EQUAL, value1).thenPut(put2); - assertEquals(ok, true); + assertTrue(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.NOT_EQUAL, value1).thenPut(put3); - assertEquals(ok, true); + assertTrue(ok); // cell = "cccc", using "dddd" to compare only LARGER/LARGER_OR_EQUAL/NOT_EQUAL // turns out "match" ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS, value4).thenPut(put3); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS_OR_EQUAL, value4).thenPut(put3); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.EQUAL, value4).thenPut(put3); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER, value4).thenPut(put3); - assertEquals(ok, true); + assertTrue(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER_OR_EQUAL, value4).thenPut(put3); - assertEquals(ok, true); + assertTrue(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.NOT_EQUAL, value4).thenPut(put2); - assertEquals(ok, true); + assertTrue(ok); // cell = "bbbb", using "bbbb" to compare only GREATER_OR_EQUAL/LESS_OR_EQUAL/EQUAL // turns out "match" ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER, value2).thenPut(put2); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.NOT_EQUAL, value2).thenPut(put2); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS, value2).thenPut(put2); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER_OR_EQUAL, value2).thenPut(put2); - assertEquals(ok, true); + assertTrue(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS_OR_EQUAL, value2).thenPut(put2); - assertEquals(ok, true); + assertTrue(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.EQUAL, value2).thenPut(put3); - assertEquals(ok, true); + assertTrue(ok); } @Test @@ -4921,7 +4921,7 @@ public class TestFromClientSide { boolean ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifEquals(value1).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); } @Test @@ -4948,72 +4948,72 @@ public class TestFromClientSide { // turns out "match" boolean ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER, value1).thenDelete(delete); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.EQUAL, value1).thenDelete(delete); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER_OR_EQUAL, value1).thenDelete(delete); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS, value1).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); table.put(put2); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS_OR_EQUAL, value1).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); table.put(put2); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.NOT_EQUAL, value1).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); // cell = "cccc", using "dddd" to compare only LARGER/LARGER_OR_EQUAL/NOT_EQUAL // turns out "match" table.put(put3); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS, value4).thenDelete(delete); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS_OR_EQUAL, value4).thenDelete(delete); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.EQUAL, value4).thenDelete(delete); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER, value4).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); table.put(put3); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER_OR_EQUAL, value4).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); table.put(put3); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.NOT_EQUAL, value4).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); // cell = "bbbb", using "bbbb" to compare only GREATER_OR_EQUAL/LESS_OR_EQUAL/EQUAL // turns out "match" table.put(put2); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER, value2).thenDelete(delete); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.NOT_EQUAL, value2).thenDelete(delete); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS, value2).thenDelete(delete); - assertEquals(ok, false); + assertFalse(ok); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.GREATER_OR_EQUAL, value2).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); table.put(put2); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.LESS_OR_EQUAL, value2).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); table.put(put2); ok = table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER) .ifMatches(CompareOperator.EQUAL, value2).thenDelete(delete); - assertEquals(ok, true); + assertTrue(ok); } /** @@ -5726,7 +5726,7 @@ public class TestFromClientSide { ResultScanner scanner = ht.getScanner(scan); int expectedIndex = 5; for (Result result : scanner) { - assertEquals(result.size(), 1); + assertEquals(1, result.size()); Cell c = result.rawCells()[0]; assertTrue(Bytes.equals(c.getRowArray(), c.getRowOffset(), c.getRowLength(), ROWS[expectedIndex], 0, ROWS[expectedIndex].length)); @@ -5734,7 +5734,7 @@ public class TestFromClientSide { c.getQualifierLength(), QUALIFIERS[expectedIndex], 0, QUALIFIERS[expectedIndex].length)); expectedIndex--; } - assertEquals(expectedIndex, 0); + assertEquals(0, expectedIndex); scanner.close(); ht.close(); } @@ -5767,12 +5767,12 @@ public class TestFromClientSide { ResultScanner scanner = ht.getScanner(scan); int count = 0; for (Result result : ht.getScanner(scan)) { - assertEquals(result.size(), 1); - assertEquals(result.rawCells()[0].getValueLength(), Bytes.SIZEOF_INT); - assertEquals(Bytes.toInt(CellUtil.cloneValue(result.rawCells()[0])), VALUE.length); + assertEquals(1, result.size()); + assertEquals(Bytes.SIZEOF_INT, result.rawCells()[0].getValueLength()); + assertEquals(VALUE.length, Bytes.toInt(CellUtil.cloneValue(result.rawCells()[0]))); count++; } - assertEquals(count, 10); + assertEquals(10, count); scanner.close(); ht.close(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java index 2d67b3e..6b031d8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java @@ -19,6 +19,12 @@ */ package org.apache.hadoop.hbase.client; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -35,37 +41,30 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.Coprocessor; -import org.apache.hadoop.hbase.coprocessor.ObserverContext; -import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor; -import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; -import org.apache.hadoop.hbase.coprocessor.RegionObserver; -import org.apache.hadoop.hbase.regionserver.HRegionServer; -import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.regionserver.RegionScanner; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint; +import org.apache.hadoop.hbase.coprocessor.ObserverContext; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; +import org.apache.hadoop.hbase.coprocessor.RegionObserver; import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils; import org.apache.hadoop.hbase.ipc.ServerRpcController; import org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos; import org.apache.hadoop.hbase.regionserver.HRegion; -import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; -import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos; +import org.apache.hadoop.hbase.regionserver.HRegionServer; +import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress; +import org.apache.hadoop.hbase.regionserver.RegionScanner; import org.apache.hadoop.hbase.testclassification.ClientTests; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Pair; import org.junit.After; import org.junit.AfterClass; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; @@ -75,6 +74,9 @@ import org.junit.rules.TestName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; +import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos; + @Category({LargeTests.class, ClientTests.class}) public class TestFromClientSide3 { private static final Logger LOG = LoggerFactory.getLogger(TestFromClientSide3.class); @@ -497,12 +499,12 @@ public class TestFromClientSide3 { Get get = new Get(ROW); boolean exist = table.exists(get); - assertEquals(exist, false); + assertFalse(exist); table.put(put); exist = table.exists(get); - assertEquals(exist, true); + assertTrue(exist); } @Test @@ -589,12 +591,12 @@ public class TestFromClientSide3 { Get get = new Get(ROW); boolean exist = table.exists(get); - assertEquals(exist, false); + assertFalse(exist); table.put(put); exist = table.exists(get); - assertEquals(exist, true); + assertTrue(exist); } @Test @@ -614,10 +616,10 @@ public class TestFromClientSide3 { LOG.info("Calling exists"); boolean[] results = table.existsAll(gets); - assertEquals(results[0], false); - assertEquals(results[1], false); - assertEquals(results[2], true); - assertEquals(results[3], false); + assertFalse(results[0]); + assertFalse(results[1]); + assertTrue(results[2]); + assertFalse(results[3]); // Test with the first region. put = new Put(new byte[] { 0x00 }); @@ -628,8 +630,8 @@ public class TestFromClientSide3 { gets.add(new Get(new byte[] { 0x00 })); gets.add(new Get(new byte[] { 0x00, 0x00 })); results = table.existsAll(gets); - assertEquals(results[0], true); - assertEquals(results[1], false); + assertTrue(results[0]); + assertFalse(results[1]); // Test with the last region put = new Put(new byte[] { (byte) 0xff, (byte) 0xff }); @@ -641,9 +643,9 @@ public class TestFromClientSide3 { gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff })); gets.add(new Get(new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff })); results = table.existsAll(gets); - assertEquals(results[0], false); - assertEquals(results[1], true); - assertEquals(results[2], false); + assertFalse(results[0]); + assertTrue(results[1]); + assertFalse(results[2]); } @Test http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaCache.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaCache.java index 093400e..3f618a1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaCache.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaCache.java @@ -279,16 +279,19 @@ public class TestMetaCache { private int expCount = -1; private List<Throwable> metaCachePreservingExceptions = metaCachePreservingExceptions(); + @Override public void throwOnGet(FakeRSRpcServices rpcServices, ClientProtos.GetRequest request) throws ServiceException { throwSomeExceptions(rpcServices, request.getRegion()); } + @Override public void throwOnMutate(FakeRSRpcServices rpcServices, ClientProtos.MutateRequest request) throws ServiceException { throwSomeExceptions(rpcServices, request.getRegion()); } + @Override public void throwOnScan(FakeRSRpcServices rpcServices, ClientProtos.ScanRequest request) throws ServiceException { if (!request.hasScannerId()) { http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultipleTimestamps.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultipleTimestamps.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultipleTimestamps.java index ee39a83..d73ebc0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultipleTimestamps.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultipleTimestamps.java @@ -180,7 +180,7 @@ public class TestMultipleTimestamps { Integer[] scanRows = new Integer[] {5, 7}; Integer[] scanColumns = new Integer[] {3, 4, 5}; - Long[] scanTimestamps = new Long[] {2l, 3L}; + Long[] scanTimestamps = new Long[] { 2L, 3L}; int scanMaxVersions = 2; put(ht, FAMILY, putRows, putColumns, putTimestamps); @@ -241,7 +241,7 @@ public class TestMultipleTimestamps { Integer[] scanRows = new Integer[] {3, 5, 7}; Integer[] scanColumns = new Integer[] {3, 4, 5}; - Long[] scanTimestamps = new Long[] {2l, 4L}; + Long[] scanTimestamps = new Long[] { 2L, 4L}; int scanMaxVersions = 5; put(ht, FAMILY, putRows1, putColumns1, putTimestamps1); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java index a06055d..f5ea10e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestReplicasClient.java @@ -261,9 +261,9 @@ public class TestReplicasClient { AdminProtos.OpenRegionRequest orr = RequestConverter.buildOpenRegionRequest( getRS().getServerName(), hri, null); AdminProtos.OpenRegionResponse responseOpen = getRS().getRSRpcServices().openRegion(null, orr); - Assert.assertEquals(responseOpen.getOpeningStateCount(), 1); - Assert.assertEquals(responseOpen.getOpeningState(0), - AdminProtos.OpenRegionResponse.RegionOpeningState.OPENED); + Assert.assertEquals(1, responseOpen.getOpeningStateCount()); + Assert.assertEquals(AdminProtos.OpenRegionResponse.RegionOpeningState.OPENED, + responseOpen.getOpeningState(0)); checkRegionIsOpened(hri); } @@ -583,8 +583,8 @@ public class TestReplicasClient { r = table.get(g); Assert.assertFalse(r.isStale()); Assert.assertFalse(r.getColumnCells(f, b1).isEmpty()); - Assert.assertEquals(hedgedReadOps.getCount(), 1); - Assert.assertEquals(hedgedReadWin.getCount(), 0); + Assert.assertEquals(1, hedgedReadOps.getCount()); + Assert.assertEquals(0, hedgedReadWin.getCount()); SlowMeCopro.sleepTime.set(0); SlowMeCopro.getSecondaryCdl().get().countDown(); LOG.info("hedged read occurred but not faster"); @@ -597,8 +597,8 @@ public class TestReplicasClient { r = table.get(g); Assert.assertTrue(r.isStale()); Assert.assertTrue(r.getColumnCells(f, b1).isEmpty()); - Assert.assertEquals(hedgedReadOps.getCount(), 2); - Assert.assertEquals(hedgedReadWin.getCount(), 1); + Assert.assertEquals(2, hedgedReadOps.getCount()); + Assert.assertEquals(1, hedgedReadWin.getCount()); SlowMeCopro.getPrimaryCdl().get().countDown(); LOG.info("hedged read occurred and faster"); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java index 3190fb9..fe1cc9c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRestoreSnapshotFromClient.java @@ -205,7 +205,7 @@ public class TestRestoreSnapshotFromClient { HTableDescriptor htd = admin.getTableDescriptor(tableName); assertEquals(2, htd.getFamilies().size()); SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, TEST_FAMILY2); - long snapshot2Rows = snapshot1Rows + 500; + long snapshot2Rows = snapshot1Rows + 500L; assertEquals(snapshot2Rows, countRows(table)); assertEquals(500, countRows(table, TEST_FAMILY2)); Set<String> fsFamilies = getFamiliesFromFS(tableName); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java index 3335298..b494895 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java @@ -194,7 +194,7 @@ public class TestResult extends TestCase { loadValueBuffer.clear(); r.loadValue(family, qf, loadValueBuffer); loadValueBuffer.flip(); - assertEquals(ByteBuffer.wrap(Bytes.add(value, Bytes.toBytes(i))), loadValueBuffer); + assertEquals(loadValueBuffer, ByteBuffer.wrap(Bytes.add(value, Bytes.toBytes(i)))); assertEquals(ByteBuffer.wrap(Bytes.add(value, Bytes.toBytes(i))), r.getValueAsByteBuffer(family, qf)); } @@ -219,7 +219,7 @@ public class TestResult extends TestCase { loadValueBuffer.clear(); r.loadValue(family, qf, loadValueBuffer); loadValueBuffer.flip(); - assertEquals(ByteBuffer.wrap(Bytes.add(value, Bytes.toBytes(i))), loadValueBuffer); + assertEquals(loadValueBuffer, ByteBuffer.wrap(Bytes.add(value, Bytes.toBytes(i)))); assertEquals(ByteBuffer.wrap(Bytes.add(value, Bytes.toBytes(i))), r.getValueAsByteBuffer(family, qf)); } http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestServerBusyException.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestServerBusyException.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestServerBusyException.java index b1126e5..387253c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestServerBusyException.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestServerBusyException.java @@ -142,7 +142,7 @@ public class TestServerBusyException { TEST_UTIL.shutdownMiniCluster(); } - private class TestPutThread extends Thread { + private static class TestPutThread extends Thread { Table table; int getServerBusyException = 0; @@ -163,7 +163,7 @@ public class TestServerBusyException { } } - private class TestGetThread extends Thread { + private static class TestGetThread extends Thread { Table table; int getServerBusyException = 0; http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSizeFailures.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSizeFailures.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSizeFailures.java index 84bfa76..41e3034 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSizeFailures.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSizeFailures.java @@ -160,8 +160,8 @@ public class TestSizeFailures { * @return An entry where the first item is rows observed and the second is entries observed. */ private Entry<Long,Long> sumTable(ResultScanner scanner) { - long rowsObserved = 0l; - long entriesObserved = 0l; + long rowsObserved = 0L; + long entriesObserved = 0L; // Read all the records in the table for (Result result : scanner) { http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSmallReversedScanner.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSmallReversedScanner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSmallReversedScanner.java index b050397..4de6a76 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSmallReversedScanner.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSmallReversedScanner.java @@ -105,7 +105,7 @@ public class TestSmallReversedScanner { Assert.assertArrayEquals(r.getRow(), Bytes.toBytes(inputRowKeys[value])); } - Assert.assertEquals(value, 0); + Assert.assertEquals(0, value); } /** @@ -133,6 +133,6 @@ public class TestSmallReversedScanner { Assert.assertArrayEquals(r.getRow(), new byte[] { (char) 0x00 }); Assert.assertTrue(--count >= 0); } - Assert.assertEquals(count, 0); + Assert.assertEquals(0, count); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotFromClient.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotFromClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotFromClient.java index 1127a5e..b077d64 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotFromClient.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotFromClient.java @@ -185,7 +185,7 @@ public class TestSnapshotFromClient { admin.deleteSnapshots(Pattern.compile("TableSnapshot.*")); List<SnapshotDescription> snapshots = admin.listSnapshots(); assertEquals(1, snapshots.size()); - assertEquals(snapshots.get(0).getName(), snapshot3); + assertEquals(snapshot3, snapshots.get(0).getName()); admin.deleteSnapshot(snapshot3); admin.close(); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java index 49c6560..fa3715d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java @@ -212,8 +212,8 @@ public class TestSnapshotMetadata { cloneHtd.getValues().size()); assertEquals(originalTableDescriptor.getConfiguration().size(), cloneHtd.getConfiguration().size()); - assertEquals(cloneHtd.getValue(TEST_CUSTOM_VALUE), TEST_CUSTOM_VALUE); - assertEquals(cloneHtd.getConfigurationValue(TEST_CONF_CUSTOM_VALUE), TEST_CONF_CUSTOM_VALUE); + assertEquals(TEST_CUSTOM_VALUE, cloneHtd.getValue(TEST_CUSTOM_VALUE)); + assertEquals(TEST_CONF_CUSTOM_VALUE, cloneHtd.getConfigurationValue(TEST_CONF_CUSTOM_VALUE)); assertEquals(originalTableDescriptor.getValues(), cloneHtd.getValues()); assertEquals(originalTableDescriptor.getConfiguration(), cloneHtd.getConfiguration()); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotWithAcl.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotWithAcl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotWithAcl.java index df2a6e8..9e543dc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotWithAcl.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotWithAcl.java @@ -177,7 +177,7 @@ public class TestSnapshotWithAcl extends SecureTestUtil { byte[] value = result.getValue(TEST_FAMILY, TEST_QUALIFIER); Assert.assertArrayEquals(value, Bytes.toBytes(rowCount++)); } - Assert.assertEquals(rowCount, ROW_COUNT); + Assert.assertEquals(ROW_COUNT, rowCount); } } } http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java index 678134b..d239eb8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSplitOrMergeStatus.java @@ -80,13 +80,13 @@ public class TestSplitOrMergeStatus { Admin admin = TEST_UTIL.getAdmin(); initSwitchStatus(admin); boolean[] results = admin.setSplitOrMergeEnabled(false, false, MasterSwitchType.SPLIT); - assertEquals(results.length, 1); + assertEquals(1, results.length); assertTrue(results[0]); admin.split(t.getName()); int count = admin.getTableRegions(tableName).size(); assertTrue(originalCount == count); results = admin.setSplitOrMergeEnabled(true, false, MasterSwitchType.SPLIT); - assertEquals(results.length, 1); + assertEquals(1, results.length); assertFalse(results[0]); admin.split(t.getName()); while ((count = admin.getTableRegions(tableName).size()) == originalCount) { @@ -117,7 +117,7 @@ public class TestSplitOrMergeStatus { // Merge switch is off so merge should NOT succeed. boolean[] results = admin.setSplitOrMergeEnabled(false, false, MasterSwitchType.MERGE); - assertEquals(results.length, 1); + assertEquals(1, results.length); assertTrue(results[0]); List<HRegionInfo> regions = admin.getTableRegions(t.getName()); assertTrue(regions.size() > 1); @@ -134,7 +134,7 @@ public class TestSplitOrMergeStatus { results = admin.setSplitOrMergeEnabled(true, false, MasterSwitchType.MERGE); regions = admin.getTableRegions(t.getName()); - assertEquals(results.length, 1); + assertEquals(1, results.length); assertFalse(results[0]); f = admin.mergeRegionsAsync(regions.get(0).getEncodedNameAsBytes(), regions.get(1).getEncodedNameAsBytes(), true); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java index 89af5de..ea60ec2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java @@ -181,15 +181,15 @@ public class TestTimestampsFilter { Table ht = TEST_UTIL.createTable(TableName.valueOf(TABLE), FAMILIES, Integer.MAX_VALUE); Put p = new Put(Bytes.toBytes("row")); - p.addColumn(FAMILY, Bytes.toBytes("column0"), (long) 3, Bytes.toBytes("value0-3")); - p.addColumn(FAMILY, Bytes.toBytes("column1"), (long) 3, Bytes.toBytes("value1-3")); - p.addColumn(FAMILY, Bytes.toBytes("column2"), (long) 1, Bytes.toBytes("value2-1")); - p.addColumn(FAMILY, Bytes.toBytes("column2"), (long) 2, Bytes.toBytes("value2-2")); - p.addColumn(FAMILY, Bytes.toBytes("column2"), (long) 3, Bytes.toBytes("value2-3")); - p.addColumn(FAMILY, Bytes.toBytes("column3"), (long) 2, Bytes.toBytes("value3-2")); - p.addColumn(FAMILY, Bytes.toBytes("column4"), (long) 1, Bytes.toBytes("value4-1")); - p.addColumn(FAMILY, Bytes.toBytes("column4"), (long) 2, Bytes.toBytes("value4-2")); - p.addColumn(FAMILY, Bytes.toBytes("column4"), (long) 3, Bytes.toBytes("value4-3")); + p.addColumn(FAMILY, Bytes.toBytes("column0"), 3L, Bytes.toBytes("value0-3")); + p.addColumn(FAMILY, Bytes.toBytes("column1"), 3L, Bytes.toBytes("value1-3")); + p.addColumn(FAMILY, Bytes.toBytes("column2"), 1L, Bytes.toBytes("value2-1")); + p.addColumn(FAMILY, Bytes.toBytes("column2"), 2L, Bytes.toBytes("value2-2")); + p.addColumn(FAMILY, Bytes.toBytes("column2"), 3L, Bytes.toBytes("value2-3")); + p.addColumn(FAMILY, Bytes.toBytes("column3"), 2L, Bytes.toBytes("value3-2")); + p.addColumn(FAMILY, Bytes.toBytes("column4"), 1L, Bytes.toBytes("value4-1")); + p.addColumn(FAMILY, Bytes.toBytes("column4"), 2L, Bytes.toBytes("value4-2")); + p.addColumn(FAMILY, Bytes.toBytes("column4"), 3L, Bytes.toBytes("value4-3")); ht.put(p); ArrayList<Long> timestamps = new ArrayList<>(); @@ -209,7 +209,7 @@ public class TestTimestampsFilter { + Bytes.toString(CellUtil.cloneValue(kv))); } - assertEquals(result.listCells().size(), 2); + assertEquals(2, result.listCells().size()); assertTrue(CellUtil.matchingValue(result.listCells().get(0), Bytes.toBytes("value2-3"))); assertTrue(CellUtil.matchingValue(result.listCells().get(1), Bytes.toBytes("value4-3"))); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java index 6511a42..3f4029a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java @@ -70,7 +70,7 @@ public class TestUpdateConfiguration { admin.updateConfiguration(server); Configuration conf = TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration(); int custom = conf.getInt("hbase.custom.config", 0); - assertEquals(custom, 1000); + assertEquals(1000, custom); // restore hbase-site.xml Files.copy(cnf3Path, cnfPath, StandardCopyOption.REPLACE_EXISTING); } @@ -97,17 +97,20 @@ public class TestUpdateConfiguration { admin.updateConfiguration(); // Check the configuration of the Masters - Configuration masterConfiguration = TEST_UTIL.getMiniHBaseCluster().getMaster(0).getConfiguration(); + Configuration masterConfiguration = + TEST_UTIL.getMiniHBaseCluster().getMaster(0).getConfiguration(); int custom = masterConfiguration.getInt("hbase.custom.config", 0); - assertEquals(custom, 1000); - Configuration backupMasterConfiguration = TEST_UTIL.getMiniHBaseCluster().getMaster(1).getConfiguration(); + assertEquals(1000, custom); + Configuration backupMasterConfiguration = + TEST_UTIL.getMiniHBaseCluster().getMaster(1).getConfiguration(); custom = backupMasterConfiguration.getInt("hbase.custom.config", 0); - assertEquals(custom, 1000); + assertEquals(1000, custom); // Check the configuration of the RegionServer - Configuration regionServerConfiguration = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0).getConfiguration(); + Configuration regionServerConfiguration = + TEST_UTIL.getMiniHBaseCluster().getRegionServer(0).getConfiguration(); custom = regionServerConfiguration.getInt("hbase.custom.config", 0); - assertEquals(custom, 1000); + assertEquals(1000, custom); // restore hbase-site.xml Files.copy(cnf3Path, cnfPath, StandardCopyOption.REPLACE_EXISTING); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java index 3b7fd84..82eda2a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdminWithClusters.java @@ -88,7 +88,7 @@ public class TestReplicationAdminWithClusters extends TestReplicationBase { admin1.disableTableReplication(tableName); table = admin1.getTableDescriptor(tableName); for (HColumnDescriptor fam : table.getColumnFamilies()) { - assertEquals(fam.getScope(), HConstants.REPLICATION_SCOPE_LOCAL); + assertEquals(HConstants.REPLICATION_SCOPE_LOCAL, fam.getScope()); } } @@ -119,7 +119,7 @@ public class TestReplicationAdminWithClusters extends TestReplicationBase { admin1.enableTableReplication(tableName); table = admin1.getTableDescriptor(tableName); for (HColumnDescriptor fam : table.getColumnFamilies()) { - assertEquals(fam.getScope(), HConstants.REPLICATION_SCOPE_GLOBAL); + assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope()); } } @@ -144,7 +144,7 @@ public class TestReplicationAdminWithClusters extends TestReplicationBase { admin1.enableTableReplication(tableName); table = admin1.getTableDescriptor(tableName); for (HColumnDescriptor fam : table.getColumnFamilies()) { - assertEquals(fam.getScope(), HConstants.REPLICATION_SCOPE_GLOBAL); + assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope()); } } @@ -153,12 +153,12 @@ public class TestReplicationAdminWithClusters extends TestReplicationBase { admin1.disableTableReplication(tableName); HTableDescriptor table = admin1.getTableDescriptor(tableName); for (HColumnDescriptor fam : table.getColumnFamilies()) { - assertEquals(fam.getScope(), HConstants.REPLICATION_SCOPE_LOCAL); + assertEquals(HConstants.REPLICATION_SCOPE_LOCAL, fam.getScope()); } admin1.enableTableReplication(tableName); table = admin1.getTableDescriptor(tableName); for (HColumnDescriptor fam : table.getColumnFamilies()) { - assertEquals(fam.getScope(), HConstants.REPLICATION_SCOPE_GLOBAL); + assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope()); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/conf/TestConfigurationManager.java ---------------------------------------------------------------------- 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 1f8dbc4..06e1a35 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 @@ -42,6 +42,7 @@ public class TestConfigurationManager { register(); } + @Override public void onConfigurationChange(Configuration conf) { notifiedOnChange = true; } http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java index 35bcd77..d7c70da 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java @@ -85,7 +85,7 @@ public class TestConstraint { try { // test that we don't fail on a valid put Put put = new Put(row1); - byte[] value = Integer.toString(10).getBytes(); + byte[] value = Bytes.toBytes(Integer.toString(10)); byte[] qualifier = new byte[0]; put.addColumn(dummy, qualifier, value); table.put(put); @@ -119,7 +119,7 @@ public class TestConstraint { // test that we do fail on violation Put put = new Put(row1); byte[] qualifier = new byte[0]; - put.addColumn(dummy, qualifier, "fail".getBytes()); + put.addColumn(dummy, qualifier, Bytes.toBytes("fail")); LOG.warn("Doing put in table"); try { table.put(put); @@ -158,7 +158,7 @@ public class TestConstraint { // test that we don't fail because its disabled Put put = new Put(row1); byte[] qualifier = new byte[0]; - put.addColumn(dummy, qualifier, "pass".getBytes()); + put.addColumn(dummy, qualifier, Bytes.toBytes("pass")); table.put(put); } finally { table.close(); @@ -191,7 +191,7 @@ public class TestConstraint { // test that we do fail on violation Put put = new Put(row1); byte[] qualifier = new byte[0]; - put.addColumn(dummy, qualifier, "pass".getBytes()); + put.addColumn(dummy, qualifier, Bytes.toBytes("pass")); LOG.warn("Doing put in table"); table.put(put); } finally { @@ -224,7 +224,7 @@ public class TestConstraint { // test that we do fail on violation Put put = new Put(row1); byte[] qualifier = new byte[0]; - put.addColumn(dummy, qualifier, "pass".getBytes()); + put.addColumn(dummy, qualifier, Bytes.toBytes("pass")); try{ table.put(put); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALCoprocessor.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALCoprocessor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALCoprocessor.java index f3d90f6..1da31da 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALCoprocessor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALCoprocessor.java @@ -123,7 +123,8 @@ public class SampleRegionWALCoprocessor implements WALCoprocessor, RegionCoproce if (Arrays.equals(family, changedFamily) && Arrays.equals(qulifier, changedQualifier)) { LOG.debug("Found the KeyValue from WALEdit which should be changed."); - cell.getValueArray()[cell.getValueOffset()] += 1; + cell.getValueArray()[cell.getValueOffset()] = + (byte) (cell.getValueArray()[cell.getValueOffset()] + 1); } } if (null != row) { http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SimpleRegionObserver.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SimpleRegionObserver.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SimpleRegionObserver.java index 1394dbd..0d864b6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SimpleRegionObserver.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SimpleRegionObserver.java @@ -558,7 +558,7 @@ public class SimpleRegionObserver implements RegionCoprocessor, RegionObserver { TestRegionObserverInterface.TEST_TABLE)) { assertNotNull(familyPaths); assertEquals(1,familyPaths.size()); - assertArrayEquals(familyPaths.get(0).getFirst(), TestRegionObserverInterface.A); + assertArrayEquals(TestRegionObserverInterface.A, familyPaths.get(0).getFirst()); String familyPath = familyPaths.get(0).getSecond(); String familyName = Bytes.toString(TestRegionObserverInterface.A); assertEquals(familyPath.substring(familyPath.length()-familyName.length()-1),"/"+familyName); @@ -577,7 +577,7 @@ public class SimpleRegionObserver implements RegionCoprocessor, RegionObserver { TestRegionObserverInterface.TEST_TABLE)) { assertNotNull(familyPaths); assertEquals(1,familyPaths.size()); - assertArrayEquals(familyPaths.get(0).getFirst(), TestRegionObserverInterface.A); + assertArrayEquals(TestRegionObserverInterface.A, familyPaths.get(0).getFirst()); String familyPath = familyPaths.get(0).getSecond(); String familyName = Bytes.toString(TestRegionObserverInterface.A); assertEquals(familyPath.substring(familyPath.length()-familyName.length()-1),"/"+familyName); http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorConfiguration.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorConfiguration.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorConfiguration.java index 27865f7..6e6c34b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorConfiguration.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorConfiguration.java @@ -108,12 +108,10 @@ public class TestCoprocessorConfiguration { tableCoprocessorLoaded.set(false); new RegionCoprocessorHost(region, rsServices, conf); assertEquals("System coprocessors loading default was not honored", - systemCoprocessorLoaded.get(), - CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED); + CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED, systemCoprocessorLoaded.get()); assertEquals("Table coprocessors loading default was not honored", - tableCoprocessorLoaded.get(), - CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED && - CoprocessorHost.DEFAULT_USER_COPROCESSORS_ENABLED); + CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED && + CoprocessorHost.DEFAULT_USER_COPROCESSORS_ENABLED, tableCoprocessorLoaded.get()); } @Test @@ -123,8 +121,7 @@ public class TestCoprocessorConfiguration { systemCoprocessorLoaded.set(false); new RegionServerCoprocessorHost(rsServices, conf); assertEquals("System coprocessors loading default was not honored", - systemCoprocessorLoaded.get(), - CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED); + CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED, systemCoprocessorLoaded.get()); } @Test @@ -134,8 +131,7 @@ public class TestCoprocessorConfiguration { systemCoprocessorLoaded.set(false); new MasterCoprocessorHost(masterServices, conf); assertEquals("System coprocessors loading default was not honored", - systemCoprocessorLoaded.get(), - CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED); + CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED, systemCoprocessorLoaded.get()); } @Test http://git-wip-us.apache.org/repos/asf/hbase/blob/b1269ec5/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java index 33a488f..de697f1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java @@ -34,7 +34,7 @@ public class TestCoprocessorHost { /** * An {@link Abortable} implementation for tests. */ - private class TestAbortable implements Abortable { + private static class TestAbortable implements Abortable { private volatile boolean aborted = false; @Override