hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject [2/3] hbase git commit: HBASE-19914 Refactor TestVisibilityLabelsOnNewVersionBehaviorTable
Date Sun, 04 Feb 2018 05:42:18 GMT
http://git-wip-us.apache.org/repos/asf/hbase/blob/2e1ec3d3/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java
----------------------------------------------------------------------
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 2e3d625..7a5232a 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
@@ -17,7 +17,6 @@
  */
 package org.apache.hadoop.hbase.security.visibility;
 
-import static org.apache.hadoop.hbase.security.visibility.VisibilityConstants.LABELS_TABLE_NAME;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -27,17 +26,13 @@ import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellScanner;
 import org.apache.hadoop.hbase.CellUtil;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
 import org.apache.hadoop.hbase.client.Delete;
@@ -48,251 +43,64 @@ import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
 import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsResponse;
-import org.apache.hadoop.hbase.security.User;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.testclassification.SecurityTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.ClassRule;
-import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-/**
- * Tests visibility labels with deletes
- */
-@Category({SecurityTests.class, MediumTests.class})
-public class TestVisibilityLabelsWithDeletes {
+@Category({ SecurityTests.class, LargeTests.class })
+public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletesTestBase {
 
   @ClassRule
   public static final HBaseClassTestRule CLASS_RULE =
-      HBaseClassTestRule.forClass(TestVisibilityLabelsWithDeletes.class);
-
-  private static final Logger LOG = LoggerFactory.getLogger(TestVisibilityLabelsWithDeletes.class);
-  private static final String TOPSECRET = "TOPSECRET";
-  private static final String PUBLIC = "PUBLIC";
-  private static final String PRIVATE = "PRIVATE";
-  private static final String CONFIDENTIAL = "CONFIDENTIAL";
-  private static final String SECRET = "SECRET";
-  public static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
-  private static final byte[] row1 = Bytes.toBytes("row1");
-  private static final byte[] row2 = Bytes.toBytes("row2");
-  protected final static byte[] fam = Bytes.toBytes("info");
-  protected final static byte[] qual = Bytes.toBytes("qual");
-  private final static byte[] qual1 = Bytes.toBytes("qual1");
-  private final static byte[] qual2 = Bytes.toBytes("qual2");
-  protected final static byte[] value = Bytes.toBytes("value");
-  private final static byte[] value1 = Bytes.toBytes("value1");
-  public static Configuration conf;
-
-  @Rule
-  public final TestName TEST_NAME = new TestName();
-  public static User SUPERUSER;
-
-  @BeforeClass
-  public static void setupBeforeClass() throws Exception {
-    // setup configuration
-    conf = TEST_UTIL.getConfiguration();
-    VisibilityTestUtil.enableVisiblityLabels(conf);
-    conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
-        ScanLabelGenerator.class);
-    conf.set("hbase.superuser", "admin");
-    TEST_UTIL.startMiniCluster(2);
-    SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
-
-    // Wait for the labels table to become available
-    TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
-    addLabels();
-  }
-
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
-    TEST_UTIL.shutdownMiniCluster();
-  }
+    HBaseClassTestRule.forClass(TestVisibilityLabelsWithDeletes.class);
 
