Search in sources :

Example 36 with ByteString

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);
}
Also used : ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) Connection(org.apache.hadoop.hbase.client.Connection) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) IOException(java.io.IOException) ListLabelsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.VisibilityLabelsProtos.ListLabelsResponse) Test(org.junit.Test)

Aggregations

ByteString (org.apache.hbase.thirdparty.com.google.protobuf.ByteString)36 IOException (java.io.IOException)22 ArrayList (java.util.ArrayList)18 Test (org.junit.Test)11 AggregateResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.AggregateProtos.AggregateResponse)9 Connection (org.apache.hadoop.hbase.client.Connection)8 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)7 List (java.util.List)7 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)7 Scan (org.apache.hadoop.hbase.client.Scan)7 Cell (org.apache.hadoop.hbase.Cell)6 CoprocessorRpcUtils (org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils)6 AggregateRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.AggregateProtos.AggregateRequest)6 AggregateService (org.apache.hadoop.hbase.shaded.protobuf.generated.AggregateProtos.AggregateService)6 GetAuthsResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.VisibilityLabelsProtos.GetAuthsResponse)6 VisibilityLabelsResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsResponse)6 RpcCallback (org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback)6 RpcController (org.apache.hbase.thirdparty.com.google.protobuf.RpcController)6 ByteBuffer (java.nio.ByteBuffer)4 CellScanner (org.apache.hadoop.hbase.CellScanner)4