diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java index aadd02cb756..4b14f668da4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java @@ -26,14 +26,15 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.AuthUtil; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.Coprocessor; 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.TableNotFoundException; +import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.Delete; @@ -44,6 +45,7 @@ import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.master.MasterCoprocessorHost; import org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost; import org.apache.hadoop.hbase.security.User; @@ -77,7 +79,6 @@ public class TestCellACLs extends SecureTestUtil { @Rule public TestTableName TEST_TABLE = new TestTableName(); - private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final byte[] TEST_FAMILY = Bytes.toBytes("f1"); private static final byte[] TEST_ROW = Bytes.toBytes("cellpermtest"); @@ -96,8 +97,6 @@ public class TestCellACLs extends SecureTestUtil { private static User USER_OTHER; private static String[] usersAndGroups; - private Connection connection; - @BeforeClass public static void setupBeforeClass() throws Exception { // setup configuration @@ -141,16 +140,16 @@ public class TestCellACLs extends SecureTestUtil { @Before public void setUp() throws Exception { // Create the test table (owner added to the _acl_ table) - this.connection = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); + Admin admin = TEST_UTIL.getHBaseAdmin(); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY); hcd.setMaxVersions(4); htd.setOwner(USER_OWNER); htd.addFamily(hcd); - TEST_UTIL.createTable(htd, new byte[][] { Bytes.toBytes("s") }); + admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); + TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName()); LOG.info("Sleeping a second because of HBASE-12581"); Threads.sleep(1000); - this.connection = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); } @Test (timeout=120000) @@ -163,17 +162,17 @@ public class TestCellACLs extends SecureTestUtil { Table t = connection.getTable(TEST_TABLE.getTableName())) { Put p; // with ro ACL - p = new Put(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1, ZERO); + p = new Put(TEST_ROW).add(TEST_FAMILY, TEST_Q1, ZERO); p.setACL(prepareCellPermissions(usersAndGroups, Action.READ)); t.put(p); // with rw ACL - p = new Put(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q2, ZERO); + p = new Put(TEST_ROW).add(TEST_FAMILY, TEST_Q2, ZERO); p.setACL(prepareCellPermissions(usersAndGroups, Action.READ, Action.WRITE)); t.put(p); // no ACL p = new Put(TEST_ROW) - .addColumn(TEST_FAMILY, TEST_Q3, ZERO) - .addColumn(TEST_FAMILY, TEST_Q4, ZERO); + .add(TEST_FAMILY, TEST_Q3, ZERO) + .add(TEST_FAMILY, TEST_Q4, ZERO); t.put(p); } return null; @@ -403,7 +402,7 @@ public class TestCellACLs extends SecureTestUtil { try(Connection connection = ConnectionFactory.createConnection(conf); Table t = connection.getTable(TEST_TABLE.getTableName())) { Put p; - p = new Put(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1, ZERO); + p = new Put(TEST_ROW).add(TEST_FAMILY, TEST_Q1, ZERO); t.put(p); } return null; @@ -466,6 +465,5 @@ public class TestCellACLs extends SecureTestUtil { LOG.info("Test deleted table " + TEST_TABLE.getTableName()); } assertEquals(0, AccessControlLists.getTablePermissions(conf, TEST_TABLE.getTableName()).size()); - this.connection.close(); } }