-  @After
-  public void tearDown() throws Exception {
-  }
-
-  protected Table createTable(HColumnDescriptor fam) throws IOException {
-    TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    HTableDescriptor table = new HTableDescriptor(tableName);
-    table.addFamily(fam);
-    TEST_UTIL.getHBaseAdmin().createTable(table);
+  @Override
+  protected Table createTable(byte[] fam) throws IOException {
+    TableName tableName = TableName.valueOf(testName.getMethodName());
+    TEST_UTIL.getAdmin().createTable(TableDescriptorBuilder.newBuilder(tableName)
+        .addColumnFamily(ColumnFamilyDescriptorBuilder.of(fam)).build());
     return TEST_UTIL.getConnection().getTable(tableName);
   }
 
-  @Test
-  public void testVisibilityLabelsWithDeleteColumns() throws Throwable {
-    setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-
-    try (Table table = createTableAndWriteDataWithLabels(SECRET + "&" + TOPSECRET, SECRET)) {
-      PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
-        @Override
-        public Void run() throws Exception {
-          try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
-            Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(TOPSECRET + "&" + SECRET));
-            d.addColumns(fam, qual);
-            table.delete(d);
-          } catch (Throwable t) {
-            throw new IOException(t);
-          }
-          return null;
-        }
-      };
-      SUPERUSER.runAs(actiona);
-
-      TEST_UTIL.getAdmin().flush(tableName);
-      Scan s = new Scan();
-      s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL));
-      ResultScanner scanner = table.getScanner(s);
-      Result[] next = scanner.next(3);
-      assertTrue(next.length == 1);
-      CellScanner cellScanner = next[0].cellScanner();
-      cellScanner.advance();
-      Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
-
-    }
+  private TableName createTable() throws IOException {
+    return createTable(-1);
   }
 
-  @Test
-  public void testVisibilityLabelsWithDeleteFamily() throws Exception {
-    setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    try (Table table = createTableAndWriteDataWithLabels(SECRET, CONFIDENTIAL + "|" + TOPSECRET)) {
-      PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
-        @Override
-        public Void run() throws Exception {
-          try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
-            Delete d = new Delete(row2);
-            d.setCellVisibility(new CellVisibility(TOPSECRET + "|" + CONFIDENTIAL));
-            d.addFamily(fam);
-            table.delete(d);
-          } catch (Throwable t) {
-            throw new IOException(t);
-          }
-          return null;
-        }
-      };
-      SUPERUSER.runAs(actiona);
-
-      TEST_UTIL.getAdmin().flush(tableName);
-      Scan s = new Scan();
-      s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL));
-      ResultScanner scanner = table.getScanner(s);
-      Result[] next = scanner.next(3);
-      assertTrue(next.length == 1);
-      CellScanner cellScanner = next[0].cellScanner();
-      cellScanner.advance();
-      Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
-    }
+  private TableName createTable(int maxVersions) throws IOException {
+    TableName tableName = TableName.valueOf(testName.getMethodName());
+    createTable(tableName, maxVersions);
+    return tableName;
   }
 
-  @Test
-  public void testVisibilityLabelsWithDeleteFamilyVersion() throws Exception {
-    setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    long[] ts = new long[] { 123L, 125L };
-    try (Table table = createTableAndWriteDataWithLabels(ts,
-        CONFIDENTIAL + "|" + TOPSECRET, SECRET)) {
-      PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
-        @Override
-        public Void run() throws Exception {
-          try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
-            Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(TOPSECRET + "|" + CONFIDENTIAL));
-            d.addFamilyVersion(fam, 123L);
-            table.delete(d);
-          } catch (Throwable t) {
-            throw new IOException(t);
-          }
-          return null;
-        }
-      };
-      SUPERUSER.runAs(actiona);
-
-      TEST_UTIL.getAdmin().flush(tableName);
-      Scan s = new Scan();
-      s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL));
-      ResultScanner scanner = table.getScanner(s);
-      Result[] next = scanner.next(3);
-      assertTrue(next.length == 1);
-      CellScanner cellScanner = next[0].cellScanner();
-      cellScanner.advance();
-      Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
-    }
-  }
-
-  @Test
-  public void testVisibilityLabelsWithDeleteColumnExactVersion() throws Exception {
-    setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    long[] ts = new long[] { 123L, 125L };
-    try (Table table = createTableAndWriteDataWithLabels(ts,
-        CONFIDENTIAL + "|" + TOPSECRET, SECRET)) {
-      PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
-        @Override
-        public Void run() throws Exception {
-          try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
-            Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(TOPSECRET + "|" + CONFIDENTIAL));
-            d.addColumn(fam, qual, 123L);
-            table.delete(d);
-          } catch (Throwable t) {
-            throw new IOException(t);
-          }
-          return null;
-        }
-      };
-      SUPERUSER.runAs(actiona);
-
-      TEST_UTIL.getAdmin().flush(tableName);
-      Scan s = new Scan();
-      s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL));
-      ResultScanner scanner = table.getScanner(s);
-      Result[] next = scanner.next(3);
-      assertTrue(next.length == 1);
-      CellScanner cellScanner = next[0].cellScanner();
-      cellScanner.advance();
-      Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+  private void createTable(TableName tableName, int maxVersions) throws IOException {
+    ColumnFamilyDescriptorBuilder builder = ColumnFamilyDescriptorBuilder.newBuilder(fam);
+    if (maxVersions > 0) {
+      builder.setMaxVersions(maxVersions);
     }
+    TEST_UTIL.getAdmin().createTable(
+      TableDescriptorBuilder.newBuilder(tableName).addColumnFamily(builder.build()).build());
   }
 
   @Test
   public void testVisibilityLabelsWithDeleteColumnsWithMultipleVersions() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" +
