HBASE-19239 Fix findbugs and error-prone issues Fixes for hbase-rest
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3436ed95 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3436ed95 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3436ed95 Branch: refs/heads/branch-1 Commit: 3436ed957cc1ecac8d3cfc13d90a56632b1be143 Parents: e95f94a Author: Andrew Purtell <apurt...@apache.org> Authored: Thu Nov 16 13:00:20 2017 -0800 Committer: Andrew Purtell <apurt...@apache.org> Committed: Fri Nov 17 17:13:03 2017 -0800 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/rest/RowSpec.java | 1 + .../hbase/rest/HBaseRESTTestingUtility.java | 4 +- .../hbase/rest/PerformanceEvaluation.java | 8 +- .../hadoop/hbase/rest/RowResourceBase.java | 20 +- .../apache/hadoop/hbase/rest/TestDeleteRow.java | 26 +-- .../hbase/rest/TestGetAndPutResource.java | 229 +++++++++---------- .../hadoop/hbase/rest/TestGzipFilter.java | 17 +- .../hadoop/hbase/rest/TestMultiRowResource.java | 15 +- .../hadoop/hbase/rest/TestScannerResource.java | 50 ++-- .../hbase/rest/TestScannersWithFilters.java | 22 +- .../hbase/rest/TestScannersWithLabels.java | 12 +- .../hadoop/hbase/rest/TestStatusResource.java | 10 +- .../hadoop/hbase/rest/TestTableResource.java | 29 ++- .../apache/hadoop/hbase/rest/TestTableScan.java | 25 +- .../hadoop/hbase/rest/TestVersionResource.java | 2 +- .../hbase/rest/client/TestXmlParsing.java | 6 +- .../hadoop/hbase/rest/model/TestCellModel.java | 7 +- .../hbase/rest/model/TestCellSetModel.java | 12 +- .../hbase/rest/model/TestColumnSchemaModel.java | 18 +- .../hadoop/hbase/rest/model/TestModelBase.java | 2 +- .../rest/model/TestNamespacesInstanceModel.java | 7 +- .../hbase/rest/model/TestNamespacesModel.java | 5 + .../hadoop/hbase/rest/model/TestRowModel.java | 8 +- .../hbase/rest/model/TestScannerModel.java | 12 +- .../model/TestStorageClusterStatusModel.java | 73 +++--- .../model/TestStorageClusterVersionModel.java | 4 +- .../hbase/rest/model/TestTableInfoModel.java | 16 +- .../hbase/rest/model/TestTableListModel.java | 9 +- .../hbase/rest/model/TestTableRegionModel.java | 12 +- .../hbase/rest/model/TestTableSchemaModel.java | 18 +- .../hbase/rest/model/TestVersionModel.java | 17 +- 31 files changed, 365 insertions(+), 331 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java index cc51c85..0a88fde 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java @@ -377,6 +377,7 @@ public class RowSpec { this.endTime = endTime; } + @Override public String toString() { StringBuilder result = new StringBuilder(); result.append("{startRow => '"); http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/HBaseRESTTestingUtility.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/HBaseRESTTestingUtility.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/HBaseRESTTestingUtility.java index 7c3e1fd..e319704 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/HBaseRESTTestingUtility.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/HBaseRESTTestingUtility.java @@ -18,6 +18,8 @@ */ package org.apache.hadoop.hbase.rest; +import java.util.Arrays; + import org.apache.commons.lang.ArrayUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -78,7 +80,7 @@ public class HBaseRESTTestingUtility { conf.set(RESTServer.REST_CSRF_BROWSER_USERAGENTS_REGEX_KEY, ".*"); RESTServer.addCSRFFilter(context, conf); HttpServerUtil.constrainHttpMethods(context); - LOG.info("Loaded filter classes :" + filterClasses); + LOG.info("Loaded filter classes :" + Arrays.toString(filterClasses)); // start the server server.start(); // get the port http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java index ad1ca29..9a3ec248 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java @@ -487,10 +487,11 @@ public class PerformanceEvaluation extends Configured implements Tool { return clazz; } + @Override protected void map(NullWritable key, PeInputSplit value, final Context context) throws IOException, InterruptedException { - Status status = new Status() { + @Override public void setStatus(String msg) { context.setStatus(msg); } @@ -632,6 +633,7 @@ public class PerformanceEvaluation extends Configured implements Tool { long elapsedTime = pe.runOneClient(cmd, index * perClientRows, perClientRows, R, flushCommits, writeToWAL, useTags, noOfTags, connection, new Status() { + @Override public void setStatus(final String msg) throws IOException { LOG.info("client-" + getName() + " " + msg); } @@ -952,6 +954,7 @@ public class PerformanceEvaluation extends Configured implements Tool { super(conf, options, status); } + @Override void testSetup() throws IOException { this.table = connection.getTable(tableName); } @@ -971,10 +974,12 @@ public class PerformanceEvaluation extends Configured implements Tool { this.flushCommits = options.isFlushCommits(); } + @Override void testSetup() throws IOException { this.mutator = connection.getBufferedMutator(tableName); } + @Override void testTakedown() throws IOException { if (flushCommits) { this.mutator.flush(); @@ -1323,6 +1328,7 @@ public class PerformanceEvaluation extends Configured implements Tool { private void runNIsOne(final Class<? extends Test> cmd) { Status status = new Status() { + @Override public void setStatus(String msg) throws IOException { LOG.info(msg); } http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java index 00abe3a..9da9761 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java @@ -151,7 +151,7 @@ public class RowResourceBase { protected static void checkValueXML(String url, String table, String row, String column, String value) throws IOException, JAXBException { Response response = getValueXML(url); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); @@ -164,7 +164,7 @@ public class RowResourceBase { protected static void checkValueXML(String table, String row, String column, String value) throws IOException, JAXBException { Response response = getValueXML(table, row, column); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); @@ -176,11 +176,11 @@ public class RowResourceBase { protected static void checkIncrementValueXML(String table, String row, String column, long value) throws IOException, JAXBException { - Response response1 = getValueXML(table, row, column); - assertEquals(response1.getCode(), 200); - assertEquals(Constants.MIMETYPE_XML, response1.getHeader("content-type")); + Response response = getValueXML(table, row, column); + assertEquals(200, response.getCode()); + assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) - xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response1.getBody())); + xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); RowModel rowModel = cellSet.getRows().get(0); CellModel cell = rowModel.getCells().get(0); assertEquals(Bytes.toString(cell.getColumn()), column); @@ -234,7 +234,7 @@ public class RowResourceBase { protected static void checkValuePB(String table, String row, String column, String value) throws IOException { Response response = getValuePB(table, row, column); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type")); CellSetModel cellSet = new CellSetModel(); cellSet.getObjectFromMessage(response.getBody()); @@ -247,7 +247,7 @@ public class RowResourceBase { protected static void checkIncrementValuePB(String table, String row, String column, long value) throws IOException { Response response = getValuePB(table, row, column); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type")); CellSetModel cellSet = new CellSetModel(); cellSet.getObjectFromMessage(response.getBody()); @@ -533,7 +533,7 @@ public class RowResourceBase { protected static void checkValueJSON(String table, String row, String column, String value) throws IOException, JAXBException { Response response = getValueJson(table, row, column); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); ObjectMapper mapper = new JacksonProvider() .locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE); @@ -547,7 +547,7 @@ public class RowResourceBase { protected static void checkIncrementValueJSON(String table, String row, String column, long value) throws IOException, JAXBException { Response response = getValueJson(table, row, column); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); ObjectMapper mapper = new JacksonJaxbJsonProvider() .locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE); http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestDeleteRow.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestDeleteRow.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestDeleteRow.java index 5af3831..6e3827d 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestDeleteRow.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestDeleteRow.java @@ -35,7 +35,7 @@ public class TestDeleteRow extends RowResourceBase { @Test public void testDeleteNonExistentColumn() throws Exception { Response response = putValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = checkAndDeleteJson(TABLE, ROW_1, COLUMN_1, VALUE_2); assertEquals(304, response.getCode()); @@ -61,39 +61,39 @@ public class TestDeleteRow extends RowResourceBase { @Test public void testDeleteXML() throws IOException, JAXBException { Response response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = putValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2); response = deleteValue(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = getValueXML(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2); response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = getValueXML(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = getValueXML(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); response = getValueXML(TABLE, ROW_1, COLUMN_2); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); //Delete a row in non existent table response = deleteValue("dummy", ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); //Delete non existent column response = deleteValue(TABLE, ROW_1, "dummy"); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGetAndPutResource.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGetAndPutResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGetAndPutResource.java index 25b445e..ba0f928 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGetAndPutResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGetAndPutResource.java @@ -25,10 +25,8 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.StringWriter; import java.net.URLEncoder; -import java.util.Dictionary; import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.xml.bind.JAXBException; @@ -57,92 +55,92 @@ public class TestGetAndPutResource extends RowResourceBase { conf.set("hbase.rest.readonly", "true"); Response response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_2); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_2); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); response = deleteValue(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); conf.set("hbase.rest.readonly", "false"); response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = deleteValue(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testSingleCellGetPutXML() throws IOException, JAXBException { Response response = getValueXML(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2); response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3); response = checkAndDeleteXML(TABLE, ROW_1, COLUMN_1, VALUE_3); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testSingleCellGetPutPB() throws IOException, JAXBException { Response response = getValuePB(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2); response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2, VALUE_3); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3); response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3, VALUE_4); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_4); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testMultipleCellCheckPutPB() throws IOException, JAXBException { Response response = getValuePB(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); // Add 2 Columns to setup the test response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); response = putValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2); HashMap<String,String> otherCells = new HashMap<String, String>(); @@ -150,32 +148,32 @@ public class TestGetAndPutResource extends RowResourceBase { // On Success update both the cells response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_3, otherCells); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3); checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_3); // On Failure, we dont update any cells response = checkAndPutValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_4, otherCells); - assertEquals(response.getCode(), 304); + assertEquals(304, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_3); checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_3); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testMultipleCellCheckPutXML() throws IOException, JAXBException { Response response = getValuePB(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); // Add 2 Columns to setup the test response = putValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); response = putValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2); HashMap<String,String> otherCells = new HashMap<String, String>(); @@ -183,36 +181,36 @@ public class TestGetAndPutResource extends RowResourceBase { // On Success update both the cells response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_3, otherCells); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3); checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_3); // On Failure, we dont update any cells response = checkAndPutValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1, VALUE_4, otherCells); - assertEquals(response.getCode(), 304); + assertEquals(304, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_3); checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_3); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testMultipleCellCheckDeletePB() throws IOException, JAXBException { Response response = getValuePB(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); // Add 3 Columns to setup the test response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); response = putValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2); response = putValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3); // Deletes the following columns based on Column1 check @@ -222,44 +220,45 @@ public class TestGetAndPutResource extends RowResourceBase { // On Success update both the cells response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_1, cellsToDelete); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); response = getValuePB(TABLE, ROW_1, COLUMN_2); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); response = getValuePB(TABLE, ROW_1, COLUMN_3); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); response = putValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2); response = putValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3); // On Failure, we dont update any cells response = checkAndDeletePB(TABLE, ROW_1, COLUMN_1, VALUE_3, cellsToDelete); - assertEquals(response.getCode(), 304); + assertEquals(304, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2); checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } - @Test + + @Test public void testSingleCellGetPutBinary() throws IOException { final String path = "/" + TABLE + "/" + ROW_3 + "/" + COLUMN_1; final byte[] body = Bytes.toBytes(VALUE_3); Response response = client.put(path, Constants.MIMETYPE_BINARY, body); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); Thread.yield(); response = client.get(path, Constants.MIMETYPE_BINARY); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_BINARY, response.getHeader("content-type")); assertTrue(Bytes.equals(response.getBody(), body)); boolean foundTimestampHeader = false; @@ -272,7 +271,7 @@ public class TestGetAndPutResource extends RowResourceBase { assertTrue(foundTimestampHeader); response = deleteRow(TABLE, ROW_3); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test @@ -280,13 +279,13 @@ public class TestGetAndPutResource extends RowResourceBase { final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1; Response response = client.put(path, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_4)); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); Thread.yield(); response = client.get(path, Constants.MIMETYPE_JSON); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); response = deleteRow(TABLE, ROW_4); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test @@ -304,10 +303,10 @@ public class TestGetAndPutResource extends RowResourceBase { String jsonString = jsonMapper.writeValueAsString(cellSetModel); Response response = client.put(path, Constants.MIMETYPE_JSON, Bytes.toBytes(jsonString)); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); Thread.yield(); response = client.get(path, Constants.MIMETYPE_JSON); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); CellSetModel cellSet = jsonMapper.readValue(response.getBody(), CellSetModel.class); assertTrue(cellSet.getRows().size() == 1); @@ -316,7 +315,7 @@ public class TestGetAndPutResource extends RowResourceBase { assertEquals(VALUE_2 , Bytes.toString(cell.getValue())); assertEquals(2L , cell.getTimestamp()); response = deleteRow(TABLE, ROW_4); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test @@ -332,7 +331,7 @@ public class TestGetAndPutResource extends RowResourceBase { Response response; response = putValueXML(path.toString(), TABLE, urlKey, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(path.toString(), TABLE, urlKey, COLUMN_1, VALUE_1); } @@ -342,13 +341,10 @@ public class TestGetAndPutResource extends RowResourceBase { final String badPath = "/" + TABLE + "/" + ROW_1 + "/" + "BAD"; Response response = client.post(goodPath, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1)); - assertEquals(response.getCode(), 200); - assertEquals(client.get(goodPath, Constants.MIMETYPE_BINARY).getCode(), - 200); - assertEquals(client.get(badPath, Constants.MIMETYPE_BINARY).getCode(), - 404); - assertEquals(client.get(goodPath, Constants.MIMETYPE_BINARY).getCode(), - 200); + assertEquals(200, response.getCode()); + assertEquals(200, client.get(goodPath, Constants.MIMETYPE_BINARY).getCode()); + assertEquals(404, client.get(badPath, Constants.MIMETYPE_BINARY).getCode()); + assertEquals(200, client.get(goodPath, Constants.MIMETYPE_BINARY).getCode()); } @Test @@ -376,7 +372,7 @@ public class TestGetAndPutResource extends RowResourceBase { // make sure the fake row was not actually created response = client.get(path, Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); // check that all of the values were created checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); @@ -385,9 +381,9 @@ public class TestGetAndPutResource extends RowResourceBase { checkValueXML(TABLE, ROW_2, COLUMN_2, VALUE_4); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = deleteRow(TABLE, ROW_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test @@ -413,7 +409,7 @@ public class TestGetAndPutResource extends RowResourceBase { // make sure the fake row was not actually created response = client.get(path, Constants.MIMETYPE_PROTOBUF); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); // check that all of the values were created checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); @@ -422,9 +418,9 @@ public class TestGetAndPutResource extends RowResourceBase { checkValuePB(TABLE, ROW_2, COLUMN_2, VALUE_4); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = deleteRow(TABLE, ROW_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test @@ -469,7 +465,7 @@ public class TestGetAndPutResource extends RowResourceBase { Response response = client.put(path, Constants.MIMETYPE_XML, Bytes.toBytes(writer.toString())); - assertEquals(response.getCode(), 400); + assertEquals(400, response.getCode()); } @Test @@ -487,7 +483,7 @@ public class TestGetAndPutResource extends RowResourceBase { Response response = client.put(path, Constants.MIMETYPE_XML, Bytes.toBytes(writer.toString())); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); } @Test @@ -515,7 +511,7 @@ public class TestGetAndPutResource extends RowResourceBase { // make sure the fake row was not actually created response = client.get(path, Constants.MIMETYPE_JSON); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); // check that all of the values were created checkValueJSON(TABLE, ROW_1, COLUMN_1, VALUE_1); @@ -524,9 +520,9 @@ public class TestGetAndPutResource extends RowResourceBase { checkValueJSON(TABLE, ROW_2, COLUMN_2, VALUE_4); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = deleteRow(TABLE, ROW_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test @@ -534,13 +530,13 @@ public class TestGetAndPutResource extends RowResourceBase { final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1; Response response = client.put(path, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_4)); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); Thread.yield(); response = client.get(path, Constants.MIMETYPE_JSON); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); response = deleteRow(TABLE, ROW_4); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); UserProvider userProvider = UserProvider.instantiate(conf); METRICS_ASSERT.assertCounterGt("requests", 2l, @@ -573,7 +569,7 @@ public class TestGetAndPutResource extends RowResourceBase { // make sure the fake row was not actually created response = client.get(path, Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); // Try getting all the column values at once. path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "," + COLUMN_2 + "," + COLUMN_3; @@ -589,7 +585,7 @@ public class TestGetAndPutResource extends RowResourceBase { assertTrue(containsCellModel(cells, COLUMN_2, VALUE_2)); assertTrue(containsCellModel(cells, COLUMN_3, VALUE_2)); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } private boolean containsCellModel(List<CellModel> cells, String column, String value) { @@ -629,7 +625,7 @@ public class TestGetAndPutResource extends RowResourceBase { // make sure the fake row was not actually created response = client.get(path, Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); // check that all of the values were created StringBuilder query = new StringBuilder(); @@ -638,16 +634,16 @@ public class TestGetAndPutResource extends RowResourceBase { query.append('/'); query.append("testrow*"); response = client.get(query.toString(), Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); assertTrue(cellSet.getRows().size() == 2); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = deleteRow(TABLE, ROW_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test @@ -675,7 +671,7 @@ public class TestGetAndPutResource extends RowResourceBase { // make sure the fake row was not actually created response = client.get(path, Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); // check that all of the values were created StringBuilder query = new StringBuilder(); @@ -686,7 +682,7 @@ public class TestGetAndPutResource extends RowResourceBase { query.append('/'); query.append(COLUMN_1); response = client.get(query.toString(), Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); @@ -697,114 +693,113 @@ public class TestGetAndPutResource extends RowResourceBase { assertEquals(COLUMN_1, Bytes.toString(row.getCells().get(0).getColumn())); } response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = deleteRow(TABLE, ROW_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testAppendXML() throws IOException, JAXBException { Response response = getValueXML(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); //append cell response = appendValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1); response = appendValueXML(TABLE, ROW_1, COLUMN_1, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValueXML(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testAppendPB() throws IOException, JAXBException { Response response = getValuePB(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); //append cell response = appendValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1); response = appendValuePB(TABLE, ROW_1, COLUMN_1, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testAppendJSON() throws IOException, JAXBException { Response response = getValueJson(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); //append cell response = appendValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); putValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1); response = appendValueJson(TABLE, ROW_1, COLUMN_1, VALUE_2); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); putValueJson(TABLE, ROW_1, COLUMN_1, VALUE_1 + VALUE_2); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testIncrementXML() throws IOException, JAXBException { Response response = getValueXML(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); //append single cell response = incrementValueXML(TABLE, ROW_1, COLUMN_1, VALUE_5); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkIncrementValueXML(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5)); response = incrementValueXML(TABLE, ROW_1, COLUMN_1, VALUE_6); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkIncrementValueXML(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6)); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testIncrementPB() throws IOException, JAXBException { Response response = getValuePB(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); //append cell response = incrementValuePB(TABLE, ROW_1, COLUMN_1, VALUE_5); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkIncrementValuePB(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5)); response = incrementValuePB(TABLE, ROW_1, COLUMN_1, VALUE_6); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkIncrementValuePB(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6)); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testIncrementJSON() throws IOException, JAXBException { Response response = getValueJson(TABLE, ROW_1, COLUMN_1); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); //append cell response = incrementValueJson(TABLE, ROW_1, COLUMN_1, VALUE_5); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkIncrementValueJSON(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5)); response = incrementValueJson(TABLE, ROW_1, COLUMN_1, VALUE_6); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); checkIncrementValueJSON(TABLE, ROW_1, COLUMN_1, Long.parseLong(VALUE_5) + Long.parseLong(VALUE_6)); response = deleteRow(TABLE, ROW_1); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } } - http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java index c984b69..5a9344a 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java @@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; @@ -98,7 +99,7 @@ public class TestGzipFilter { headers[0] = new Header("Content-Type", Constants.MIMETYPE_BINARY); headers[1] = new Header("Content-Encoding", "gzip"); Response response = client.put(path, headers, value_1_gzip); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); Table table = TEST_UTIL.getConnection().getTable(TABLE); Get get = new Get(Bytes.toBytes(ROW_1)); @@ -113,7 +114,7 @@ public class TestGzipFilter { headers[0] = new Header("Accept", Constants.MIMETYPE_BINARY); headers[1] = new Header("Accept-Encoding", "gzip"); response = client.get(path, headers); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); ByteArrayInputStream bis = new ByteArrayInputStream(response.getBody()); GZIPInputStream is = new GZIPInputStream(bis); value = new byte[VALUE_1.length]; @@ -131,11 +132,11 @@ public class TestGzipFilter { headers[0] = new Header("Accept", Constants.MIMETYPE_BINARY); headers[1] = new Header("Accept-Encoding", "gzip"); Response response = client.get("/" + TABLE + "/" + ROW_1 + "/" + COLUMN_2, headers); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); String contentEncoding = response.getHeader("Content-Encoding"); assertTrue(contentEncoding == null || !contentEncoding.contains("gzip")); response = client.get("/" + TABLE, headers); - assertEquals(response.getCode(), 405); + assertEquals(405, response.getCode()); contentEncoding = response.getHeader("Content-Encoding"); assertTrue(contentEncoding == null || !contentEncoding.contains("gzip")); } @@ -146,14 +147,14 @@ public class TestGzipFilter { headers[1] = new Header("Accept", Constants.MIMETYPE_JSON); headers[2] = new Header("Accept-Encoding", "gzip"); Response response = client.post("/" + TABLE + "/scanner", headers, - "<Scanner/>".getBytes()); - assertEquals(response.getCode(), 201); + "<Scanner/>".getBytes(StandardCharsets.UTF_8)); + assertEquals(201, response.getCode()); String scannerUrl = response.getLocation(); assertNotNull(scannerUrl); response = client.get(scannerUrl); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); response = client.get(scannerUrl); - assertEquals(response.getCode(), 204); + assertEquals(204, response.getCode()); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java index 35fb7fd..e58be13 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java @@ -43,8 +43,6 @@ import org.junit.runners.Parameterized; import javax.ws.rs.core.MediaType; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -72,9 +70,8 @@ public class TestMultiRowResource { private static final HBaseRESTTestingUtility REST_TEST_UTIL = new HBaseRESTTestingUtility(); private static Client client; + @SuppressWarnings("unused") private static JAXBContext context; - private static Marshaller marshaller; - private static Unmarshaller unmarshaller; private static Configuration conf; private static Header extraHdr = null; @@ -104,8 +101,6 @@ public class TestMultiRowResource { CellModel.class, CellSetModel.class, RowModel.class); - marshaller = context.createMarshaller(); - unmarshaller = context.createUnmarshaller(); client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort())); Admin admin = TEST_UTIL.getHBaseAdmin(); if (admin.tableExists(TABLE)) { @@ -148,7 +143,7 @@ public class TestMultiRowResource { Response response = client.get(path.toString(), Constants.MIMETYPE_JSON); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); client.delete(row_5_url, extraHdr); @@ -175,7 +170,7 @@ public class TestMultiRowResource { Response response = client.get(path.toString(), Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); client.delete(row_5_url, extraHdr); @@ -202,7 +197,7 @@ public class TestMultiRowResource { client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2), extraHdr); Response response = client.get(path.toString(), Constants.MIMETYPE_JSON); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); ObjectMapper mapper = new JacksonProvider().locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE); CellSetModel cellSet = (CellSetModel) mapper.readValue(response.getBody(), CellSetModel.class); @@ -231,7 +226,7 @@ public class TestMultiRowResource { client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1), extraHdr); Response response = client.get(path.toString(), Constants.MIMETYPE_JSON); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); ObjectMapper mapper = new JacksonProvider().locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE); CellSetModel cellSet = (CellSetModel) mapper.readValue(response.getBody(), CellSetModel.class); http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java index 242c36d..d941a9f 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java @@ -38,8 +38,6 @@ import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import org.apache.commons.httpclient.Header; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; @@ -68,7 +66,7 @@ import org.junit.experimental.categories.Category; @Category(MediumTests.class) public class TestScannerResource { - private static final Log LOG = LogFactory.getLog(TestScannerResource.class); + private static final TableName TABLE = TableName.valueOf("TestScannerResource"); private static final TableName TABLE_TO_BE_DISABLED = TableName.valueOf("ScannerResourceDisable"); private static final String NONEXISTENT_TABLE = "ThisTableDoesNotExist"; @@ -134,7 +132,7 @@ public class TestScannerResource { model.setBatch(100); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); int count = 0; @@ -160,7 +158,7 @@ public class TestScannerResource { } // delete the scanner response = client.delete(scannerURI); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); return count; } @@ -216,7 +214,7 @@ public class TestScannerResource { conf.set("hbase.rest.readonly", "true"); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); String scannerURI = response.getLocation(); assertNull(scannerURI); @@ -224,28 +222,28 @@ public class TestScannerResource { conf.set("hbase.rest.readonly", "false"); response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); // confirm batch size conformance - assertEquals(countCellSet(cellSet), BATCH_SIZE); + assertEquals(BATCH_SIZE, countCellSet(cellSet)); // test delete scanner operation is forbidden in read-only mode conf.set("hbase.rest.readonly", "true"); response = client.delete(scannerURI); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); // recall previous delete scanner operation with read-only off conf.set("hbase.rest.readonly", "false"); response = client.delete(scannerURI); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test @@ -260,7 +258,7 @@ public class TestScannerResource { conf.set("hbase.rest.readonly", "true"); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); String scannerURI = response.getLocation(); assertNull(scannerURI); @@ -268,28 +266,28 @@ public class TestScannerResource { conf.set("hbase.rest.readonly", "false"); response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_PROTOBUF); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type")); CellSetModel cellSet = new CellSetModel(); cellSet.getObjectFromMessage(response.getBody()); // confirm batch size conformance - assertEquals(countCellSet(cellSet), BATCH_SIZE); + assertEquals(BATCH_SIZE, countCellSet(cellSet)); // test delete scanner operation is forbidden in read-only mode conf.set("hbase.rest.readonly", "true"); response = client.delete(scannerURI); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); // recall previous delete scanner operation with read-only off conf.set("hbase.rest.readonly", "false"); response = client.delete(scannerURI); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test @@ -303,7 +301,7 @@ public class TestScannerResource { conf.set("hbase.rest.readonly", "true"); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); String scannerURI = response.getLocation(); assertNull(scannerURI); @@ -311,13 +309,13 @@ public class TestScannerResource { conf.set("hbase.rest.readonly", "false"); response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell response = client.get(scannerURI, Constants.MIMETYPE_BINARY); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_BINARY, response.getHeader("content-type")); // verify that data was returned assertTrue(response.getBody().length > 0); @@ -340,23 +338,23 @@ public class TestScannerResource { // test delete scanner operation is forbidden in read-only mode conf.set("hbase.rest.readonly", "true"); response = client.delete(scannerURI); - assertEquals(response.getCode(), 403); + assertEquals(403, response.getCode()); // recall previous delete scanner operation with read-only off conf.set("hbase.rest.readonly", "false"); response = client.delete(scannerURI); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } @Test public void testFullTableScan() throws IOException { ScannerModel model = new ScannerModel(); model.addColumn(Bytes.toBytes(COLUMN_1)); - assertEquals(fullTableScan(model), expectedRows1); + assertEquals(expectedRows1, fullTableScan(model)); model = new ScannerModel(); model.addColumn(Bytes.toBytes(COLUMN_2)); - assertEquals(fullTableScan(model), expectedRows2); + assertEquals(expectedRows2, fullTableScan(model)); } @Test @@ -370,7 +368,7 @@ public class TestScannerResource { String scannerURI = response.getLocation(); assertNotNull(scannerURI); response = client.get(scannerURI, Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 404); + assertEquals(404, response.getCode()); } // performs table scan during which the underlying table is disabled @@ -382,7 +380,7 @@ public class TestScannerResource { model.setCaching(1); Response response = client.put("/" + TABLE_TO_BE_DISABLED + "/scanner", Constants.MIMETYPE_PROTOBUF, model.createProtobufOutput()); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); TEST_UTIL.getHBaseAdmin().disableTable(TABLE_TO_BE_DISABLED); http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java index a06d650..07d2f03 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java @@ -113,8 +113,8 @@ public class TestScannersWithFilters { private static JAXBContext context; private static Marshaller marshaller; private static Unmarshaller unmarshaller; - private static long numRows = ROWS_ONE.length + ROWS_TWO.length; - private static long colsPerRow = FAMILIES.length * QUALIFIERS_ONE.length; + private static long numRows = (long) ROWS_ONE.length + ROWS_TWO.length; + private static long colsPerRow = (long) FAMILIES.length * QUALIFIERS_ONE.length; @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -221,13 +221,13 @@ public class TestScannersWithFilters { byte[] body = Bytes.toBytes(writer.toString()); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cells = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); @@ -243,7 +243,7 @@ public class TestScannersWithFilters { // delete the scanner response = client.delete(scannerURI); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); } private static void verifyScanFull(Scan s, KeyValue [] kvs) @@ -256,20 +256,20 @@ public class TestScannersWithFilters { byte[] body = Bytes.toBytes(writer.toString()); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); // delete the scanner response = client.delete(scannerURI); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); int row = 0; int idx = 0; @@ -310,20 +310,20 @@ public class TestScannersWithFilters { byte[] body = Bytes.toBytes(writer.toString()); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); // delete the scanner response = client.delete(scannerURI); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); Iterator<RowModel> i = cellSet.getRows().iterator(); int j = 0; http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java index 175b9f3..c72517c 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java @@ -26,7 +26,6 @@ import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Random; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -166,6 +165,7 @@ public class TestScannersWithLabels { private static void createLabels() throws IOException, InterruptedException { PrivilegedExceptionAction<VisibilityLabelsResponse> action = new PrivilegedExceptionAction<VisibilityLabelsResponse>() { + @Override public VisibilityLabelsResponse run() throws Exception { String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET }; try (Connection conn = ConnectionFactory.createConnection(conf)) { @@ -200,14 +200,14 @@ public class TestScannersWithLabels { // recall previous put operation with read-only off conf.set("hbase.rest.readonly", "false"); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); // Respond with 204 as there are no cells to be retrieved - assertEquals(response.getCode(), 204); + assertEquals(204, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); } @@ -225,18 +225,18 @@ public class TestScannersWithLabels { // recall previous put operation with read-only off conf.set("hbase.rest.readonly", "false"); Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body); - assertEquals(response.getCode(), 201); + assertEquals(201, response.getCode()); String scannerURI = response.getLocation(); assertNotNull(scannerURI); // get a cell set response = client.get(scannerURI, Constants.MIMETYPE_XML); // Respond with 204 as there are no cells to be retrieved - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response .getBody())); - assertEquals(countCellSet(cellSet), 5); + assertEquals(5, countCellSet(cellSet)); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java index bba185d..2ee3397 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java @@ -25,12 +25,9 @@ import java.io.IOException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.Waiter; import org.apache.hadoop.hbase.rest.client.Client; import org.apache.hadoop.hbase.rest.client.Cluster; import org.apache.hadoop.hbase.rest.client.Response; @@ -46,7 +43,6 @@ import org.junit.experimental.categories.Category; @Category(MediumTests.class) public class TestStatusResource { - private static final Log LOG = LogFactory.getLog(TestStatusResource.class); private static final byte[] META_REGION_NAME = Bytes.toBytes(TableName.META_TABLE_NAME+",,1"); @@ -96,7 +92,7 @@ public class TestStatusResource { @Test public void testGetClusterStatusXML() throws IOException, JAXBException { Response response = client.get("/status/cluster", Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); StorageClusterStatusModel model = (StorageClusterStatusModel) context.createUnmarshaller().unmarshal( @@ -107,13 +103,13 @@ public class TestStatusResource { @Test public void testGetClusterStatusPB() throws IOException { Response response = client.get("/status/cluster", Constants.MIMETYPE_PROTOBUF); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type")); StorageClusterStatusModel model = new StorageClusterStatusModel(); model.getObjectFromMessage(response.getBody()); validate(model); response = client.get("/status/cluster", Constants.MIMETYPE_PROTOBUF_IETF); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type")); model = new StorageClusterStatusModel(); model.getObjectFromMessage(response.getBody()); http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java index 3abcb4a..25508b0 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java @@ -127,13 +127,13 @@ public class TestTableResource { admin.split(TABLE); // give some time for the split to happen - long timeout = EnvironmentEdgeManager.currentTime() + (15 * 1000); - TEST_UTIL.waitFor(timeout, 250, new Waiter.Predicate<IOException>() { + TEST_UTIL.waitFor(15 * 1000, 250, new Waiter.Predicate<IOException>() { @Override public boolean evaluate() throws IOException { List<HRegionLocation> regionLocations = regionLocator.getAllRegionLocations(); - return regionLocations.size() == 2 && regionLocations.get(0).getServerName() != null - && regionLocations.get(1).getServerName() != null; + return regionLocations != null && + regionLocations.size() == 2 && regionLocations.get(0).getServerName() != null && + regionLocations.get(1).getServerName() != null; } }); m = regionLocator.getAllRegionLocations(); @@ -199,14 +199,14 @@ public class TestTableResource { @Test public void testTableListText() throws IOException { Response response = client.get("/", Constants.MIMETYPE_TEXT); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_TEXT, response.getHeader("content-type")); } @Test public void testTableListXML() throws IOException, JAXBException { Response response = client.get("/", Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); TableListModel model = (TableListModel) context.createUnmarshaller() @@ -217,20 +217,20 @@ public class TestTableResource { @Test public void testTableListJSON() throws IOException { Response response = client.get("/", Constants.MIMETYPE_JSON); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); } @Test public void testTableListPB() throws IOException, JAXBException { Response response = client.get("/", Constants.MIMETYPE_PROTOBUF); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type")); TableListModel model = new TableListModel(); model.getObjectFromMessage(response.getBody()); checkTableList(model); response = client.get("/", Constants.MIMETYPE_PROTOBUF_IETF); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type")); model = new TableListModel(); model.getObjectFromMessage(response.getBody()); @@ -240,14 +240,14 @@ public class TestTableResource { @Test public void testTableInfoText() throws IOException { Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_TEXT); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_TEXT, response.getHeader("content-type")); } @Test public void testTableInfoXML() throws IOException, JAXBException { Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_XML); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); TableInfoModel model = (TableInfoModel) context.createUnmarshaller() @@ -258,20 +258,20 @@ public class TestTableResource { @Test public void testTableInfoJSON() throws IOException { Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_JSON); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); } @Test public void testTableInfoPB() throws IOException, JAXBException { Response response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_PROTOBUF); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_PROTOBUF, response.getHeader("content-type")); TableInfoModel model = new TableInfoModel(); model.getObjectFromMessage(response.getBody()); checkTableInfo(model); response = client.get("/" + TABLE + "/regions", Constants.MIMETYPE_PROTOBUF_IETF); - assertEquals(response.getCode(), 200); + assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_PROTOBUF_IETF, response.getHeader("content-type")); model = new TableInfoModel(); model.getObjectFromMessage(response.getBody()); @@ -279,4 +279,3 @@ public class TestTableResource { } } - http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableScan.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableScan.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableScan.java index 0654f78..d3e618b 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableScan.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableScan.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -278,12 +279,14 @@ public class TestTableScan { // install the callback on all ClientSideCellSetModel instances unmarshaller.setListener(new Unmarshaller.Listener() { + @Override public void beforeUnmarshal(Object target, Object parent) { if (target instanceof ClientSideCellSetModel) { ((ClientSideCellSetModel) target).setCellSetModelListener(listener); } } + @Override public void afterUnmarshal(Object target, Object parent) { if (target instanceof ClientSideCellSetModel) { ((ClientSideCellSetModel) target).setCellSetModelListener(null); @@ -485,7 +488,8 @@ public class TestTableScan { CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream()); int count = TestScannerResource.countCellSet(model); assertEquals(1, count); - assertEquals("aab", new String(model.getRows().get(0).getCells().get(0).getValue())); + assertEquals("aab", new String(model.getRows().get(0).getCells().get(0).getValue(), + StandardCharsets.UTF_8)); } @Test @@ -503,7 +507,8 @@ public class TestTableScan { CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream()); int count = TestScannerResource.countCellSet(model); assertEquals(1, count); - assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue())); + assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue(), + StandardCharsets.UTF_8)); } @@ -522,7 +527,8 @@ public class TestTableScan { CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream()); int count = TestScannerResource.countCellSet(model); assertEquals(1, count); - assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue())); + assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue(), + StandardCharsets.UTF_8)); } @Test @@ -541,7 +547,8 @@ public class TestTableScan { CellSetModel model = (CellSetModel) ush.unmarshal(response.getStream()); int count = TestScannerResource.countCellSet(model); assertEquals(1, count); - assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue())); + assertEquals("abc", new String(model.getRows().get(0).getCells().get(0).getValue(), + StandardCharsets.UTF_8)); } @Test @@ -606,10 +613,10 @@ public class TestTableScan { RowModel rowModel = rowModels.get(i); RowModel reversedRowModel = reversedRowModels.get(i); - assertEquals(new String(rowModel.getKey(), "UTF-8"), - new String(reversedRowModel.getKey(), "UTF-8")); - assertEquals(new String(rowModel.getCells().get(0).getValue(), "UTF-8"), - new String(reversedRowModel.getCells().get(0).getValue(), "UTF-8")); + assertEquals(new String(rowModel.getKey(), StandardCharsets.UTF_8), + new String(reversedRowModel.getKey(), StandardCharsets.UTF_8)); + assertEquals(new String(rowModel.getCells().get(0).getValue(), StandardCharsets.UTF_8), + new String(reversedRowModel.getCells().get(0).getValue(), StandardCharsets.UTF_8)); } } @@ -658,7 +665,7 @@ public class TestTableScan { public void setCellSetModelListener(final Listener l) { row = (l == null) ? null : new ArrayList<RowModel>() { private static final long serialVersionUID = 1L; - + @Override public boolean add(RowModel o) { l.handleRowModel(ClientSideCellSetModel.this, o); listenerInvoked = true; http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java index 60a4340..03c462e 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestVersionResource.java @@ -78,7 +78,7 @@ public class TestVersionResource { private static void validate(VersionModel model) { assertNotNull(model); assertNotNull(model.getRESTVersion()); - assertEquals(model.getRESTVersion(), RESTServlet.VERSION_STRING); + assertEquals(RESTServlet.VERSION_STRING, model.getRESTVersion()); String osVersion = model.getOSVersion(); assertNotNull(osVersion); assertTrue(osVersion.contains(System.getProperty("os.name"))); http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java index 586e33c..c12bbb6 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestXmlParsing.java @@ -23,6 +23,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; +import java.nio.charset.StandardCharsets; + import javax.xml.bind.UnmarshalException; import org.apache.commons.logging.Log; @@ -48,7 +50,7 @@ public class TestXmlParsing { + "<ClusterVersion Version=\"2.0.0\"/>"; Client client = mock(Client.class); RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null); - Response resp = new Response(200, null, xml.getBytes()); + Response resp = new Response(200, null, xml.getBytes(StandardCharsets.UTF_8)); when(client.get("/version/cluster", Constants.MIMETYPE_XML)).thenReturn(resp); @@ -64,7 +66,7 @@ public class TestXmlParsing { + " <ClusterVersion>&xee;</ClusterVersion>"; Client client = mock(Client.class); RemoteAdmin admin = new RemoteAdmin(client, HBaseConfiguration.create(), null); - Response resp = new Response(200, null, externalEntitiesXml.getBytes()); + Response resp = new Response(200, null, externalEntitiesXml.getBytes(StandardCharsets.UTF_8)); when(client.get("/version/cluster", Constants.MIMETYPE_XML)).thenReturn(resp); http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellModel.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellModel.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellModel.java index bc273b4..a21a316 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellModel.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellModel.java @@ -43,6 +43,7 @@ public class TestCellModel extends TestModelBase<CellModel> { "{\"column\":\"dGVzdGNvbHVtbg==\",\"timestamp\":1245219839331,\"$\":\"dGVzdHZhbHVl\"}"; } + @Override protected CellModel buildTestModel() { CellModel model = new CellModel(); model.setColumn(COLUMN); @@ -51,21 +52,25 @@ public class TestCellModel extends TestModelBase<CellModel> { return model; } + @Override protected void checkModel(CellModel model) { assertTrue(Bytes.equals(model.getColumn(), COLUMN)); assertTrue(Bytes.equals(model.getValue(), VALUE)); assertTrue(model.hasUserTimestamp()); - assertEquals(model.getTimestamp(), TIMESTAMP); + assertEquals(TIMESTAMP, model.getTimestamp()); } + @Override public void testBuildModel() throws Exception { checkModel(buildTestModel()); } + @Override public void testFromXML() throws Exception { checkModel(fromXML(AS_XML)); } + @Override public void testFromPB() throws Exception { checkModel(fromPB(AS_PB)); } http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellSetModel.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellSetModel.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellSetModel.java index 08cd0e4..56c2679 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellSetModel.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestCellSetModel.java @@ -80,6 +80,7 @@ public class TestCellSetModel extends TestModelBase<CellSetModel> { "\"timestamp\":1245393318192,\"$\":\"dGVzdHZhbHVlMw==\"}]}]}"; } + @Override protected CellSetModel buildTestModel() { CellSetModel model = new CellSetModel(); RowModel row; @@ -95,6 +96,7 @@ public class TestCellSetModel extends TestModelBase<CellSetModel> { return model; } + @Override protected void checkModel(CellSetModel model) { Iterator<RowModel> rows = model.getRows().iterator(); RowModel row = rows.next(); @@ -104,7 +106,7 @@ public class TestCellSetModel extends TestModelBase<CellSetModel> { assertTrue(Bytes.equals(COLUMN1, cell.getColumn())); assertTrue(Bytes.equals(VALUE1, cell.getValue())); assertTrue(cell.hasUserTimestamp()); - assertEquals(cell.getTimestamp(), TIMESTAMP1); + assertEquals(TIMESTAMP1, cell.getTimestamp()); assertFalse(cells.hasNext()); row = rows.next(); assertTrue(Bytes.equals(ROW2, row.getKey())); @@ -113,26 +115,28 @@ public class TestCellSetModel extends TestModelBase<CellSetModel> { assertTrue(Bytes.equals(COLUMN2, cell.getColumn())); assertTrue(Bytes.equals(VALUE2, cell.getValue())); assertTrue(cell.hasUserTimestamp()); - assertEquals(cell.getTimestamp(), TIMESTAMP2); + assertEquals(TIMESTAMP2, cell.getTimestamp()); cell = cells.next(); assertTrue(Bytes.equals(COLUMN3, cell.getColumn())); assertTrue(Bytes.equals(VALUE3, cell.getValue())); assertTrue(cell.hasUserTimestamp()); - assertEquals(cell.getTimestamp(), TIMESTAMP3); + assertEquals(TIMESTAMP3, cell.getTimestamp()); assertFalse(cells.hasNext()); } + @Override public void testBuildModel() throws Exception { checkModel(buildTestModel()); } + @Override public void testFromXML() throws Exception { checkModel(fromXML(AS_XML)); } + @Override public void testFromPB() throws Exception { checkModel(fromPB(AS_PB)); } } - http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestColumnSchemaModel.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestColumnSchemaModel.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestColumnSchemaModel.java index bf1d204..f8fa963 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestColumnSchemaModel.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestColumnSchemaModel.java @@ -47,6 +47,7 @@ public class TestColumnSchemaModel extends TestModelBase<ColumnSchemaModel> { "\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}"; } + @Override protected ColumnSchemaModel buildTestModel() { ColumnSchemaModel model = new ColumnSchemaModel(); model.setName(COLUMN_NAME); @@ -60,18 +61,19 @@ public class TestColumnSchemaModel extends TestModelBase<ColumnSchemaModel> { return model; } + @Override protected void checkModel(ColumnSchemaModel model) { - assertEquals(model.getName(), COLUMN_NAME); - assertEquals(model.__getBlockcache(), BLOCKCACHE); - assertEquals(model.__getBlocksize(), BLOCKSIZE); - assertEquals(model.__getBloomfilter(), BLOOMFILTER); + assertEquals(COLUMN_NAME, model.getName()); + assertEquals(BLOCKCACHE, model.__getBlockcache()); + assertEquals(BLOCKSIZE, model.__getBlocksize()); + assertEquals(BLOOMFILTER, model.__getBloomfilter()); assertTrue(model.__getCompression().equalsIgnoreCase(COMPRESSION)); - assertEquals(model.__getInMemory(), IN_MEMORY); - assertEquals(model.__getTTL(), TTL); - assertEquals(model.__getVersions(), VERSIONS); + assertEquals(IN_MEMORY, model.__getInMemory()); + assertEquals(TTL, model.__getTTL()); + assertEquals(VERSIONS, model.__getVersions()); } + @Override public void testFromPB() throws Exception { } } - http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestModelBase.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestModelBase.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestModelBase.java index 293110a..ad3a667 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestModelBase.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestModelBase.java @@ -93,7 +93,7 @@ public abstract class TestModelBase<T> extends TestCase { protected T fromPB(String pb) throws Exception { return (T)clazz.getMethod("getObjectFromMessage", byte[].class).invoke( - clazz.newInstance(), + clazz.getDeclaredConstructor().newInstance(), Base64.decode(AS_PB)); } http://git-wip-us.apache.org/repos/asf/hbase/blob/3436ed95/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestNamespacesInstanceModel.java ---------------------------------------------------------------------- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestNamespacesInstanceModel.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestNamespacesInstanceModel.java index c1bf0c8..1a0fd1b 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestNamespacesInstanceModel.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestNamespacesInstanceModel.java @@ -53,6 +53,7 @@ public class TestNamespacesInstanceModel extends TestModelBase<NamespacesInstanc "\"KEY_1\":\"VALUE_1\",\"KEY_2\":\"VALUE_2\"}}"; } + @Override protected NamespacesInstanceModel buildTestModel() { return buildTestModel(NAMESPACE_NAME, NAMESPACE_PROPERTIES); } @@ -65,6 +66,7 @@ public class TestNamespacesInstanceModel extends TestModelBase<NamespacesInstanc return model; } + @Override protected void checkModel(NamespacesInstanceModel model) { checkModel(model, NAMESPACE_NAME, NAMESPACE_PROPERTIES); } @@ -81,17 +83,20 @@ public class TestNamespacesInstanceModel extends TestModelBase<NamespacesInstanc } @Test + @Override public void testBuildModel() throws Exception { checkModel(buildTestModel()); } @Test + @Override public void testFromXML() throws Exception { checkModel(fromXML(AS_XML)); } @Test + @Override public void testFromPB() throws Exception { checkModel(fromPB(AS_PB)); } -} \ No newline at end of file +}