use of org.apache.hbase.thirdparty.com.google.protobuf.ByteString in project hbase by apache.
the class TestVisibilityLabelsWithDefaultVisLabelService method testListLabels.
@Test
public void testListLabels() throws Throwable {
PrivilegedExceptionAction<ListLabelsResponse> action = new PrivilegedExceptionAction<ListLabelsResponse>() {
@Override
public ListLabelsResponse run() throws Exception {
ListLabelsResponse response = null;
try (Connection conn = ConnectionFactory.createConnection(conf)) {
response = VisibilityClient.listLabels(conn, null);
} catch (Throwable e) {
throw new IOException(e);
}
// The addLabels() in setup added:
// { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE, COPYRIGHT, ACCENT,
// UNICODE_VIS_TAG, UC1, UC2 };
// The previous tests added 2 more labels: ABC, XYZ
// The 'system' label is excluded.
List<ByteString> labels = response.getLabelList();
assertEquals(12, labels.size());
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;
}
};
SUPERUSER.runAs(action);
}
Aggregations