-                SECRET + "&" + TOPSECRET+")"));
+            d.setCellVisibility(new CellVisibility(
+                "(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" + SECRET + "&" + TOPSECRET + ")"));
             d.addColumns(fam, qual, 125L);
             table.delete(d);
           } catch (Throwable t) {
@@ -305,7 +113,7 @@ public class TestVisibilityLabelsWithDeletes {
 
       TEST_UTIL.getAdmin().flush(tableName);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -313,24 +121,24 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(126L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(125L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
@@ -338,14 +146,14 @@ public class TestVisibilityLabelsWithDeletes {
   public void testVisibilityLabelsWithDeleteColumnsWithMultipleVersionsNoTimestamp()
       throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d1 = new Delete(row1);
             d1.setCellVisibility(new CellVisibility(CONFIDENTIAL));
             d1.addColumns(fam, qual);
@@ -358,8 +166,8 @@ public class TestVisibilityLabelsWithDeletes {
             table.delete(d2);
 
             Delete d3 = new Delete(row1);
-            d3.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
-                + SECRET + "&" + TOPSECRET + ")"));
+            d3.setCellVisibility(new CellVisibility(
+                "(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" + SECRET + "&" + TOPSECRET + ")"));
             d3.addColumns(fam, qual);
             table.delete(d3);
           } catch (Throwable t) {
@@ -370,7 +178,7 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -378,24 +186,23 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
   @Test
-  public void
-    testVisibilityLabelsWithDeleteColumnsWithNoMatchVisExpWithMultipleVersionsNoTimestamp()
+  public void testVisibilityLabelsWithDeleteColumnsNoMatchVisExpWithMultipleVersionsNoTimestamp()
       throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
             d.addColumns(fam, qual);
@@ -407,8 +214,8 @@ public class TestVisibilityLabelsWithDeletes {
             table.delete(d);
 
             d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
-                + SECRET + "&" + TOPSECRET + ")"));
+            d.setCellVisibility(new CellVisibility(
+                "(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" + SECRET + "&" + TOPSECRET + ")"));
             d.addColumns(fam, qual);
             table.delete(d);
           } catch (Throwable t) {
@@ -419,7 +226,7 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -427,13 +234,13 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
@@ -441,14 +248,14 @@ public class TestVisibilityLabelsWithDeletes {
   public void testVisibilityLabelsWithDeleteFamilyWithMultipleVersionsNoTimestamp()
       throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d1 = new Delete(row1);
             d1.setCellVisibility(new CellVisibility(CONFIDENTIAL));
             d1.addFamily(fam);
@@ -460,8 +267,8 @@ public class TestVisibilityLabelsWithDeletes {
             table.delete(d2);
 
             Delete d3 = new Delete(row1);
-            d3.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
-                + SECRET + "&" + TOPSECRET + ")"));
+            d3.setCellVisibility(new CellVisibility(
+                "(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" + SECRET + "&" + TOPSECRET + ")"));
             d3.addFamily(fam);
             table.delete(d3);
           } catch (Throwable t) {
@@ -472,7 +279,7 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -480,19 +287,14 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
   @Test
   public void testDeleteColumnsWithoutAndWithVisibilityLabels() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable();
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(row1);
       put.addColumn(fam, qual, value);
@@ -506,7 +308,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             Result[] next = scanner.next(3);
@@ -527,7 +329,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             Result[] next = scanner.next(3);
@@ -544,12 +346,7 @@ public class TestVisibilityLabelsWithDeletes {
 
   @Test
   public void testDeleteColumnsWithAndWithoutVisibilityLabels() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable();
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(row1);
       put.addColumn(fam, qual, value);
@@ -564,7 +361,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             Result[] next = scanner.next(3);
@@ -584,7 +381,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             Result[] next = scanner.next(3);
@@ -601,12 +398,7 @@ public class TestVisibilityLabelsWithDeletes {
 
   @Test
   public void testDeleteFamiliesWithoutAndWithVisibilityLabels() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable();
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(row1);
       put.addColumn(fam, qual, value);
@@ -620,7 +412,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             Result[] next = scanner.next(3);
@@ -641,7 +433,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             Result[] next = scanner.next(3);
@@ -658,12 +450,7 @@ public class TestVisibilityLabelsWithDeletes {
 
   @Test
   public void testDeleteFamiliesWithAndWithoutVisibilityLabels() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable();
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(row1);
       put.addColumn(fam, qual, value);
@@ -678,7 +465,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             Result[] next = scanner.next(3);
@@ -698,7 +485,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             Result[] next = scanner.next(3);
@@ -715,12 +502,7 @@ public class TestVisibilityLabelsWithDeletes {
 
   @Test
   public void testDeletesWithoutAndWithVisibilityLabels() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable();
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(row1);
       put.addColumn(fam, qual, value);
@@ -734,7 +516,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             // The delete would not be able to apply it because of visibility mismatch
@@ -756,7 +538,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-              Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Scan s = new Scan();
             ResultScanner scanner = table.getScanner(s);
             Result[] next = scanner.next(3);
@@ -774,13 +556,7 @@ public class TestVisibilityLabelsWithDeletes {
 
   @Test
   public void testVisibilityLabelsWithDeleteFamilyWithPutsReAppearing() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    colDesc.setMaxVersions(5);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable(5);
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.addColumn(fam, qual, value);
@@ -795,7 +571,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
             d.addFamily(fam);
@@ -808,7 +584,7 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -821,7 +597,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET));
             d.addFamily(fam);
@@ -834,13 +610,13 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(CONFIDENTIAL));
       scanner = table.getScanner(s);
       next = scanner.next(3);
       assertEquals(1, next.length);
       s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET));
       scanner = table.getScanner(s);
       Result[] next1 = scanner.next(3);
@@ -850,13 +626,7 @@ public class TestVisibilityLabelsWithDeletes {
 
   @Test
   public void testVisibilityLabelsWithDeleteColumnsWithPutsReAppearing() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    colDesc.setMaxVersions(5);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable(5);
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.addColumn(fam, qual, value);
@@ -871,7 +641,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
             d.addColumns(fam, qual);
@@ -884,7 +654,7 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -897,7 +667,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET));
             d.addColumns(fam, qual);
@@ -910,13 +680,13 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(CONFIDENTIAL));
       scanner = table.getScanner(s);
       next = scanner.next(3);
       assertEquals(1, next.length);
       s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET));
       scanner = table.getScanner(s);
       Result[] next1 = scanner.next(3);
