Skip to content

Commit 884843d

Browse files
anmolnarApache9
authored andcommitted
HBASE-22382 Refactor tests in TestFromClientSide (#385)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent 5641728 commit 884843d

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,21 +1162,25 @@ public void testSingleRowMultipleFamily() throws Exception {
11621162
}
11631163
}
11641164

1165-
@Test
1166-
public void testNull() throws Exception {
1167-
final TableName tableName = TableName.valueOf(name.getMethodName());
1168-
1165+
@Test(expected = IOException.class)
1166+
public void testNullTableName() throws IOException {
11691167
// Null table name (should NOT work)
1170-
try {
1171-
TEST_UTIL.createTable((TableName)null, FAMILY);
1172-
fail("Creating a table with null name passed, should have failed");
1173-
} catch(Exception e) {}
1168+
TEST_UTIL.createTable((TableName)null, FAMILY);
1169+
fail("Creating a table with null name passed, should have failed");
1170+
}
1171+
1172+
@Test(expected = IOException.class)
1173+
public void testNullFamilyName() throws IOException {
1174+
final TableName tableName = TableName.valueOf(name.getMethodName());
11741175

11751176
// Null family (should NOT work)
1176-
try {
1177-
TEST_UTIL.createTable(tableName, new byte[][]{null});
1178-
fail("Creating a table with a null family passed, should fail");
1179-
} catch(Exception e) {}
1177+
TEST_UTIL.createTable(tableName, new byte[][]{null});
1178+
fail("Creating a table with a null family passed, should fail");
1179+
}
1180+
1181+
@Test
1182+
public void testNullRowAndQualifier() throws Exception {
1183+
final TableName tableName = TableName.valueOf(name.getMethodName());
11801184

11811185
try (Table ht = TEST_UTIL.createTable(tableName, FAMILY)) {
11821186

@@ -1208,9 +1212,13 @@ public void testNull() throws Exception {
12081212
assertEmptyResult(result);
12091213
}
12101214
}
1215+
}
12111216

1212-
// Use a new table
1213-
try (Table ht = TEST_UTIL.createTable(TableName.valueOf(name.getMethodName() + "2"), FAMILY)) {
1217+
@Test
1218+
public void testNullEmptyQualifier() throws Exception {
1219+
final TableName tableName = TableName.valueOf(name.getMethodName());
1220+
1221+
try (Table ht = TEST_UTIL.createTable(tableName, FAMILY)) {
12141222

12151223
// Empty qualifier, byte[0] instead of null (should work)
12161224
try {
@@ -1239,9 +1247,16 @@ public void testNull() throws Exception {
12391247
assertEmptyResult(result);
12401248

12411249
} catch (Exception e) {
1242-
throw new IOException("Using a row with null qualifier threw exception, should ");
1250+
throw new IOException("Using a row with null qualifier should not throw exception");
12431251
}
1252+
}
1253+
}
1254+
1255+
@Test
1256+
public void testNullValue() throws IOException {
1257+
final TableName tableName = TableName.valueOf(name.getMethodName());
12441258

1259+
try (Table ht = TEST_UTIL.createTable(tableName, FAMILY)) {
12451260
// Null value
12461261
try {
12471262
Put put = new Put(ROW);
@@ -1557,6 +1572,7 @@ public void testVersions() throws Exception {
15571572
}
15581573

15591574
@Test
1575+
@SuppressWarnings("checkstyle:MethodLength")
15601576
public void testVersionLimits() throws Exception {
15611577
final TableName tableName = TableName.valueOf(name.getMethodName());
15621578
byte [][] FAMILIES = makeNAscii(FAMILY, 3);
@@ -6033,6 +6049,7 @@ public void testNullWithReverseScan() throws Exception {
60336049
}
60346050

60356051
@Test
6052+
@SuppressWarnings("checkstyle:MethodLength")
60366053
public void testDeletesWithReverseScan() throws Exception {
60376054
final TableName tableName = TableName.valueOf(name.getMethodName());
60386055
byte[][] ROWS = makeNAscii(ROW, 6);

0 commit comments

Comments
 (0)