Skip to content

Commit dcc2c4d

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

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
@@ -1163,21 +1163,25 @@ public void testSingleRowMultipleFamily() throws Exception {
11631163
}
11641164
}
11651165

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

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

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

@@ -1209,9 +1213,13 @@ public void testNull() throws Exception {
12091213
assertEmptyResult(result);
12101214
}
12111215
}
1216+
}
12121217

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

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

12421250
} catch (Exception e) {
1243-
throw new IOException("Using a row with null qualifier threw exception, should ");
1251+
throw new IOException("Using a row with null qualifier should not throw exception");
12441252
}
1253+
}
1254+
}
1255+
1256+
@Test
1257+
public void testNullValue() throws IOException {
1258+
final TableName tableName = TableName.valueOf(name.getMethodName());
12451259

1260+
try (Table ht = TEST_UTIL.createTable(tableName, FAMILY)) {
12461261
// Null value
12471262
try {
12481263
Put put = new Put(ROW);
@@ -1558,6 +1573,7 @@ public void testVersions() throws Exception {
15581573
}
15591574

15601575
@Test
1576+
@SuppressWarnings("checkstyle:MethodLength")
15611577
public void testVersionLimits() throws Exception {
15621578
final TableName tableName = TableName.valueOf(name.getMethodName());
15631579
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)