@@ -926,13 +696,7 @@ public class TestVisibilityLabelsWithDeletes {
 
   @Test
   public void testVisibilityCombinations() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    colDesc.setMaxVersions(5);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable(5);
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.addColumn(fam, qual, 123L, value);
@@ -946,7 +710,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET));
             d.addColumns(fam, qual, 126L);
@@ -956,7 +720,7 @@ public class TestVisibilityLabelsWithDeletes {
           }
 
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
             d.addColumn(fam, qual, 123L);
@@ -969,24 +733,18 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(CONFIDENTIAL, SECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
       assertEquals(0, next.length);
     }
   }
+
   @Test
   public void testVisibilityLabelsWithDeleteColumnWithSpecificVersionWithPutsReAppearing()
       throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    colDesc.setMaxVersions(5);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
-
+    TableName tableName = createTable(5);
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put1 = new Put(Bytes.toBytes("row1"));
       put1.addColumn(fam, qual, 123L, value);
@@ -998,7 +756,7 @@ public class TestVisibilityLabelsWithDeletes {
       table.put(createList(put1, put2));
 
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(CONFIDENTIAL, SECRET));
 
       ResultScanner scanner = table.getScanner(s);
@@ -1009,7 +767,7 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
             d.addColumn(fam, qual, 123L);
