diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java index 0d7ff68314..54b5b33673 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java @@ -94,7 +94,7 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili try (Connection conn = ConnectionFactory.createConnection(conf)) { response = VisibilityClient.addLabels(conn, labels); } catch (Throwable e) { - fail("Should not have thrown exception"); + throw new IOException(e); } List resultList = response.getResultList(); assertEquals(5, resultList.size()); @@ -183,7 +183,7 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili try (Connection conn = ConnectionFactory.createConnection(conf)) { response = VisibilityClient.listLabels(conn, null); } catch (Throwable e) { - fail("Should not have thrown exception"); + throw new IOException(e); } // The addLabels() in setup added: // { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE, COPYRIGHT, ACCENT, @@ -192,12 +192,12 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili // The 'system' label is excluded. List labels = response.getLabelList(); assertEquals(12, labels.size()); - assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom(CONFIDENTIAL.getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom("ABC".getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom("XYZ".getBytes()))); - assertFalse(labels.contains(ByteString.copyFrom(SYSTEM_LABEL.getBytes()))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(SECRET)))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(TOPSECRET)))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(CONFIDENTIAL)))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes("ABC")))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes("XYZ")))); + assertFalse(labels.contains(ByteString.copyFrom(Bytes.toBytes(SYSTEM_LABEL)))); return null; } }; @@ -214,13 +214,13 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili try (Connection conn = ConnectionFactory.createConnection(conf)) { response = VisibilityClient.listLabels(conn, ".*secret"); } catch (Throwable e) { - fail("Should not have thrown exception"); + throw new IOException(e); } // Only return the labels that end with 'secret' List labels = response.getLabelList(); assertEquals(2, labels.size()); - assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes()))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(SECRET)))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(TOPSECRET)))); return null; } }; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java index b0cabed46d..405a7fa5ec 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java @@ -313,8 +313,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(1, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -334,8 +332,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -366,8 +362,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -386,8 +380,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -417,8 +409,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(1, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -438,8 +428,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -470,8 +458,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -490,8 +476,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -522,8 +506,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes // The delete would not be able to apply it because of visibility mismatch Result[] next = scanner.next(3); assertEquals(1, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -544,8 +526,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes Result[] next = scanner.next(3); // this will alone match assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; }