You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/07/25 02:49:32 UTC

[hbase] branch branch-2.1 updated: HBASE-22382 Refactor tests in TestFromClientSide (#385)

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 884843d  HBASE-22382 Refactor tests in TestFromClientSide (#385)
884843d is described below

commit 884843d0854196122300f7a24a8f4f24614bde8e
Author: Andor Molnár <an...@cloudera.com>
AuthorDate: Wed Jul 24 08:08:45 2019 +0200

    HBASE-22382 Refactor tests in TestFromClientSide (#385)
    
    Signed-off-by: Duo Zhang <zh...@apache.org>
---
 .../hadoop/hbase/client/TestFromClientSide.java    | 47 +++++++++++++++-------
 1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
index 59cfcae..fd60da4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
@@ -1162,21 +1162,25 @@ public class TestFromClientSide {
     }
   }
 
-  @Test
-  public void testNull() throws Exception {
-    final TableName tableName = TableName.valueOf(name.getMethodName());
-
+  @Test(expected = IOException.class)
+  public void testNullTableName() throws IOException {
     // Null table name (should NOT work)
-    try {
-      TEST_UTIL.createTable((TableName)null, FAMILY);
-      fail("Creating a table with null name passed, should have failed");
-    } catch(Exception e) {}
+    TEST_UTIL.createTable((TableName)null, FAMILY);
+    fail("Creating a table with null name passed, should have failed");
+  }
+
+  @Test(expected = IOException.class)
+  public void testNullFamilyName() throws IOException {
+    final TableName tableName = TableName.valueOf(name.getMethodName());
 
     // Null family (should NOT work)
-    try {
-      TEST_UTIL.createTable(tableName, new byte[][]{null});
-      fail("Creating a table with a null family passed, should fail");
-    } catch(Exception e) {}
+    TEST_UTIL.createTable(tableName, new byte[][]{null});
+    fail("Creating a table with a null family passed, should fail");
+  }
+
+  @Test
+  public void testNullRowAndQualifier() throws Exception {
+    final TableName tableName = TableName.valueOf(name.getMethodName());
 
     try (Table ht = TEST_UTIL.createTable(tableName, FAMILY)) {
 
@@ -1208,9 +1212,13 @@ public class TestFromClientSide {
         assertEmptyResult(result);
       }
     }
+  }
 
-    // Use a new table
-    try (Table ht = TEST_UTIL.createTable(TableName.valueOf(name.getMethodName() + "2"), FAMILY)) {
+  @Test
+  public void testNullEmptyQualifier() throws Exception {
+    final TableName tableName = TableName.valueOf(name.getMethodName());
+
+    try (Table ht = TEST_UTIL.createTable(tableName, FAMILY)) {
 
       // Empty qualifier, byte[0] instead of null (should work)
       try {
@@ -1239,9 +1247,16 @@ public class TestFromClientSide {
         assertEmptyResult(result);
 
       } catch (Exception e) {
-        throw new IOException("Using a row with null qualifier threw exception, should ");
+        throw new IOException("Using a row with null qualifier should not throw exception");
       }
+    }
+  }
+
+  @Test
+  public void testNullValue() throws IOException {
+    final TableName tableName = TableName.valueOf(name.getMethodName());
 
+    try (Table ht = TEST_UTIL.createTable(tableName, FAMILY)) {
       // Null value
       try {
         Put put = new Put(ROW);
@@ -1557,6 +1572,7 @@ public class TestFromClientSide {
   }
 
   @Test
+  @SuppressWarnings("checkstyle:MethodLength")
   public void testVersionLimits() throws Exception {
     final TableName tableName = TableName.valueOf(name.getMethodName());
     byte [][] FAMILIES = makeNAscii(FAMILY, 3);
@@ -6033,6 +6049,7 @@ public class TestFromClientSide {
   }
 
   @Test
+  @SuppressWarnings("checkstyle:MethodLength")
   public void testDeletesWithReverseScan() throws Exception {
     final TableName tableName = TableName.valueOf(name.getMethodName());
     byte[][] ROWS = makeNAscii(ROW, 6);