@@ -1017,7 +775,7 @@ public class TestVisibilityLabelsWithDeletes {
           }
 
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET));
             d.addColumn(fam, qual, 123L);
@@ -1030,7 +788,7 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(CONFIDENTIAL));
       scanner = table.getScanner(s);
       assertEquals(0, scanner.next(3).length);
@@ -1039,11 +797,10 @@ public class TestVisibilityLabelsWithDeletes {
   }
 
   @Test
-  public void
-    testVisibilityLabelsWithDeleteFamilyWithNoMatchingVisExpWithMultipleVersionsNoTimestamp()
+  public void testVisibilityLabelsWithDeleteFamilyNoMatchingVisExpWithMultipleVersionsNoTimestamp()
       throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
@@ -1058,12 +815,12 @@ public class TestVisibilityLabelsWithDeletes {
           d2.addFamily(fam);
 
           Delete d3 = new Delete(row1);
-          d3.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
-              + SECRET + "&" + TOPSECRET + ")"));
+          d3.setCellVisibility(new CellVisibility(
+              "(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" + SECRET + "&" + TOPSECRET + ")"));
           d3.addFamily(fam);
 
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             table.delete(createList(d1, d2, d3));
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1073,7 +830,7 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1081,13 +838,13 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
       scanner.close();
     }
   }
@@ -1095,7 +852,7 @@ public class TestVisibilityLabelsWithDeletes {
   @Test
   public void testDeleteFamilyAndDeleteColumnsWithAndWithoutVisibilityExp() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
@@ -1108,7 +865,7 @@ public class TestVisibilityLabelsWithDeletes {
           d2.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
           d2.addColumns(fam, qual);
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             table.delete(createList(d1, d2));
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1118,7 +875,7 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1126,41 +883,36 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(126L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(124L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(123L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
       scanner.close();
     }
   }
 
   private Table doPuts(TableName tableName) throws IOException, InterruptedIOException,
       RetriesExhaustedWithDetailsException, InterruptedException {
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    colDesc.setMaxVersions(5);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    createTable(tableName, 5);
 
     List<Put> puts = new ArrayList<>(5);
     Put put = new Put(Bytes.toBytes("row1"));
@@ -1170,8 +922,8 @@ public class TestVisibilityLabelsWithDeletes {
 
     put = new Put(Bytes.toBytes("row1"));
     put.addColumn(fam, qual, 124L, value);
-    put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
-    + TOPSECRET + "&" + SECRET+")"));
+    put.setCellVisibility(new CellVisibility(
+        "(" + CONFIDENTIAL + "&" + PRIVATE + ")|(" + TOPSECRET + "&" + SECRET + ")"));
     puts.add(put);
 
     put = new Put(Bytes.toBytes("row1"));
@@ -1181,21 +933,21 @@ public class TestVisibilityLabelsWithDeletes {
 
     put = new Put(Bytes.toBytes("row1"));
     put.addColumn(fam, qual, 126L, value);
-    put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
-        + TOPSECRET + "&" + SECRET+")"));
+    put.setCellVisibility(new CellVisibility(
+        "(" + CONFIDENTIAL + "&" + PRIVATE + ")|(" + TOPSECRET + "&" + SECRET + ")"));
     puts.add(put);
 
     put = new Put(Bytes.toBytes("row1"));
     put.addColumn(fam, qual, 127L, value);
-    put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
-        + TOPSECRET + "&" + SECRET+")"));
+    put.setCellVisibility(new CellVisibility(
+        "(" + CONFIDENTIAL + "&" + PRIVATE + ")|(" + TOPSECRET + "&" + SECRET + ")"));
     puts.add(put);
 
     TEST_UTIL.getAdmin().flush(tableName);
     put = new Put(Bytes.toBytes("row2"));
     put.addColumn(fam, qual, 127L, value);
