HBASE-22382 Refactor tests in TestFromClientSide (#385)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Andor Molnár 2019-07-24 08:08:45 +02:00 committed by Duo Zhang
parent 7ebf80fe1d
commit 542ae47797
1 changed files with 32 additions and 15 deletions

View File

@ -1155,21 +1155,25 @@ public class TestFromClientSide {
} }
} }
@Test @Test(expected = IOException.class)
public void testNull() throws Exception { public void testNullTableName() throws IOException {
final TableName tableName = TableName.valueOf(name.getMethodName());
// Null table name (should NOT work) // Null table name (should NOT work)
try {
TEST_UTIL.createTable((TableName)null, FAMILY); TEST_UTIL.createTable((TableName)null, FAMILY);
fail("Creating a table with null name passed, should have failed"); fail("Creating a table with null name passed, should have failed");
} catch(Exception e) {} }
@Test(expected = IOException.class)
public void testNullFamilyName() throws IOException {
final TableName tableName = TableName.valueOf(name.getMethodName());
// Null family (should NOT work) // Null family (should NOT work)
try {
TEST_UTIL.createTable(tableName, new byte[][]{null}); TEST_UTIL.createTable(tableName, new byte[][]{null});
fail("Creating a table with a null family passed, should fail"); fail("Creating a table with a null family passed, should fail");
} catch(Exception e) {} }
@Test
public void testNullRowAndQualifier() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
try (Table ht = TEST_UTIL.createTable(tableName, FAMILY)) { try (Table ht = TEST_UTIL.createTable(tableName, FAMILY)) {
@ -1201,9 +1205,13 @@ public class TestFromClientSide {
assertEmptyResult(result); assertEmptyResult(result);
} }
} }
}
// Use a new table @Test
try (Table ht = TEST_UTIL.createTable(TableName.valueOf(name.getMethodName() + "2"), FAMILY)) { 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) // Empty qualifier, byte[0] instead of null (should work)
try { try {
@ -1232,9 +1240,16 @@ public class TestFromClientSide {
assertEmptyResult(result); assertEmptyResult(result);
} catch (Exception e) { } 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 // Null value
try { try {
Put put = new Put(ROW); Put put = new Put(ROW);
@ -1550,6 +1565,7 @@ public class TestFromClientSide {
} }
@Test @Test
@SuppressWarnings("checkstyle:MethodLength")
public void testVersionLimits() throws Exception { public void testVersionLimits() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName());
byte [][] FAMILIES = makeNAscii(FAMILY, 3); byte [][] FAMILIES = makeNAscii(FAMILY, 3);
@ -5965,6 +5981,7 @@ public class TestFromClientSide {
} }
@Test @Test
@SuppressWarnings("checkstyle:MethodLength")
public void testDeletesWithReverseScan() throws Exception { public void testDeletesWithReverseScan() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName());
byte[][] ROWS = makeNAscii(ROW, 6); byte[][] ROWS = makeNAscii(ROW, 6);