This is an automated email from the ASF dual-hosted git repository.
janh pushed a commit to branch branch-1
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-1 by this push:
new 02d80b2 HBASE-23623 Reduced the number of Checkstyle violations in
hbase-rest
02d80b2 is described below
commit 02d80b240bbb3ab244bbfc45b1a37a0202c22598
Author: Jan Hentschel <[email protected]>
AuthorDate: Thu Jan 23 13:03:28 2020 +0100
HBASE-23623 Reduced the number of Checkstyle violations in hbase-rest
Signed-off-by: stack <[email protected]>
---
.../hadoop/hbase/rest/PerformanceEvaluation.java | 24 +++-----
.../hadoop/hbase/rest/TestGetAndPutResource.java | 40 ++++++-------
.../hbase/rest/TestNamespacesInstanceResource.java | 42 ++++++-------
.../hadoop/hbase/rest/TestNamespacesResource.java | 12 ++--
.../hadoop/hbase/rest/TestScannersWithLabels.java | 9 ++-
.../hadoop/hbase/rest/TestSchemaResource.java | 42 +++++++------
.../apache/hadoop/hbase/rest/TestTableScan.java | 64 +++++++++-----------
.../hbase/rest/client/TestRemoteHTableRetries.java | 25 ++++----
.../hadoop/hbase/rest/client/TestRemoteTable.java | 69 ++++++++++------------
.../hadoop/hbase/rest/model/TestScannerModel.java | 3 -
.../rest/model/TestStorageClusterStatusModel.java | 7 +--
11 files changed, 154 insertions(+), 183 deletions(-)
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 17b1f53..ed142b7 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
@@ -305,10 +305,6 @@ public class PerformanceEvaluation extends Configured
implements Tool {
return totalRows;
}
- public int getClients() {
- return clients;
- }
-
public boolean isFlushCommits() {
return flushCommits;
}
@@ -486,11 +482,11 @@ public class PerformanceEvaluation extends Configured
implements Tool {
@Override
protected void map(NullWritable key, PeInputSplit value, final Context
context)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException {
Status status = new Status() {
@Override
public void setStatus(String msg) {
- context.setStatus(msg);
+ context.setStatus(msg);
}
};
@@ -631,7 +627,7 @@ public class PerformanceEvaluation extends Configured
implements Tool {
perClientRows, R,
flushCommits, writeToWAL, useTags, noOfTags, connection, new
Status() {
@Override
- public void setStatus(final String msg) throws IOException {
+ public void setStatus(final String msg) {
LOG.info("client-" + getName() + " " + msg);
}
});
@@ -781,7 +777,6 @@ public class PerformanceEvaluation extends Configured
implements Tool {
private int startRow;
private int perClientRunRows;
private int totalRows;
- private int numClientThreads;
private TableName tableName;
private boolean flushCommits;
private boolean writeToWAL;
@@ -789,13 +784,12 @@ public class PerformanceEvaluation extends Configured
implements Tool {
private int noOfTags;
private Connection connection;
- TestOptions(int startRow, int perClientRunRows, int totalRows, int
numClientThreads,
- TableName tableName, boolean flushCommits, boolean writeToWAL, boolean
useTags,
+ TestOptions(int startRow, int perClientRunRows, int totalRows, TableName
tableName,
+ boolean flushCommits, boolean writeToWAL, boolean useTags,
int noOfTags, Connection connection) {
this.startRow = startRow;
this.perClientRunRows = perClientRunRows;
this.totalRows = totalRows;
- this.numClientThreads = numClientThreads;
this.tableName = tableName;
this.flushCommits = flushCommits;
this.writeToWAL = writeToWAL;
@@ -816,10 +810,6 @@ public class PerformanceEvaluation extends Configured
implements Tool {
return totalRows;
}
- public int getNumClientThreads() {
- return numClientThreads;
- }
-
public TableName getTableName() {
return tableName;
}
@@ -1286,7 +1276,7 @@ public class PerformanceEvaluation extends Configured
implements Tool {
long totalElapsedTime;
TestOptions options = new TestOptions(startRow, perClientRunRows,
- totalRows, N, tableName, flushCommits, writeToWAL, useTags, noOfTags,
connection);
+ totalRows, tableName, flushCommits, writeToWAL, useTags, noOfTags,
connection);
final Test t;
try {
Constructor<? extends Test> constructor = cmd.getDeclaredConstructor(
@@ -1310,7 +1300,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 {
+ public void setStatus(String msg) {
LOG.info(msg);
}
};
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 ba0f928..2252314 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
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.hadoop.hbase.rest;
import static org.junit.Assert.assertEquals;
@@ -46,7 +45,6 @@ import org.junit.experimental.categories.Category;
@Category(MediumTests.class)
public class TestGetAndPutResource extends RowResourceBase {
-
private static final MetricsAssertHelper METRICS_ASSERT =
CompatibilityFactory.getInstance(MetricsAssertHelper.class);
@@ -110,7 +108,7 @@ public class TestGetAndPutResource extends RowResourceBase {
public void testSingleCellGetPutPB() throws IOException, JAXBException {
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
assertEquals(404, response.getCode());
-
+
response = putValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
assertEquals(200, response.getCode());
checkValuePB(TABLE, ROW_1, COLUMN_1, VALUE_1);
@@ -130,7 +128,7 @@ public class TestGetAndPutResource extends RowResourceBase {
}
@Test
- public void testMultipleCellCheckPutPB() throws IOException, JAXBException {
+ public void testMultipleCellCheckPutPB() throws IOException {
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
assertEquals(404, response.getCode());
@@ -143,7 +141,7 @@ public class TestGetAndPutResource extends RowResourceBase {
assertEquals(200, response.getCode());
checkValuePB(TABLE, ROW_1, COLUMN_2, VALUE_2);
- HashMap<String,String> otherCells = new HashMap<String, String>();
+ HashMap<String,String> otherCells = new HashMap<>();
otherCells.put(COLUMN_2,VALUE_3);
// On Success update both the cells
@@ -176,7 +174,7 @@ public class TestGetAndPutResource extends RowResourceBase {
assertEquals(200, response.getCode());
checkValueXML(TABLE, ROW_1, COLUMN_2, VALUE_2);
- HashMap<String,String> otherCells = new HashMap<String, String>();
+ HashMap<String,String> otherCells = new HashMap<>();
otherCells.put(COLUMN_2,VALUE_3);
// On Success update both the cells
@@ -196,7 +194,7 @@ public class TestGetAndPutResource extends RowResourceBase {
}
@Test
- public void testMultipleCellCheckDeletePB() throws IOException,
JAXBException {
+ public void testMultipleCellCheckDeletePB() throws IOException {
Response response = getValuePB(TABLE, ROW_1, COLUMN_1);
assertEquals(404, response.getCode());
@@ -214,7 +212,7 @@ public class TestGetAndPutResource extends RowResourceBase {
checkValuePB(TABLE, ROW_1, COLUMN_3, VALUE_3);
// Deletes the following columns based on Column1 check
- HashMap<String,String> cellsToDelete = new HashMap<String, String>();
+ HashMap<String,String> cellsToDelete = new HashMap<>();
cellsToDelete.put(COLUMN_2,VALUE_2); // Value does not matter
cellsToDelete.put(COLUMN_3,VALUE_3); // Value does not matter
@@ -249,7 +247,7 @@ public class TestGetAndPutResource extends RowResourceBase {
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);
@@ -275,7 +273,7 @@ public class TestGetAndPutResource extends RowResourceBase {
}
@Test
- public void testSingleCellGetJSON() throws IOException, JAXBException {
+ public void testSingleCellGetJSON() throws IOException {
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
Response response = client.put(path, Constants.MIMETYPE_BINARY,
Bytes.toBytes(VALUE_4));
@@ -289,7 +287,7 @@ public class TestGetAndPutResource extends RowResourceBase {
}
@Test
- public void testLatestCellGetJSON() throws IOException, JAXBException {
+ public void testLatestCellGetJSON() throws IOException {
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_4);
@@ -336,7 +334,7 @@ public class TestGetAndPutResource extends RowResourceBase {
}
@Test
- public void testNoSuchCF() throws IOException, JAXBException {
+ public void testNoSuchCF() throws IOException {
final String goodPath = "/" + TABLE + "/" + ROW_1 + "/" + CFA+":";
final String badPath = "/" + TABLE + "/" + ROW_1 + "/" + "BAD";
Response response = client.post(goodPath, Constants.MIMETYPE_BINARY,
@@ -524,9 +522,9 @@ public class TestGetAndPutResource extends RowResourceBase {
response = deleteRow(TABLE, ROW_2);
assertEquals(200, response.getCode());
}
-
+
@Test
- public void testMetrics() throws IOException, JAXBException {
+ public void testMetrics() throws IOException {
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
Response response = client.put(path, Constants.MIMETYPE_BINARY,
Bytes.toBytes(VALUE_4));
@@ -539,19 +537,19 @@ public class TestGetAndPutResource extends
RowResourceBase {
assertEquals(200, response.getCode());
UserProvider userProvider = UserProvider.instantiate(conf);
- METRICS_ASSERT.assertCounterGt("requests", 2l,
+ METRICS_ASSERT.assertCounterGt("requests", 2L,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());
- METRICS_ASSERT.assertCounterGt("successfulGet", 0l,
+ METRICS_ASSERT.assertCounterGt("successfulGet", 0L,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());
- METRICS_ASSERT.assertCounterGt("successfulPut", 0l,
+ METRICS_ASSERT.assertCounterGt("successfulPut", 0L,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());
- METRICS_ASSERT.assertCounterGt("successfulDelete", 0l,
+ METRICS_ASSERT.assertCounterGt("successfulDelete", 0L,
RESTServlet.getInstance(conf, userProvider).getMetrics().getSource());
}
-
+
@Test
public void testMultiColumnGetXML() throws Exception {
String path = "/" + TABLE + "/fakerow";
@@ -575,8 +573,8 @@ public class TestGetAndPutResource extends RowResourceBase {
path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "," + COLUMN_2 + "," +
COLUMN_3;
response = client.get(path, Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
- CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new
ByteArrayInputStream(response
- .getBody()));
+ CellSetModel cellSet =
+ (CellSetModel) xmlUnmarshaller.unmarshal(new
ByteArrayInputStream(response.getBody()));
assertTrue(cellSet.getRows().size() == 1);
assertTrue(cellSet.getRows().get(0).getCells().size() == 3);
List<CellModel> cells = cellSet.getRows().get(0).getCells();
diff --git
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestNamespacesInstanceResource.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestNamespacesInstanceResource.java
index cf7d3a3..fb8ddcd 100644
---
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestNamespacesInstanceResource.java
+++
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestNamespacesInstanceResource.java
@@ -1,5 +1,4 @@
/*
- *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,6 +17,11 @@
*/
package org.apache.hadoop.hbase.rest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.ByteArrayInputStream;
@@ -51,8 +55,6 @@ import org.apache.hadoop.hbase.rest.provider.JacksonProvider;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import static org.junit.Assert.*;
-
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -61,13 +63,13 @@ import org.junit.experimental.categories.Category;
@Category(MediumTests.class)
public class TestNamespacesInstanceResource {
private static String NAMESPACE1 = "TestNamespacesInstanceResource1";
- private static Map<String,String> NAMESPACE1_PROPS = new
HashMap<String,String>();
+ private static Map<String,String> NAMESPACE1_PROPS = new HashMap<>();
private static String NAMESPACE2 = "TestNamespacesInstanceResource2";
- private static Map<String,String> NAMESPACE2_PROPS = new
HashMap<String,String>();
+ private static Map<String,String> NAMESPACE2_PROPS = new HashMap<>();
private static String NAMESPACE3 = "TestNamespacesInstanceResource3";
- private static Map<String,String> NAMESPACE3_PROPS = new
HashMap<String,String>();
+ private static Map<String,String> NAMESPACE3_PROPS = new HashMap<>();
private static String NAMESPACE4 = "TestNamespacesInstanceResource4";
- private static Map<String,String> NAMESPACE4_PROPS = new
HashMap<String,String>();
+ private static Map<String,String> NAMESPACE4_PROPS = new HashMap<>();
private static final HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
private static final HBaseRESTTestingUtility REST_TEST_UTIL =
@@ -87,8 +89,8 @@ public class TestNamespacesInstanceResource {
REST_TEST_UTIL.getServletPort()));
testNamespacesInstanceModel = new TestNamespacesInstanceModel();
context = JAXBContext.newInstance(NamespacesInstanceModel.class,
TableListModel.class);
- jsonMapper = new JacksonProvider()
- .locateMapper(NamespacesInstanceModel.class,
MediaType.APPLICATION_JSON_TYPE);
+ jsonMapper = new
JacksonProvider().locateMapper(NamespacesInstanceModel.class,
+ MediaType.APPLICATION_JSON_TYPE);
NAMESPACE1_PROPS.put("key1", "value1");
NAMESPACE2_PROPS.put("key2a", "value2a");
NAMESPACE2_PROPS.put("key2b", "value2b");
@@ -117,9 +119,9 @@ public class TestNamespacesInstanceResource {
private NamespaceDescriptor findNamespace(Admin admin, String namespaceName)
throws IOException{
NamespaceDescriptor[] nd = admin.listNamespaceDescriptors();
- for(int i = 0; i < nd.length; i++){
- if(nd[i].getName().equals(namespaceName)){
- return nd[i];
+ for (NamespaceDescriptor namespaceDescriptor : nd) {
+ if (namespaceDescriptor.getName().equals(namespaceName)) {
+ return namespaceDescriptor;
}
}
return null;
@@ -129,18 +131,18 @@ public class TestNamespacesInstanceResource {
checkNamespaceProperties(nd.getConfiguration(), testProps);
}
- private void checkNamespaceProperties(Map<String,String> namespaceProps,
+ private void checkNamespaceProperties(Map<String,String> namespaceProps,
Map<String,String> testProps){
assertTrue(namespaceProps.size() == testProps.size());
- for(String key: testProps.keySet()){
+ for (String key: testProps.keySet()) {
assertEquals(testProps.get(key), namespaceProps.get(key));
}
}
private void checkNamespaceTables(List<TableModel> namespaceTables,
List<String> testTables){
assertEquals(namespaceTables.size(), testTables.size());
- for(int i = 0 ; i < namespaceTables.size() ; i++){
- String tableName = ((TableModel) namespaceTables.get(i)).getName();
+ for (TableModel namespaceTable : namespaceTables) {
+ String tableName = namespaceTable.getName();
assertTrue(testTables.contains(tableName));
}
}
@@ -174,7 +176,7 @@ public class TestNamespacesInstanceResource {
// Create namespace via admin.
NamespaceDescriptor.Builder nsBuilder = NamespaceDescriptor.create(nsName);
- NamespaceDescriptor nsd = nsBuilder.build();
+ NamespaceDescriptor nsd = nsBuilder.build();
nsd.setConfiguration("key1", "value1");
admin.createNamespace(nsd);
@@ -189,7 +191,7 @@ public class TestNamespacesInstanceResource {
table.addFamily(colDesc);
admin.createTable(table);
- Map<String, String> nsProperties = new HashMap<String,String>();
+ Map<String, String> nsProperties = new HashMap<>();
nsProperties.put("key1", "value1");
List<String> nsTables = Arrays.asList("table1", "table2");
@@ -357,7 +359,7 @@ public class TestNamespacesInstanceResource {
}
@Test
- public void testNamespaceCreateAndDeletePBAndNoBody() throws IOException,
JAXBException {
+ public void testNamespaceCreateAndDeletePBAndNoBody() throws IOException {
String namespacePath3 = "/namespaces/" + NAMESPACE3;
String namespacePath4 = "/namespaces/" + NAMESPACE4;
NamespacesInstanceModel model3;
@@ -412,7 +414,7 @@ public class TestNamespacesInstanceResource {
// Check cannot post tables that already exist.
response = client.post(namespacePath3, Constants.MIMETYPE_BINARY, new
byte[]{});
assertEquals(403, response.getCode());
- response = client.post(namespacePath4, Constants.MIMETYPE_PROTOBUF,
+ response = client.post(namespacePath4, Constants.MIMETYPE_PROTOBUF,
model4.createProtobufOutput());
assertEquals(403, response.getCode());
diff --git
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestNamespacesResource.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestNamespacesResource.java
index a70835f..ee72db0 100644
---
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestNamespacesResource.java
+++
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestNamespacesResource.java
@@ -1,5 +1,4 @@
/*
- *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,6 +17,9 @@
*/
package org.apache.hadoop.hbase.rest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -36,8 +38,6 @@ import org.apache.hadoop.hbase.rest.model.TestNamespacesModel;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import static org.junit.Assert.*;
-
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -79,8 +79,8 @@ public class TestNamespacesResource {
private boolean doesNamespaceExist(Admin admin, String namespaceName) throws
IOException {
NamespaceDescriptor[] nd = admin.listNamespaceDescriptors();
- for(int i = 0; i < nd.length; i++) {
- if(nd[i].getName().equals(namespaceName)) {
+ for (NamespaceDescriptor namespaceDescriptor : nd) {
+ if (namespaceDescriptor.getName().equals(namespaceName)) {
return true;
}
}
@@ -152,7 +152,7 @@ public class TestNamespacesResource {
}
@Test
- public void testNamespaceListPBandDefault() throws IOException,
JAXBException {
+ public void testNamespaceListPBandDefault() throws IOException {
String schemaPath = "/namespaces/";
NamespacesModel model;
Response response;
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 356889a..89fe3d4 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
@@ -14,7 +14,8 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */package org.apache.hadoop.hbase.rest;
+ */
+package org.apache.hadoop.hbase.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -91,7 +92,8 @@ public class TestScannersWithLabels {
private static Unmarshaller unmarshaller;
private static Configuration conf;
- private static int insertData(TableName tableName, String column, double
prob) throws IOException {
+ private static int insertData(TableName tableName, String column, double
prob)
+ throws IOException {
byte[] k = new byte[3];
byte[][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(column));
@@ -177,6 +179,7 @@ public class TestScannersWithLabels {
};
SUPERUSER.runAs(action);
}
+
private static void setAuths() throws Exception {
String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET };
try (Connection conn = ConnectionFactory.createConnection(conf)) {
@@ -185,6 +188,7 @@ public class TestScannersWithLabels {
throw new IOException(t);
}
}
+
@Test
public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws
IOException, JAXBException {
final int BATCH_SIZE = 5;
@@ -237,5 +241,4 @@ public class TestScannersWithLabels {
.getBody()));
assertEquals(5, countCellSet(cellSet));
}
-
}
diff --git
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java
index 7ca56f3..a25ce26 100644
---
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java
+++
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java
@@ -1,5 +1,4 @@
/*
- *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,9 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.hadoop.hbase.rest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
@@ -44,8 +46,6 @@ import org.apache.hadoop.hbase.rest.model.TableSchemaModel;
import org.apache.hadoop.hbase.rest.model.TestTableSchemaModel;
import org.apache.hadoop.hbase.util.Bytes;
-import static org.junit.Assert.*;
-
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -67,7 +67,7 @@ public class TestSchemaResource {
private static Configuration conf;
private static TestTableSchemaModel testTableSchemaModel;
private static Header extraHdr = null;
-
+
private static boolean csrfEnabled = true;
@Parameterized.Parameters
@@ -130,27 +130,27 @@ public class TestSchemaResource {
if (csrfEnabled) {
// test put operation is forbidden without custom header
response = client.put(schemaPath, Constants.MIMETYPE_XML, toXML(model));
- assertEquals(response.getCode(), 400);
+ assertEquals(400, response.getCode());
}
response = client.put(schemaPath, Constants.MIMETYPE_XML, toXML(model),
extraHdr);
- assertEquals(response.getCode(), 201);
+ assertEquals(201, response.getCode());
// recall the same put operation but in read-only mode
conf.set("hbase.rest.readonly", "true");
response = client.put(schemaPath, Constants.MIMETYPE_XML, toXML(model),
extraHdr);
- assertEquals(response.getCode(), 403);
+ assertEquals(403, response.getCode());
// retrieve the schema and validate it
response = client.get(schemaPath, Constants.MIMETYPE_XML);
- assertEquals(response.getCode(), 200);
+ assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
model = fromXML(response.getBody());
testTableSchemaModel.checkModel(model, TABLE1);
// with json retrieve the schema and validate it
response = client.get(schemaPath, Constants.MIMETYPE_JSON);
- assertEquals(response.getCode(), 200);
+ assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
model = testTableSchemaModel.fromJSON(Bytes.toString(response.getBody()));
testTableSchemaModel.checkModel(model, TABLE1);
@@ -163,19 +163,19 @@ public class TestSchemaResource {
// test delete schema operation is forbidden in read-only mode
response = client.delete(schemaPath, extraHdr);
- assertEquals(response.getCode(), 403);
+ assertEquals(403, response.getCode());
// return read-only setting back to default
conf.set("hbase.rest.readonly", "false");
// delete the table and make sure HBase concurs
response = client.delete(schemaPath, extraHdr);
- assertEquals(response.getCode(), 200);
+ assertEquals(200, response.getCode());
assertFalse(admin.tableExists(TableName.valueOf(TABLE1)));
}
@Test
- public void testTableCreateAndDeletePB() throws IOException, JAXBException {
+ public void testTableCreateAndDeletePB() throws IOException {
String schemaPath = "/" + TABLE2 + "/schema";
TableSchemaModel model;
Response response;
@@ -190,22 +190,22 @@ public class TestSchemaResource {
if (csrfEnabled) {
// test put operation is forbidden without custom header
response = client.put(schemaPath, Constants.MIMETYPE_PROTOBUF,
model.createProtobufOutput());
- assertEquals(response.getCode(), 400);
+ assertEquals(400, response.getCode());
}
response = client.put(schemaPath, Constants.MIMETYPE_PROTOBUF,
model.createProtobufOutput(), extraHdr);
- assertEquals(response.getCode(), 201);
+ assertEquals(201, response.getCode());
// recall the same put operation but in read-only mode
conf.set("hbase.rest.readonly", "true");
response = client.put(schemaPath, Constants.MIMETYPE_PROTOBUF,
model.createProtobufOutput(), extraHdr);
assertNotNull(extraHdr);
- assertEquals(response.getCode(), 403);
+ assertEquals(403, response.getCode());
// retrieve the schema and validate it
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF);
- assertEquals(response.getCode(), 200);
+ assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_PROTOBUF,
response.getHeader("content-type"));
model = new TableSchemaModel();
model.getObjectFromMessage(response.getBody());
@@ -213,7 +213,7 @@ public class TestSchemaResource {
// retrieve the schema and validate it with alternate pbuf type
response = client.get(schemaPath, Constants.MIMETYPE_PROTOBUF_IETF);
- assertEquals(response.getCode(), 200);
+ assertEquals(200, response.getCode());
assertEquals(Constants.MIMETYPE_PROTOBUF_IETF,
response.getHeader("content-type"));
model = new TableSchemaModel();
model.getObjectFromMessage(response.getBody());
@@ -227,16 +227,14 @@ public class TestSchemaResource {
// test delete schema operation is forbidden in read-only mode
response = client.delete(schemaPath, extraHdr);
- assertEquals(response.getCode(), 403);
+ assertEquals(403, response.getCode());
// return read-only setting back to default
conf.set("hbase.rest.readonly", "false");
// delete the table and make sure HBase concurs
response = client.delete(schemaPath, extraHdr);
- assertEquals(response.getCode(), 200);
+ assertEquals(200, response.getCode());
assertFalse(admin.tableExists(TableName.valueOf(TABLE2)));
}
-
}
-
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 03d4360..f4810be 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
@@ -47,13 +47,11 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.parsers.SAXParserFactory;
-import javax.xml.stream.XMLStreamException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.filter.Filter;
@@ -66,6 +64,7 @@ import org.apache.hadoop.hbase.rest.model.CellModel;
import org.apache.hadoop.hbase.rest.model.CellSetModel;
import org.apache.hadoop.hbase.rest.model.RowModel;
import org.apache.hadoop.hbase.rest.provider.JacksonProvider;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -76,7 +75,6 @@ import org.xml.sax.XMLReader;
@Category(MediumTests.class)
public class TestTableScan {
-
private static final TableName TABLE = TableName.valueOf("TestScanResource");
private static final String CFA = "a";
private static final String CFB = "b";
@@ -96,7 +94,7 @@ public class TestTableScan {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
conf = TEST_UTIL.getConfiguration();
- conf.set(Constants.CUSTOM_FILTERS, "CustomFilter:" +
CustomFilter.class.getName());
+ conf.set(Constants.CUSTOM_FILTERS, "CustomFilter:" +
CustomFilter.class.getName());
TEST_UTIL.startMiniCluster();
REST_TEST_UTIL.startServletContainer(conf);
client = new Client(new Cluster().add("localhost",
@@ -122,7 +120,7 @@ public class TestTableScan {
}
@Test
- public void testSimpleScannerXML() throws IOException, JAXBException,
XMLStreamException {
+ public void testSimpleScannerXML() throws IOException, JAXBException {
// Test scanning particular columns
StringBuilder builder = new StringBuilder();
builder.append("/*");
@@ -149,7 +147,7 @@ public class TestTableScan {
response = client.get("/" + TABLE + builder.toString(),
Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
- assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
+ assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
model = (CellSetModel) ush.unmarshal(response.getStream());
count = TestScannerResource.countCellSet(model);
assertEquals(expectedRows1, count);
@@ -198,7 +196,7 @@ public class TestTableScan {
}
@Test
- public void testSimpleScannerJson() throws IOException, JAXBException {
+ public void testSimpleScannerJson() throws IOException {
// Test scanning particular columns with limit.
StringBuilder builder = new StringBuilder();
builder.append("/*");
@@ -285,16 +283,16 @@ public class TestTableScan {
unmarshaller.setListener(new Unmarshaller.Listener() {
@Override
public void beforeUnmarshal(Object target, Object parent) {
- if (target instanceof ClientSideCellSetModel) {
- ((ClientSideCellSetModel)
target).setCellSetModelListener(listener);
- }
+ if (target instanceof ClientSideCellSetModel) {
+ ((ClientSideCellSetModel)
target).setCellSetModelListener(listener);
+ }
}
@Override
public void afterUnmarshal(Object target, Object parent) {
- if (target instanceof ClientSideCellSetModel) {
- ((ClientSideCellSetModel)
target).setCellSetModelListener(null);
- }
+ if (target instanceof ClientSideCellSetModel) {
+ ((ClientSideCellSetModel) target).setCellSetModelListener(null);
+ }
}
});
@@ -396,7 +394,7 @@ public class TestTableScan {
int rowCount = readProtobufStream(response.getStream());
assertEquals(15, rowCount);
- //Test with start row and end row.
+ //Test with start row and end row.
builder = new StringBuilder();
builder.append("/*");
builder.append("?");
@@ -455,7 +453,7 @@ public class TestTableScan {
}
@Test
- public void testScanningUnknownColumnJson() throws IOException,
JAXBException {
+ public void testScanningUnknownColumnJson() throws IOException {
// Test scanning particular columns with limit.
StringBuilder builder = new StringBuilder();
builder.append("/*");
@@ -471,7 +469,7 @@ public class TestTableScan {
int count = TestScannerResource.countCellSet(model);
assertEquals(0, count);
}
-
+
@Test
public void testSimpleFilter() throws IOException, JAXBException {
StringBuilder builder = new StringBuilder();
@@ -503,7 +501,7 @@ public class TestTableScan {
builder.append("?");
builder.append(Constants.SCAN_FILTER + "="
+ URLEncoder.encode("QualifierFilter(=,'binary:1')", "UTF-8"));
- Response response =
+ Response response =
client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
JAXBContext ctx = JAXBContext.newInstance(CellSetModel.class);
@@ -515,7 +513,6 @@ public class TestTableScan {
StandardCharsets.UTF_8));
}
-
@Test
public void testCompoundFilter() throws IOException, JAXBException {
StringBuilder builder = new StringBuilder();
@@ -554,7 +551,7 @@ public class TestTableScan {
assertEquals("abc", new
String(model.getRows().get(0).getCells().get(0).getValue(),
StandardCharsets.UTF_8));
}
-
+
@Test
public void testNegativeCustomFilter() throws IOException, JAXBException {
StringBuilder builder = new StringBuilder();
@@ -625,7 +622,7 @@ public class TestTableScan {
}
@Test
- public void testColumnWithEmptyQualifier() throws IOException, JAXBException
{
+ public void testColumnWithEmptyQualifier() throws IOException {
// Test scanning with empty qualifier
StringBuilder builder = new StringBuilder();
builder.append("/*");
@@ -670,7 +667,7 @@ public class TestTableScan {
public CustomFilter(byte[] key) {
super(key);
}
-
+
@Override
public boolean filterRowKey(byte[] buffer, int offset, int length) {
int cmp = Bytes.compareTo(buffer, offset, length, this.key, 0,
this.key.length);
@@ -690,7 +687,6 @@ public class TestTableScan {
@XmlRootElement(name = "CellSet")
@XmlAccessorType(XmlAccessType.FIELD)
public static class ClientSideCellSetModel implements Serializable {
-
private static final long serialVersionUID = 1L;
/**
@@ -707,25 +703,23 @@ public class TestTableScan {
* is removed again.
*/
public void setCellSetModelListener(final Listener l) {
- row = (l == null) ? null : new ArrayList<RowModel>() {
+ 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;
- return false;
- }
- };
+
+ @Override
+ public boolean add(RowModel o) {
+ l.handleRowModel(ClientSideCellSetModel.this, o);
+ listenerInvoked = true;
+ return false;
+ }
+ };
}
/**
* This listener is invoked every time a new row model is unmarshalled.
*/
- public static interface Listener {
- void handleRowModel(ClientSideCellSetModel helper, RowModel rowModel);
+ public interface Listener {
+ void handleRowModel(ClientSideCellSetModel helper, RowModel rowModel);
}
}
}
-
-
-
diff --git
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteHTableRetries.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteHTableRetries.java
index adfeafe..5133427 100644
---
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteHTableRetries.java
+++
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteHTableRetries.java
@@ -48,13 +48,12 @@ import org.junit.experimental.categories.Category;
*/
@Category(SmallTests.class)
public class TestRemoteHTableRetries {
-
private static final int SLEEP_TIME = 50;
private static final int RETRIES = 3;
private static final long MAX_TIME = SLEEP_TIME * (RETRIES - 1);
private static final HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
-
+
private static final byte[] ROW_1 = Bytes.toBytes("testrow1");
private static final byte[] COLUMN_1 = Bytes.toBytes("a");
private static final byte[] QUALIFIER_1 = Bytes.toBytes("1");
@@ -62,7 +61,7 @@ public class TestRemoteHTableRetries {
private Client client;
private RemoteHTable remoteTable;
-
+
@Before
public void setup() throws Exception {
client = mock(Client.class);
@@ -86,7 +85,7 @@ public class TestRemoteHTableRetries {
public void tearDownAfterClass() throws Exception {
remoteTable.close();
}
-
+
@Test
public void testDelete() throws Exception {
testTimedOutCall(new CallExecutor() {
@@ -98,7 +97,7 @@ public class TestRemoteHTableRetries {
});
verify(client, times(RETRIES)).delete(anyString());
}
-
+
@Test
public void testGet() throws Exception {
testTimedOutGetCall(new CallExecutor() {
@@ -119,14 +118,13 @@ public class TestRemoteHTableRetries {
});
verify(client, times(RETRIES)).put(anyString(), anyString(),
any(byte[].class));
}
-
+
@Test
public void testMultiRowPut() throws Exception {
testTimedOutCall(new CallExecutor() {
@Override
public void run() throws Exception {
- Put[] puts = { new Put(Bytes.toBytes("Row1")),
- new Put(Bytes.toBytes("Row2")) };
+ Put[] puts = { new Put(Bytes.toBytes("Row1")), new
Put(Bytes.toBytes("Row2")) };
remoteTable.put(Arrays.asList(puts));
}
});
@@ -143,7 +141,7 @@ public class TestRemoteHTableRetries {
});
verify(client, times(RETRIES)).post(anyString(), anyString(),
any(byte[].class));
}
-
+
@Test
public void testCheckAndPut() throws Exception {
testTimedOutCall(new CallExecutor() {
@@ -165,16 +163,16 @@ public class TestRemoteHTableRetries {
Put put = new Put(ROW_1);
put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
Delete delete= new Delete(ROW_1);
- remoteTable.checkAndDelete(ROW_1, COLUMN_1, QUALIFIER_1, VALUE_1,
delete );
+ remoteTable.checkAndDelete(ROW_1, COLUMN_1, QUALIFIER_1, VALUE_1,
delete);
}
});
}
-
+
private void testTimedOutGetCall(CallExecutor callExecutor) throws Exception
{
testTimedOutCall(callExecutor);
verify(client, times(RETRIES)).get(anyString(), anyString());
}
-
+
private void testTimedOutCall(CallExecutor callExecutor) throws Exception {
long start = System.currentTimeMillis();
try {
@@ -186,8 +184,7 @@ public class TestRemoteHTableRetries {
assertTrue((System.currentTimeMillis() - start) > MAX_TIME);
}
- private static interface CallExecutor {
+ private interface CallExecutor {
void run() throws Exception;
}
-
}
diff --git
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java
index 9613e9f..469e1af 100644
---
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java
+++
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/client/TestRemoteTable.java
@@ -1,5 +1,4 @@
/*
- *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.hadoop.hbase.rest.client;
import static org.junit.Assert.assertEquals;
@@ -60,7 +58,6 @@ import org.junit.experimental.categories.Category;
@Category(MediumTests.class)
public class TestRemoteTable {
-
// Verify that invalid URL characters and arbitrary bytes are escaped when
// constructing REST URLs per HBASE-7621. RemoteHTable should support row
keys
// and qualifiers containing any byte for all table operations.
@@ -97,7 +94,7 @@ public class TestRemoteTable {
private static final long TS_1 = TS_2 - ONE_HOUR;
private static final HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
- private static final HBaseRESTTestingUtility REST_TEST_UTIL =
+ private static final HBaseRESTTestingUtility REST_TEST_UTIL =
new HBaseRESTTestingUtility();
private RemoteHTable remoteTable;
@@ -111,7 +108,10 @@ public class TestRemoteTable {
public void before() throws Exception {
Admin admin = TEST_UTIL.getHBaseAdmin();
if (admin.tableExists(TABLE)) {
- if (admin.isTableEnabled(TABLE)) admin.disableTable(TABLE);
+ if (admin.isTableEnabled(TABLE)) {
+ admin.disableTable(TABLE);
+ }
+
admin.deleteTable(TABLE);
}
HTableDescriptor htd = new HTableDescriptor(TABLE);
@@ -130,16 +130,16 @@ public class TestRemoteTable {
table.put(put);
}
remoteTable = new RemoteHTable(
- new Client(new Cluster().add("localhost",
+ new Client(new Cluster().add("localhost",
REST_TEST_UTIL.getServletPort())),
TEST_UTIL.getConfiguration(), TABLE.toBytes());
}
-
+
@After
public void after() throws Exception {
remoteTable.close();
}
-
+
@AfterClass
public static void tearDownAfterClass() throws Exception {
REST_TEST_UTIL.shutdownServletContainer();
@@ -216,7 +216,6 @@ public class TestRemoteTable {
assertTrue(Bytes.equals(VALUE_2, value2));
// test timestamp
-
get = new Get(ROW_2);
get.addFamily(COLUMN_1);
get.addFamily(COLUMN_2);
@@ -229,7 +228,6 @@ public class TestRemoteTable {
assertNull(value2);
// test timerange
-
get = new Get(ROW_2);
get.addFamily(COLUMN_1);
get.addFamily(COLUMN_2);
@@ -242,7 +240,6 @@ public class TestRemoteTable {
assertNull(value2);
// test maxVersions
-
get = new Get(ROW_2);
get.addFamily(COLUMN_1);
get.setMaxVersions(2);
@@ -263,7 +260,7 @@ public class TestRemoteTable {
@Test
public void testMultiGet() throws Exception {
- ArrayList<Get> gets = new ArrayList<Get>();
+ ArrayList<Get> gets = new ArrayList<>();
gets.add(new Get(ROW_1));
gets.add(new Get(ROW_2));
Result[] results = remoteTable.get(gets);
@@ -273,7 +270,7 @@ public class TestRemoteTable {
assertEquals(2, results[1].size());
//Test Versions
- gets = new ArrayList<Get>();
+ gets = new ArrayList<>();
Get g = new Get(ROW_1);
g.setMaxVersions(3);
gets.add(g);
@@ -285,13 +282,13 @@ public class TestRemoteTable {
assertEquals(3, results[1].size());
//404
- gets = new ArrayList<Get>();
+ gets = new ArrayList<>();
gets.add(new Get(Bytes.toBytes("RESALLYREALLYNOTTHERE")));
results = remoteTable.get(gets);
assertNotNull(results);
assertEquals(0, results.length);
- gets = new ArrayList<Get>();
+ gets = new ArrayList<>();
gets.add(new Get(Bytes.toBytes("RESALLYREALLYNOTTHERE")));
gets.add(new Get(ROW_1));
gets.add(new Get(ROW_2));
@@ -314,8 +311,7 @@ public class TestRemoteTable {
assertTrue(Bytes.equals(VALUE_1, value));
// multiput
-
- List<Put> puts = new ArrayList<Put>();
+ List<Put> puts = new ArrayList<>();
put = new Put(ROW_3);
put.add(COLUMN_2, QUALIFIER_2, VALUE_2);
puts.add(put);
@@ -341,8 +337,9 @@ public class TestRemoteTable {
value = result.getValue(COLUMN_2, QUALIFIER_2);
assertNotNull(value);
assertTrue(Bytes.equals(VALUE_2, value));
-
- assertTrue(Bytes.equals(Bytes.toBytes("TestRemoteTable" +
VALID_TABLE_NAME_CHARS), remoteTable.getTableName()));
+
+ assertTrue(Bytes.equals(Bytes.toBytes("TestRemoteTable" +
VALID_TABLE_NAME_CHARS),
+ remoteTable.getTableName()));
}
@Test
@@ -425,13 +422,13 @@ public class TestRemoteTable {
assertNull(value1);
assertNull(value2);
}
-
+
/**
- * Test RemoteHTable.Scanner
+ * Test RemoteHTable.Scanner
*/
@Test
public void testScanner() throws IOException {
- List<Put> puts = new ArrayList<Put>();
+ List<Put> puts = new ArrayList<>();
Put put = new Put(ROW_1);
put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
puts.add(put);
@@ -466,7 +463,7 @@ public class TestRemoteTable {
results = scanner.next(1);
assertNull(results);
scanner.close();
-
+
scanner = remoteTable.getScanner(COLUMN_1);
results = scanner.next(4);
assertNotNull(results);
@@ -477,7 +474,7 @@ public class TestRemoteTable {
assertTrue(Bytes.equals(ROW_4, results[3].getRow()));
scanner.close();
-
+
scanner = remoteTable.getScanner(COLUMN_1,QUALIFIER_1);
results = scanner.next(4);
assertNotNull(results);
@@ -488,9 +485,8 @@ public class TestRemoteTable {
assertTrue(Bytes.equals(ROW_4, results[3].getRow()));
scanner.close();
assertTrue(remoteTable.isAutoFlush());
-
}
-
+
@Test
public void testCheckAndDelete() throws IOException {
Get get = new Get(ROW_1);
@@ -511,18 +507,16 @@ public class TestRemoteTable {
put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
remoteTable.put(put);
- assertTrue(remoteTable.checkAndPut(ROW_1, COLUMN_1, QUALIFIER_1, VALUE_1,
- put));
- assertFalse(remoteTable.checkAndPut(ROW_1, COLUMN_1, QUALIFIER_1, VALUE_2,
- put));
+ assertTrue(remoteTable.checkAndPut(ROW_1, COLUMN_1, QUALIFIER_1, VALUE_1,
put));
+ assertFalse(remoteTable.checkAndPut(ROW_1, COLUMN_1, QUALIFIER_1, VALUE_2,
put));
}
-
+
/**
- * Test RemoteHable.Scanner.iterator method
+ * Test RemoteHable.Scanner.iterator method
*/
@Test
public void testIteratorScaner() throws IOException {
- List<Put> puts = new ArrayList<Put>();
+ List<Put> puts = new ArrayList<>();
Put put = new Put(ROW_1);
put.add(COLUMN_1, QUALIFIER_1, VALUE_1);
puts.add(put);
@@ -547,7 +541,7 @@ public class TestRemoteTable {
}
assertEquals(4, counter);
}
-
+
/**
* Test a some methods of class Response.
*/
@@ -569,13 +563,14 @@ public class TestRemoteTable {
response.setHeaders(headers);
assertEquals("value1.1", response.getHeader("header1"));
response.setBody(Bytes.toBytes("body"));
- assertTrue(response.hasBody());
+ assertTrue(response.hasBody());
}
/**
* Tests keeping a HBase scanner alive for long periods of time. Each call
to next() should reset
- * the ConnectionCache timeout for the scanner's connection
- * @throws Exception
+ * the ConnectionCache timeout for the scanner's connection.
+ *
+ * @throws Exception if starting the servlet container or disabling or
truncating the table fails
*/
@Test
public void testLongLivedScan() throws Exception {
diff --git
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java
index 705a552..30d6ddd 100644
---
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java
+++
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java
@@ -1,5 +1,4 @@
/*
- *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.hadoop.hbase.rest.model;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@@ -106,5 +104,4 @@ public class TestScannerModel extends
TestModelBase<ScannerModel> {
assertTrue(foundLabel2);
}
}
-
}
diff --git
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java
index 78afd2f..eb54db7 100644
---
a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java
+++
b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestStorageClusterStatusModel.java
@@ -1,5 +1,4 @@
/*
- *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.hadoop.hbase.rest.model;
import java.util.Iterator;
@@ -29,7 +27,6 @@ import org.junit.experimental.categories.Category;
@Category(SmallTests.class)
public class TestStorageClusterStatusModel extends
TestModelBase<StorageClusterStatusModel> {
-
public TestStorageClusterStatusModel() throws Exception {
super(StorageClusterStatusModel.class);
@@ -99,7 +96,7 @@ public class TestStorageClusterStatusModel extends
TestModelBase<StorageClusterS
assertEquals(1245219839331L, node.getStartCode());
assertEquals(128, node.getHeapSizeMB());
assertEquals(1024, node.getMaxHeapSizeMB());
- Iterator<StorageClusterStatusModel.Node.Region> regions =
+ Iterator<StorageClusterStatusModel.Node.Region> regions =
node.getRegions().iterator();
StorageClusterStatusModel.Node.Region region = regions.next();
assertTrue(Bytes.toString(region.getName()).equals(
@@ -138,7 +135,7 @@ public class TestStorageClusterStatusModel extends
TestModelBase<StorageClusterS
assertEquals(1, region.getTotalStaticBloomSizeKB());
assertEquals(1, region.getTotalCompactingKVs());
assertEquals(1, region.getCurrentCompactedKVs());
-
+
assertFalse(regions.hasNext());
assertFalse(nodes.hasNext());
}