-    put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|(" + TOPSECRET
-        + "&" + SECRET + ")"));
+    put.setCellVisibility(new CellVisibility(
+        "(" + CONFIDENTIAL + "&" + PRIVATE + ")|(" + TOPSECRET + "&" + SECRET + ")"));
     puts.add(put);
 
     Table table = TEST_UTIL.getConnection().getTable(tableName);
@@ -1203,14 +955,9 @@ public class TestVisibilityLabelsWithDeletes {
     return table;
   }
 
-  private Table doPutsWithDiffCols(TableName tableName) throws IOException,
-      InterruptedIOException, RetriesExhaustedWithDetailsException, InterruptedException {
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    colDesc.setMaxVersions(5);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+  private Table doPutsWithDiffCols(TableName tableName) throws IOException, InterruptedIOException,
+      RetriesExhaustedWithDetailsException, InterruptedException {
+    createTable(tableName, 5);
 
     List<Put> puts = new ArrayList<>(5);
     Put put = new Put(Bytes.toBytes("row1"));
@@ -1220,8 +967,8 @@ public class TestVisibilityLabelsWithDeletes {
 
     put = new Put(Bytes.toBytes("row1"));
     put.addColumn(fam, qual, 124L, value);
-    put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
-    + TOPSECRET + "&" + SECRET+")"));
+    put.setCellVisibility(new CellVisibility(
+        "(" + CONFIDENTIAL + "&" + PRIVATE + ")|(" + TOPSECRET + "&" + SECRET + ")"));
     puts.add(put);
 
     put = new Put(Bytes.toBytes("row1"));
@@ -1236,8 +983,8 @@ public class TestVisibilityLabelsWithDeletes {
 
     put = new Put(Bytes.toBytes("row1"));
     put.addColumn(fam, qual2, 127L, value);
-    put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
-        + TOPSECRET + "&" + SECRET+")"));
+    put.setCellVisibility(new CellVisibility(
+        "(" + CONFIDENTIAL + "&" + PRIVATE + ")|(" + TOPSECRET + "&" + SECRET + ")"));
     puts.add(put);
 
     Table table = TEST_UTIL.getConnection().getTable(tableName);
@@ -1247,12 +994,7 @@ public class TestVisibilityLabelsWithDeletes {
 
   private Table doPutsWithoutVisibility(TableName tableName) throws IOException,
       InterruptedIOException, RetriesExhaustedWithDetailsException, InterruptedException {
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    colDesc.setMaxVersions(5);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    createTable(tableName, 5);
     List<Put> puts = new ArrayList<>(5);
     Put put = new Put(Bytes.toBytes("row1"));
     put.addColumn(fam, qual, 123L, value);
@@ -1286,22 +1028,21 @@ public class TestVisibilityLabelsWithDeletes {
     return table;
   }
 
-
   @Test
   public void testDeleteColumnWithSpecificTimeStampUsingMultipleVersionsUnMatchingVisExpression()
       throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" +
-                SECRET + "&" + TOPSECRET+")"));
+            d.setCellVisibility(new CellVisibility(
+                "(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" + SECRET + "&" + TOPSECRET + ")"));
             d.addColumn(fam, qual, 125L);
             table.delete(d);
           } catch (Throwable t) {
@@ -1314,7 +1055,7 @@ public class TestVisibilityLabelsWithDeletes {
 
       TEST_UTIL.getAdmin().flush(tableName);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1322,48 +1063,48 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(126L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(125L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(124L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(123L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
   @Test
   public void testDeleteColumnWithLatestTimeStampUsingMultipleVersions() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
             d.addColumn(fam, qual);
@@ -1378,7 +1119,7 @@ public class TestVisibilityLabelsWithDeletes {
 
       TEST_UTIL.getAdmin().flush(tableName);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1386,36 +1127,36 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(126L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(124L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(123L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
-  @Test (timeout=180000)
+  @Test(timeout = 180000)
   public void testDeleteColumnWithLatestTimeStampWhenNoVersionMatches() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       Put put = new Put(Bytes.toBytes("row1"));
@@ -1426,9 +1167,9 @@ public class TestVisibilityLabelsWithDeletes {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(SECRET ));
+            d.setCellVisibility(new CellVisibility(SECRET));
             d.addColumn(fam, qual);
             table.delete(d);
           } catch (Throwable t) {
@@ -1441,7 +1182,7 @@ public class TestVisibilityLabelsWithDeletes {
 
       TEST_UTIL.getAdmin().flush(tableName);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1449,34 +1190,34 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(128L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(126L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(125L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(124L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
 
       put = new Put(Bytes.toBytes("row1"));
       put.addColumn(fam, qual, 129L, value);
@@ -1485,7 +1226,7 @@ public class TestVisibilityLabelsWithDeletes {
 
       TEST_UTIL.getAdmin().flush(tableName);
       s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       scanner = table.getScanner(s);
       next = scanner.next(3);
@@ -1493,23 +1234,24 @@ public class TestVisibilityLabelsWithDeletes {
       cellScanner = next[0].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(129L, current.getTimestamp());
     }
   }
+
   @Test
   public void testDeleteColumnWithLatestTimeStampUsingMultipleVersionsAfterCompaction()
       throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
             d.addColumn(fam, qual);
@@ -1531,7 +1273,7 @@ public class TestVisibilityLabelsWithDeletes {
       // Sleep to ensure compaction happens. Need to do it in a better way
       Thread.sleep(5000);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1539,43 +1281,43 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(126L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(124L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(123L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
   @Test
   public void testDeleteFamilyLatestTimeStampWithMulipleVersions() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
             d.addFamily(fam);
@@ -1590,7 +1332,7 @@ public class TestVisibilityLabelsWithDeletes {
 
       TEST_UTIL.getAdmin().flush(tableName);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1598,26 +1340,26 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(126L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
   @Test
   public void testDeleteColumnswithMultipleColumnsWithMultipleVersions() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPutsWithDiffCols(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
@@ -1627,7 +1369,7 @@ public class TestVisibilityLabelsWithDeletes {
           d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
           d.addColumns(fam, qual, 125L);
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1639,7 +1381,7 @@ public class TestVisibilityLabelsWithDeletes {
 
       TEST_UTIL.getAdmin().flush(tableName);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1647,40 +1389,34 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(124L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(123L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertTrue(Bytes.equals(current.getQualifierArray(), current.getQualifierOffset(),
-          current.getQualifierLength(), qual1, 0, qual1.length));
+        current.getQualifierLength(), qual1, 0, qual1.length));
       assertEquals(126L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       assertTrue(Bytes.equals(current.getQualifierArray(), current.getQualifierOffset(),
-          current.getQualifierLength(), qual2, 0, qual2.length));
+        current.getQualifierLength(), qual2, 0, qual2.length));
     }
   }
 
   @Test
   public void testDeleteColumnsWithDiffColsAndTags() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    colDesc.setMaxVersions(5);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable(5);
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.addColumn(fam, qual1, 125L, value);
@@ -1703,7 +1439,7 @@ public class TestVisibilityLabelsWithDeletes {
           d2.addColumns(fam, qual1, 125L);
 
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             table.delete(createList(d1, d2));
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1713,22 +1449,17 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
       assertEquals(1, next.length);
     }
   }
+
   @Test
   public void testDeleteColumnsWithDiffColsAndTags1() throws Exception {
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Admin hBaseAdmin = TEST_UTIL.getAdmin();
-    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-    colDesc.setMaxVersions(5);
-    HTableDescriptor desc = new HTableDescriptor(tableName);
-    desc.addFamily(colDesc);
-    hBaseAdmin.createTable(desc);
+    TableName tableName = createTable(5);
     try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.addColumn(fam, qual1, 125L, value);
@@ -1751,7 +1482,7 @@ public class TestVisibilityLabelsWithDeletes {
           d2.addColumns(fam, qual1, 126L);
 
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             table.delete(createList(d1, d2));
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1761,24 +1492,25 @@ public class TestVisibilityLabelsWithDeletes {
       };
       SUPERUSER.runAs(actiona);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
       assertEquals(1, next.length);
     }
   }
+
   @Test
   public void testDeleteFamilyWithoutCellVisibilityWithMulipleVersions() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPutsWithoutVisibility(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.addFamily(fam);
             table.delete(d);
@@ -1792,7 +1524,7 @@ public class TestVisibilityLabelsWithDeletes {
 
       TEST_UTIL.getAdmin().flush(tableName);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1801,8 +1533,8 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
@@ -1810,13 +1542,13 @@ public class TestVisibilityLabelsWithDeletes {
   public void testDeleteFamilyLatestTimeStampWithMulipleVersionsWithoutCellVisibilityInPuts()
       throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPutsWithoutVisibility(tableName)) {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
             d.addFamily(fam);
@@ -1830,7 +1562,7 @@ public class TestVisibilityLabelsWithDeletes {
       SUPERUSER.runAs(actiona);
       TEST_UTIL.getAdmin().flush(tableName);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1838,51 +1570,51 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(126L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(125L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(124L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(123L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
   @Test
   public void testDeleteFamilySpecificTimeStampWithMulipleVersions() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
-                + SECRET + "&" + TOPSECRET + ")"));
+            d.setCellVisibility(new CellVisibility(
+                "(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" + SECRET + "&" + TOPSECRET + ")"));
             d.addFamily(fam, 126L);
             table.delete(d);
           } catch (Throwable t) {
@@ -1895,7 +1627,7 @@ public class TestVisibilityLabelsWithDeletes {
 
       TEST_UTIL.getAdmin().flush(tableName);
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(6);
@@ -1903,41 +1635,41 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(125L, current.getTimestamp());
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(123L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
   @Test
   public void testScanAfterCompaction() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     try (Table table = doPuts(tableName)) {
       TEST_UTIL.getAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" +
-                SECRET + "&" + TOPSECRET+")"));
+            d.setCellVisibility(new CellVisibility(
+                "(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" + SECRET + "&" + TOPSECRET + ")"));
             d.addFamily(fam, 126L);
             table.delete(d);
           } catch (Throwable t) {
@@ -1958,7 +1690,7 @@ public class TestVisibilityLabelsWithDeletes {
       Thread.sleep(5000);
       // Sleep to ensure compaction happens. Need to do it in a better way
       Scan s = new Scan();
-      s.setMaxVersions(5);
+      s.readVersions(5);
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
@@ -1966,31 +1698,31 @@ public class TestVisibilityLabelsWithDeletes {
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row1, 0, row1.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row1, 0, row1.length));
       assertEquals(127L, current.getTimestamp());
       cellScanner = next[1].cellScanner();
       cellScanner.advance();
       current = cellScanner.current();
-      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
-          current.getRowLength(), row2, 0, row2.length));
+      assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(), current.getRowLength(),
+        row2, 0, row2.length));
     }
   }
 
   @Test
   public void testDeleteFamilySpecificTimeStampWithMulipleVersionsDoneTwice() throws Exception {
     setAuths();
-    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
+    final TableName tableName = TableName.valueOf(testName.getMethodName());
     // Do not flush here.
     try (Table table = doPuts(tableName)) {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
           try (Connection connection = ConnectionFactory.createConnection(conf);
-               Table table = connection.getTable(tableName)) {
+            Table table = connection.getTable(tableName)) {
             Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
-                + TOPSECRET + "&" 

<TRUNCATED>

Mime
View raw message