sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pras...@apache.org
Subject [2/3] SENTRY-47: Tests need to clean up the databases and tables it creates (Sravya Tirukkovalur via Prasad Mujumdar)
Date Fri, 22 Aug 2014 00:59:55 GMT
http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b6c62f79/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java
index 41bd083..fddb343 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java
@@ -35,22 +35,21 @@ import com.google.common.io.Resources;
 
 public class TestOperations extends AbstractTestWithStaticConfiguration {
   private PolicyFile policyFile;
-  final String dbName = "db1";
   final String tableName = "tb1";
   final String semanticException = "SemanticException No valid privileges";
 
   static Map<String, String> privileges = new HashMap<String, String>();
   static {
     privileges.put("all_server", "server=server1->action=all");
-    privileges.put("all_db1", "server=server1->db=db1->action=all");
-    privileges.put("select_db1", "server=server1->db=db1->action=select");
-    privileges.put("insert_db1", "server=server1->db=db1->action=insert");
-    privileges.put("all_db2", "server=server1->db=db2->action=all");
-    privileges.put("all_db1_tb1", "server=server1->db=db1->table=tb1->action=all");
-    privileges.put("select_db1_tb1", "server=server1->db=db1->table=tb1->action=select");
-    privileges.put("insert_db1_tb1", "server=server1->db=db1->table=tb1->action=insert");
-    privileges.put("insert_db2_tb2", "server=server1->db=db2->table=tb2->action=insert");
-    privileges.put("select_db1_view1", "server=server1->db=db1->table=view1->action=select");
+    privileges.put("all_db1", "server=server1->db=" + DB1 + "->action=all");
+    privileges.put("select_db1", "server=server1->db=" + DB1 + "->action=select");
+    privileges.put("insert_db1", "server=server1->db=" + DB1 + "->action=insert");
+    privileges.put("all_db2", "server=server1->db=" + DB2 + "->action=all");
+    privileges.put("all_db1_tb1", "server=server1->db=" + DB1 + "->table=tb1->action=all");
+    privileges.put("select_db1_tb1", "server=server1->db=" + DB1 + "->table=tb1->action=select");
+    privileges.put("insert_db1_tb1", "server=server1->db=" + DB1 + "->table=tb1->action=insert");
+    privileges.put("insert_db2_tb2", "server=server1->db=" + DB2 + "->table=tb2->action=insert");
+    privileges.put("select_db1_view1", "server=server1->db=" + DB1 + "->table=view1->action=select");
 
   }
 
@@ -86,7 +85,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
   private void adminCreatePartition() throws Exception{
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
-    statement.execute("USE db1");
+    statement.execute("USE " + DB1);
     statement.execute("ALTER TABLE tb1 ADD IF NOT EXISTS PARTITION (b = '1') ");
     statement.close();
     connection.close();
@@ -99,7 +98,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
    */
   @Test
   public void testAllOnDatabase() throws Exception{
-    adminCreate(dbName, null);
+    adminCreate(DB1, null);
     policyFile
         .addPermissionsToRole("all_db1", privileges.get("all_db1"))
         .addRolesToGroup(USERGROUP1, "all_db1");
@@ -108,14 +107,14 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     Connection connection = context.createConnection(USER1_1);
     Statement statement = context.createStatement(connection);
-    statement.execute("CREATE TABLE db1.tb1(a int)");
-    statement.execute("ALTER DATABASE db1 SET DBPROPERTIES ('comment'='comment')");
-    statement.execute("DROP database db1 cascade");
+    statement.execute("CREATE TABLE " + DB1 + ".tb1(a int)");
+    statement.execute("ALTER DATABASE " + DB1 + " SET DBPROPERTIES ('comment'='comment')");
+    statement.execute("DROP database " + DB1 + " cascade");
     statement.close();
     connection.close();
 
     //Negative case
-    adminCreate(dbName, null);
+    adminCreate(DB1, null);
     policyFile
         .addPermissionsToRole("select_db1", privileges.get("select_db1"))
         .addRolesToGroup(USERGROUP2, "select_db1");
@@ -123,9 +122,9 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    context.assertSentrySemanticException(statement, "CREATE TABLE db1.tb1(a int)", semanticException);
-    context.assertSentrySemanticException(statement, "ALTER DATABASE db1 SET DBPROPERTIES ('comment'='comment')", semanticException);
-    context.assertSentrySemanticException(statement, "DROP database db1 cascade", semanticException);
+    context.assertSentrySemanticException(statement, "CREATE TABLE " + DB1 + ".tb1(a int)", semanticException);
+    context.assertSentrySemanticException(statement, "ALTER DATABASE " + DB1 + " SET DBPROPERTIES ('comment'='comment')", semanticException);
+    context.assertSentrySemanticException(statement, "DROP database " + DB1 + " cascade", semanticException);
     statement.close();
     connection.close();
 
@@ -135,7 +134,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
    */
   @Test
   public void testDescDB() throws Exception {
-    adminCreate(dbName, null);
+    adminCreate(DB1, null);
     policyFile
         .addPermissionsToRole("select_db1", privileges.get("select_db1"))
         .addPermissionsToRole("insert_db1", privileges.get("insert_db1"))
@@ -145,13 +144,13 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     Connection connection = context.createConnection(USER1_1);
     Statement statement = context.createStatement(connection);
-    statement.execute("describe database db1");
+    statement.execute("describe database " + DB1);
     statement.close();
     connection.close();
 
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("describe database db1");
+    statement.execute("describe database " + DB1);
     statement.close();
     connection.close();
 
@@ -162,7 +161,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     writePolicyFile(policyFile);
     connection = context.createConnection(USER3_1);
     statement = context.createStatement(connection);
-    context.assertSentrySemanticException(statement, "describe database db1", semanticException);
+    context.assertSentrySemanticException(statement, "describe database " + DB1, semanticException);
     statement.close();
     connection.close();
 
@@ -203,7 +202,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
   */
   @Test
   public void testAllOnTable() throws Exception{
-    adminCreate(dbName, tableName, true);
+    adminCreate(DB1, tableName, true);
     policyFile
         .addPermissionsToRole("all_db1_tb1", privileges.get("all_db1_tb1"))
         .addRolesToGroup(USERGROUP1, "all_db1_tb1")
@@ -216,7 +215,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     //Negative test cases
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     assertSemanticException(statement, "CREATE INDEX table01_index ON TABLE tb1 (a) AS 'COMPACT' WITH DEFERRED REBUILD");
     assertSemanticException(statement, "DROP INDEX table01_index ON tb1");
     assertSemanticException(statement, "ALTER TABLE tb1 ADD IF NOT EXISTS PARTITION (b = '1') ");
@@ -231,13 +230,13 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     //Setup
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     statement.execute("ALTER TABLE tb1 ADD IF NOT EXISTS PARTITION (b = '10') ");
 
     //Negative test cases
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     assertSemanticException(statement, "ALTER TABLE tb1 PARTITION (b = 10) RENAME TO PARTITION (b = 2)");
     assertSemanticException(statement, "ALTER TABLE tb1 PARTITION (b = 10) SET SERDEPROPERTIES ('field.delim' = ',')");
     //assertSemanticException(statement, "ALTER TABLE tb1 ARCHIVE PARTITION (b = 2)");
@@ -260,12 +259,12 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     //assertSemanticException(statement, "ALTER INDEX tb1_index ON tb1 REBUILD");
     assertSemanticException(statement, "ALTER TABLE tb1 RENAME TO tb2");
 
-    assertSemanticException(statement, "DROP TABLE db1.tb1");
+    assertSemanticException(statement, "DROP TABLE " + DB1 + ".tb1");
 
     //Positive cases
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     statement.execute("CREATE INDEX table01_index ON TABLE tb1 (a) AS 'COMPACT' WITH DEFERRED REBUILD");
     statement.execute("DROP INDEX table01_index ON tb1");
     statement.execute("ALTER TABLE tb1 ADD IF NOT EXISTS PARTITION (b = '1') ");
@@ -302,9 +301,9 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     //Drop of the new tablename works only when Hive meta store syncs the alters with the sentry privileges.
     //This is currently not set for pseudo cluster runs
     if( hiveServer2Type.equals(HiveServerFactory.HiveServer2Type.UnmanagedHiveServer2)) {
-      statement.execute("DROP TABLE db1.tb2");
+      statement.execute("DROP TABLE " + DB1 + ".tb2");
     } else {
-      statement.execute("DROP TABLE db1.tb1");
+      statement.execute("DROP TABLE " + DB1 + ".tb1");
     }
 
     statement.close();
@@ -317,7 +316,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
    */
   @Test
   public void testSelectAndInsertOnTable() throws Exception {
-    adminCreate(dbName, tableName, true);
+    adminCreate(DB1, tableName, true);
     adminCreatePartition();
     policyFile
         .addPermissionsToRole("select_db1_tb1", privileges.get("select_db1_tb1"))
@@ -327,7 +326,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     Connection connection = context.createConnection(USER1_1);
     Statement statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     statement.execute("ANALYZE TABLE tb1 PARTITION (b='1' ) COMPUTE STATISTICS");
     statement.close();
     connection.close();
@@ -345,7 +344,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
    */
   @Test
   public void testSelectOnTable() throws Exception {
-    adminCreate(dbName, tableName, true);
+    adminCreate(DB1, tableName, true);
     adminCreatePartition();
     policyFile
         .addPermissionsToRole("select_db1_tb1", privileges.get("select_db1_tb1"))
@@ -354,7 +353,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     Connection connection = context.createConnection(USER1_1);
     Statement statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     statement.execute("select * from tb1");
 
     statement.executeQuery("SHOW Partitions tb1");
@@ -377,7 +376,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     writePolicyFile(policyFile);
     connection = context.createConnection(USER3_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     context.assertSentrySemanticException(statement, "select * from tb1", semanticException);
 
     statement.close();
@@ -398,7 +397,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
    */
   @Test
   public void testInsertOnTable() throws Exception {
-    adminCreate(dbName, tableName, true);
+    adminCreate(DB1, tableName, true);
     adminCreatePartition();
     policyFile
         .addPermissionsToRole("insert_db1_tb1", privileges.get("insert_db1_tb1"))
@@ -407,7 +406,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     Connection connection = context.createConnection(USER1_1);
     Statement statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     /*statement.execute("LOCK TABLE tb1 EXCLUSIVE");
     statement.execute("UNLOCK TABLE tb1");
     */
@@ -438,7 +437,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
    */
   @Test
   public void testAlterAllOnTableAndURI() throws Exception {
-    adminCreate(dbName, tableName, true);
+    adminCreate(DB1, tableName, true);
     String tabLocation = dfs.getBaseDir() + "/" + Math.random();
     policyFile
         .addPermissionsToRole("all_db1_tb1", privileges.get("all_db1_tb1"))
@@ -450,7 +449,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     Connection connection = context.createConnection(USER1_1);
     Statement statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     statement.execute("ALTER TABLE tb1 SET LOCATION '" + tabLocation + "'");
     statement.execute("ALTER TABLE tb1 ADD IF NOT EXISTS PARTITION (b = '3') LOCATION '" + tabLocation + "/part'");
     statement.close();
@@ -464,7 +463,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     connection = context.createConnection(USER3_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     context.assertSentrySemanticException(statement, "ALTER TABLE tb1 SET LOCATION '" + tabLocation + "'",
         semanticException);
     context.assertSentrySemanticException(statement, "ALTER TABLE tb1 ADD IF NOT EXISTS PARTITION (b = '3') LOCATION '"
@@ -480,8 +479,8 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
    */
   @Test
   public void testCreateView() throws Exception {
-    adminCreate(dbName, tableName);
-    adminCreate("db2", null);
+    adminCreate(DB1, tableName);
+    adminCreate(DB2, null);
     policyFile
         .addPermissionsToRole("select_db1_tb1", privileges.get("select_db1_tb1"))
         .addPermissionsToRole("all_db2", privileges.get("all_db2"))
@@ -490,8 +489,8 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     Connection connection = context.createConnection(USER1_1);
     Statement statement = context.createStatement(connection);
-    statement.execute("use db2");
-    statement.execute("create view view1 as select a from db1.tb1");
+    statement.execute("use " + DB2);
+    statement.execute("create view view1 as select a from " + DB1 + ".tb1");
     statement.close();
     connection.close();
 
@@ -503,8 +502,8 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     connection = context.createConnection(USER3_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db2");
-    context.assertSentrySemanticException(statement, "create view view1 as select a from db1.tb1",
+    statement.execute("Use " + DB2);
+    context.assertSentrySemanticException(statement, "create view view1 as select a from " + DB1 + ".tb1",
         semanticException);
     statement.close();
     connection.close();
@@ -525,9 +524,9 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to);
     to.close();
 
-    dropDb(ADMIN1, dbName);
-    createDb(ADMIN1, dbName);
-    createTable(ADMIN1, dbName, dataFile, tableName);
+    dropDb(ADMIN1, DB1);
+    createDb(ADMIN1, DB1);
+    createTable(ADMIN1, DB1, dataFile, tableName);
     String location = dfs.getBaseDir() + "/" + Math.random();
     policyFile
         .addPermissionsToRole("all_db1", privileges.get("all_db1"))
@@ -544,7 +543,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     //Negative case
     connection = context.createConnection(USER3_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     context.assertSentrySemanticException(statement, "export table tb1 to '" + location + "'",
         semanticException);
     statement.close();
@@ -553,7 +552,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     //Positive
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     statement.execute("export table tb1 to '" + location + "'" );
     statement.close();
     connection.close();
@@ -561,7 +560,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     //Negative
     connection = context.createConnection(USER3_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     context.assertSentrySemanticException(statement, "import table tb2 from '" + location + "'",
         semanticException);
     statement.close();
@@ -570,7 +569,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     //Positive
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     statement.execute("import table tb2 from '" + location + "'");
     statement.close();
     connection.close();
@@ -588,7 +587,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to);
     to.close();
 
-    adminCreate(dbName, tableName);
+    adminCreate(DB1, tableName);
 
     policyFile
         .addPermissionsToRole("insert_db1_tb1", privileges.get("insert_db1_tb1"))
@@ -598,7 +597,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     Connection connection = context.createConnection(USER1_1);
     Statement statement = context.createStatement(connection);
-    statement.execute("Use db1");
+    statement.execute("Use " + DB1);
     statement.execute("load data local inpath '" + dataFile.getPath() + "' into table tb1" );
     statement.close();
     connection.close();
@@ -609,13 +608,13 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
    */
   @Test
   public void testCTAS() throws Exception {
-    adminCreate(dbName, tableName);
-    adminCreate("db2", null);
+    adminCreate(DB1, tableName);
+    adminCreate(DB2, null);
 
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
-    statement.execute("Use db1");
-    statement.execute("create view view1 as select a from db1.tb1");
+    statement.execute("Use " + DB1);
+    statement.execute("create view view1 as select a from " + DB1 + ".tb1");
     statement.close();
     connection.close();
 
@@ -629,18 +628,18 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db2");
-    statement.execute("create table tb2 as select a from db1.tb1" );
-    context.assertSentrySemanticException(statement, "create table tb3 as select a from db1.view1",
+    statement.execute("Use " + DB2);
+    statement.execute("create table tb2 as select a from " + DB1 + ".tb1" );
+    context.assertSentrySemanticException(statement, "create table tb3 as select a from " + DB1 + ".view1",
         semanticException);
     statement.close();
     connection.close();
 
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("Use db2");
-    statement.execute("create table tb3 as select a from db1.view1" );
-    context.assertSentrySemanticException(statement, "create table tb4 as select a from db1.tb1",
+    statement.execute("Use " + DB2);
+    statement.execute("create table tb3 as select a from " + DB1 + ".view1" );
+    context.assertSentrySemanticException(statement, "create table tb4 as select a from " + DB1 + ".tb1",
         semanticException);
 
     statement.close();
@@ -658,12 +657,12 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to);
     to.close();
 
-    dropDb(ADMIN1, dbName);
-    dropDb(ADMIN1, "db2");
-    createDb(ADMIN1, dbName);
-    createDb(ADMIN1, "db2");
-    createTable(ADMIN1, dbName, dataFile, tableName);
-    createTable(ADMIN1, "db2", null, "tb2");
+    dropDb(ADMIN1, DB1);
+    dropDb(ADMIN1, DB2);
+    createDb(ADMIN1, DB1);
+    createDb(ADMIN1, DB2);
+    createTable(ADMIN1, DB1, dataFile, tableName);
+    createTable(ADMIN1, DB2, null, "tb2");
     String location = dfs.getBaseDir() + "/" + Math.random();
 
     policyFile
@@ -676,15 +675,15 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
 
     Connection connection = context.createConnection(USER1_1);
     Statement statement = context.createStatement(connection);
-    assertSemanticException(statement, "insert overwrite directory '" + location + "' select * from db1.tb1" );
-    statement.execute("insert overwrite table db2.tb2 select * from db1.tb1");
+    assertSemanticException(statement, "insert overwrite directory '" + location + "' select * from " + DB1 + ".tb1" );
+    statement.execute("insert overwrite table " + DB2 + ".tb2 select * from " + DB1 + ".tb1");
     statement.close();
     connection.close();
 
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("insert overwrite directory '" + location + "' select * from db1.tb1" );
-    assertSemanticException(statement,"insert overwrite table db2.tb2 select * from db1.tb1");
+    statement.execute("insert overwrite directory '" + location + "' select * from " + DB1 + ".tb1" );
+    assertSemanticException(statement,"insert overwrite table " + DB2 + ".tb2 select * from " + DB1 + ".tb1");
     statement.close();
     connection.close();
   }
@@ -695,11 +694,11 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     Statement statement;
     connection = context.createConnection(ADMIN1);
     statement = context.createStatement(connection);
-    statement.execute("create database db1");
-    statement.execute("create table db1.tb1(a int)");
-    statement.execute("DROP table db1.tb1");
-    statement.execute("create table db1.tb1(a int)");
-    statement.execute("use db1");
+    statement.execute("create database " + DB1);
+    statement.execute("create table " + DB1 + ".tb1(a int)");
+    statement.execute("DROP table " + DB1 + ".tb1");
+    statement.execute("create table " + DB1 + ".tb1(a int)");
+    statement.execute("use " + DB1);
     statement.execute("drop table tb1");
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b6c62f79/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java
index 10f5dc8..4452d9a 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java
@@ -80,14 +80,14 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     File db2PolicyFileHandle = new File(context.getPolicyFile().getParent(), DB2_POLICY_FILE);
     db2PolicyFile
         .addRolesToGroup(USERGROUP2, "select_tbl2")
-        .addPermissionsToRole("select_tbl2", "server=server1->db=db2->table=tbl2->action=select")
+        .addPermissionsToRole("select_tbl2", "server=server1->db="  + DB2 + "->table=tbl2->action=select")
         .write(db2PolicyFileHandle);
 
     policyFile
         .addRolesToGroup(USERGROUP1, "select_tbl1")
         .addRolesToGroup(USERGROUP2, "select_tbl2")
-        .addPermissionsToRole("select_tbl1", "server=server1->db=db1->table=tbl1->action=select")
-        .addDatabase("db2", prefix + db2PolicyFileHandle.getName())
+        .addPermissionsToRole("select_tbl1", "server=server1->db=" + DB1 +"->table=tbl1->action=select")
+        .addDatabase(DB2, prefix + db2PolicyFileHandle.getName())
         .setUserGroupMapping(StaticUserGroup.getStaticMapping())
         .write(context.getPolicyFile());
 
@@ -95,16 +95,16 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
 
-    statement.execute("DROP DATABASE IF EXISTS db1 CASCADE");
-    statement.execute("DROP DATABASE IF EXISTS db2 CASCADE");
-    statement.execute("CREATE DATABASE db1");
-    statement.execute("USE db1");
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 +" CASCADE");
+    statement.execute("DROP DATABASE IF EXISTS "  + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE "  + DB1);
+    statement.execute("USE "  + DB1);
     statement.execute("CREATE TABLE tbl1(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE tbl1");
-    statement.execute("DROP DATABASE IF EXISTS db2 CASCADE");
-    statement.execute("CREATE DATABASE db2");
-    statement.execute("USE db2");
+    statement.execute("DROP DATABASE IF EXISTS "  + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE "  + DB2);
+    statement.execute("USE "  + DB2);
     statement.execute("CREATE TABLE tbl2(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE tbl2");
@@ -114,13 +114,13 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE db1");
+    statement.execute("USE "  + DB1);
     // test user1 can execute query on tbl1
     verifyCount(statement, "SELECT COUNT(*) FROM tbl1");
 
     // user1 cannot query db2.tbl2
-    context.assertAuthzException(statement, "USE db2");
-    context.assertAuthzException(statement, "SELECT COUNT(*) FROM db2.tbl2");
+    context.assertAuthzException(statement, "USE "  + DB2);
+    context.assertAuthzException(statement, "SELECT COUNT(*) FROM "  + DB2 + ".tbl2");
     statement.close();
     connection.close();
 
@@ -128,13 +128,13 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
 
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("USE db2");
+    statement.execute("USE "  + DB2);
     // test user2 can execute query on tbl2
     verifyCount(statement, "SELECT COUNT(*) FROM tbl2");
 
     // user2 cannot query db1.tbl1
-    context.assertAuthzException(statement, "SELECT COUNT(*) FROM db1.tbl1");
-    context.assertAuthzException(statement, "USE db1");
+    context.assertAuthzException(statement, "SELECT COUNT(*) FROM " + DB1 +".tbl1");
+    context.assertAuthzException(statement, "USE "  + DB1);
 
     statement.close();
     connection.close();
@@ -142,8 +142,8 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     //test cleanup
     connection = context.createConnection(ADMIN1);
     statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE db1 CASCADE");
-    statement.execute("DROP DATABASE db2 CASCADE");
+    statement.execute("DROP DATABASE " + DB1 +" CASCADE");
+    statement.execute("DROP DATABASE "  + DB2 + " CASCADE");
     statement.close();
     connection.close();
   }
@@ -168,7 +168,7 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     PolicyFile db4PolicyFile = new PolicyFile();
     db2PolicyFile
         .addRolesToGroup(USERGROUP2, "select_tbl2")
-        .addPermissionsToRole("select_tbl2", "server=server1->db=db2->table=tbl2->action=select")
+        .addPermissionsToRole("select_tbl2", "server=server1->db="  + DB2 + "->table=tbl2->action=select")
         .write(db2PolicyFileHandle);
     db3PolicyFile
         .addRolesToGroup(USERGROUP3, "select_tbl3_BAD")
@@ -181,8 +181,8 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     policyFile
         .addRolesToGroup(USERGROUP1, "select_tbl1")
         .addRolesToGroup(USERGROUP2, "select_tbl2")
-        .addPermissionsToRole("select_tbl1", "server=server1->db=db1->table=tbl1->action=select")
-        .addDatabase("db2", prefix + db2PolicyFileHandle.getName())
+        .addPermissionsToRole("select_tbl1", "server=server1->db=" + DB1 +"->table=tbl1->action=select")
+        .addDatabase(DB2, prefix + db2PolicyFileHandle.getName())
         .addDatabase("db3", prefix + db3PolicyFileHandle.getName())
         .addDatabase("db4", prefix + db4PolicyFileHandle.getName())
         .setUserGroupMapping(StaticUserGroup.getStaticMapping())
@@ -192,16 +192,16 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
 
-    statement.execute("DROP DATABASE IF EXISTS db1 CASCADE");
-    statement.execute("CREATE DATABASE db1");
-    statement.execute("USE db1");
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 +" CASCADE");
+    statement.execute("CREATE DATABASE "  + DB1);
+    statement.execute("USE "  + DB1);
     statement.execute("CREATE TABLE tbl1(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE tbl1");
 
-    statement.execute("DROP DATABASE IF EXISTS db2 CASCADE");
-    statement.execute("CREATE DATABASE db2");
-    statement.execute("USE db2");
+    statement.execute("DROP DATABASE IF EXISTS "  + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE "  + DB2);
+    statement.execute("USE "  + DB2);
     statement.execute("CREATE TABLE tbl2(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE tbl2");
@@ -226,14 +226,14 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE db1");
+    statement.execute("USE "  + DB1);
     // test user1 can execute query on tbl1
     verifyCount(statement, "SELECT COUNT(*) FROM tbl1");
     connection.close();
 
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("USE db2");
+    statement.execute("USE "  + DB2);
     // test user1 can execute query on tbl1
     verifyCount(statement, "SELECT COUNT(*) FROM tbl2");
     connection.close();
@@ -256,8 +256,8 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     //test cleanup
     connection = context.createConnection(ADMIN1);
     statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE db1 CASCADE");
-    statement.execute("DROP DATABASE db2 CASCADE");
+    statement.execute("DROP DATABASE " + DB1 +" CASCADE");
+    statement.execute("DROP DATABASE "  + DB2 + " CASCADE");
     statement.execute("DROP DATABASE db3 CASCADE");
     statement.execute("DROP DATABASE db4 CASCADE");
     statement.close();
@@ -271,16 +271,16 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     policyFile
         .addRolesToGroup(USERGROUP1, "select_tbl1")
         .addRolesToGroup(USERGROUP2, "select_tbl2")
-        .addPermissionsToRole("select_tbl1", "server=server1->db=db1->table=tbl1->action=select")
-        .addDatabase("db2", prefix + db2PolicyFileHandle.getName())
+        .addPermissionsToRole("select_tbl1", "server=server1->db=" + DB1 +"->table=tbl1->action=select")
+        .addDatabase(DB2, prefix + db2PolicyFileHandle.getName())
         .setUserGroupMapping(StaticUserGroup.getStaticMapping())
         .write(context.getPolicyFile());
 
     PolicyFile db2PolicyFile = new PolicyFile();
     db2PolicyFile
         .addRolesToGroup(USERGROUP2, "select_tbl2", "data_read", "insert_tbl2")
-        .addPermissionsToRole("select_tbl2", "server=server1->db=db2->table=tbl2->action=select")
-        .addPermissionsToRole("insert_tbl2", "server=server1->db=db2->table=tbl2->action=insert")
+        .addPermissionsToRole("select_tbl2", "server=server1->db="  + DB2 + "->table=tbl2->action=select")
+        .addPermissionsToRole("insert_tbl2", "server=server1->db="  + DB2 + "->table=tbl2->action=insert")
         .addPermissionsToRole("data_read", "server=server1->URI=file://" + dataFile)
         .write(db2PolicyFileHandle);
     // ugly hack: needs to go away once this becomes a config property. Note that this property
@@ -291,16 +291,16 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
 
-    statement.execute("DROP DATABASE IF EXISTS db1 CASCADE");
-    statement.execute("DROP DATABASE IF EXISTS db2 CASCADE");
-    statement.execute("CREATE DATABASE db1");
-    statement.execute("USE db1");
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 +" CASCADE");
+    statement.execute("DROP DATABASE IF EXISTS "  + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE "  + DB1);
+    statement.execute("USE "  + DB1);
     statement.execute("CREATE TABLE tbl1(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE tbl1");
-    statement.execute("DROP DATABASE IF EXISTS db2 CASCADE");
-    statement.execute("CREATE DATABASE db2");
-    statement.execute("USE db2");
+    statement.execute("DROP DATABASE IF EXISTS "  + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE "  + DB2);
+    statement.execute("USE "  + DB2);
     statement.execute("CREATE TABLE tbl2(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE tbl2");
@@ -310,20 +310,20 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE db1");
+    statement.execute("USE "  + DB1);
     // test user1 can execute query on tbl1
     verifyCount(statement, "SELECT COUNT(*) FROM tbl1");
 
     // user1 cannot query db2.tbl2
-    context.assertAuthzException(statement, "USE db2");
-    context.assertAuthzException(statement, "SELECT COUNT(*) FROM db2.tbl2");
+    context.assertAuthzException(statement, "USE "  + DB2);
+    context.assertAuthzException(statement, "SELECT COUNT(*) FROM "  + DB2 + ".tbl2");
     statement.close();
     connection.close();
 
     // test per-db file for db2
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("USE db2");
+    statement.execute("USE "  + DB2);
     // test user2 can execute query on tbl2
     verifyCount(statement, "SELECT COUNT(*) FROM tbl2");
 
@@ -331,12 +331,12 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE tbl2");
 
     // user2 cannot query db1.tbl1
-    context.assertAuthzException(statement, "SELECT COUNT(*) FROM db1.tbl1");
-    context.assertAuthzException(statement, "USE db1");
+    context.assertAuthzException(statement, "SELECT COUNT(*) FROM " + DB1 +".tbl1");
+    context.assertAuthzException(statement, "USE "  + DB1);
 
     // once we disable this property all queries should fail
     System.setProperty(SimpleDBPolicyEngine.ACCESS_ALLOW_URI_PER_DB_POLICYFILE, "false");
-    context.assertAuthzException(statement, "USE db2");
+    context.assertAuthzException(statement, "USE "  + DB2);
 
     // re-enable for clean
     System.setProperty(SimpleDBPolicyEngine.ACCESS_ALLOW_URI_PER_DB_POLICYFILE, "true");
@@ -347,8 +347,8 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     //test cleanup
     connection = context.createConnection(ADMIN1);
     statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE db1 CASCADE");
-    statement.execute("DROP DATABASE db2 CASCADE");
+    statement.execute("DROP DATABASE " + DB1 +" CASCADE");
+    statement.execute("DROP DATABASE "  + DB2 + " CASCADE");
     statement.close();
     connection.close();
   }
@@ -361,7 +361,7 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
   public void testDefaultDb() throws Exception {
     policyFile
         .addRolesToGroup(USERGROUP1, "select_tbl1")
-        .addPermissionsToRole("select_tbl1", "server=server1->db=db1->table=tbl1->action=select")
+        .addPermissionsToRole("select_tbl1", "server=server1->db=" + DB1 +"->table=tbl1->action=select")
         .setUserGroupMapping(StaticUserGroup.getStaticMapping())
         .write(context.getPolicyFile());
 
@@ -371,12 +371,12 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
 
     statement.execute("USE default");
 
-    statement.execute("DROP DATABASE IF EXISTS db1 CASCADE");
-    statement.execute("CREATE DATABASE db1");
-    statement.execute("USE db1");
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 +" CASCADE");
+    statement.execute("CREATE DATABASE "  + DB1);
+    statement.execute("USE "  + DB1);
     statement.execute("CREATE TABLE tbl1(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
-    statement.execute("DROP DATABASE IF EXISTS db2 CASCADE");
+    statement.execute("DROP DATABASE IF EXISTS "  + DB2 + " CASCADE");
     statement.close();
     connection.close();
 
@@ -404,8 +404,8 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     policyFile
         .addRolesToGroup(USERGROUP1, "select_tbl1")
         .addRolesToGroup(USERGROUP2, "select_tbl2")
-        .addPermissionsToRole("select_tbl1", "server=server1->db=db1->table=tbl1->action=select")
-        .addDatabase("db2", prefix + db2PolicyFileHandle.getName())
+        .addPermissionsToRole("select_tbl1", "server=server1->db=" + DB1 +"->table=tbl1->action=select")
+        .addDatabase(DB2, prefix + db2PolicyFileHandle.getName())
         .addDatabase("default", prefix + defaultPolicyFileHandle.getName())
         .setUserGroupMapping(StaticUserGroup.getStaticMapping())
         .write(context.getPolicyFile());
@@ -413,7 +413,7 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     PolicyFile db2PolicyFile = new PolicyFile();
     db2PolicyFile
         .addRolesToGroup(USERGROUP2, "select_tbl2")
-        .addPermissionsToRole("select_tbl2", "server=server1->db=db2->table=tbl2->action=select")
+        .addPermissionsToRole("select_tbl2", "server=server1->db="  + DB2 + "->table=tbl2->action=select")
         .write(db2PolicyFileHandle);
 
     PolicyFile defaultPolicyFile = new PolicyFile();
@@ -430,15 +430,15 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     statement.execute("CREATE TABLE dtab(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
 
-    statement.execute("DROP DATABASE IF EXISTS db1 CASCADE");
-    statement.execute("DROP DATABASE IF EXISTS db2 CASCADE");
-    statement.execute("CREATE DATABASE db1");
-    statement.execute("USE db1");
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 +" CASCADE");
+    statement.execute("DROP DATABASE IF EXISTS "  + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE "  + DB1);
+    statement.execute("USE "  + DB1);
     statement.execute("CREATE TABLE tbl1(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
-    statement.execute("DROP DATABASE IF EXISTS db2 CASCADE");
-    statement.execute("CREATE DATABASE db2");
-    statement.execute("USE db2");
+    statement.execute("DROP DATABASE IF EXISTS "  + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE "  + DB2);
+    statement.execute("USE "  + DB2);
     statement.execute("CREATE TABLE tbl2(B INT, A STRING) " +
                       " row format delimited fields terminated by '|'  stored as textfile");
     statement.close();
@@ -447,10 +447,10 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     // user_1 should be able to switch to default, but not the tables from default
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE db1");
+    statement.execute("USE "  + DB1);
     statement.execute("USE default");
     context.assertAuthzException(statement, "SELECT * FROM dtab");
-    statement.execute("USE db1");
+    statement.execute("USE "  + DB1);
     context.assertAuthzException(statement, "SELECT * FROM default.dtab");
 
     statement.close();
@@ -459,10 +459,10 @@ public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration
     // user_2 should be able to access default and select from default's tables
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("USE db2");
+    statement.execute("USE "  + DB2);
     statement.execute("USE default");
     statement.execute("SELECT * FROM dtab");
-    statement.execute("USE db2");
+    statement.execute("USE "  + DB2);
     statement.execute("SELECT * FROM default.dtab");
     statement.close();
     connection.close();

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b6c62f79/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java
index b31446c..c8712e7 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java
@@ -59,7 +59,7 @@ public class TestPerDatabasePolicyFile extends AbstractTestWithStaticConfigurati
    */
   @Test
   public void testDbSpecificFileGrantsToOtherDb() throws Exception {
-    doTestDbSpecificFileGrants("server=server1->db=db1");
+    doTestDbSpecificFileGrants("server=server1->db=" + DB1);
   }
   /**
    * Ensure that db specific file cannot grant to all db
@@ -93,8 +93,8 @@ public class TestPerDatabasePolicyFile extends AbstractTestWithStaticConfigurati
     // setup db objects needed by the test
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
-    createSampleDbTable(statement, "db1", "tbl1");
-    createSampleDbTable(statement, "db2", "tbl1");
+    createSampleDbTable(statement, DB1, "tbl1");
+    createSampleDbTable(statement, DB2, "tbl1");
     statement.close();
     connection.close();
 
@@ -105,14 +105,14 @@ public class TestPerDatabasePolicyFile extends AbstractTestWithStaticConfigurati
     .addRolesToGroup("group1", "db1_role");
     specificPolicyFile.write(specificPolicyFileFile);
 
-    policyFile.addDatabase("db2", specificPolicyFileFile.getPath());
+    policyFile.addDatabase(DB2, specificPolicyFileFile.getPath());
     writePolicyFile(policyFile);
 
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
     // test user can query table
-    context.assertAuthzException(statement, "USE db1");
-    context.assertAuthzException(statement, "SELECT COUNT(a) FROM db1.tbl1");
+    context.assertAuthzException(statement, "USE " + DB1);
+    context.assertAuthzException(statement, "SELECT COUNT(a) FROM " + DB1 + ".tbl1");
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b6c62f79/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java
index d115cad..2d34015 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java
@@ -59,25 +59,24 @@ public class TestPrivilegeAtTransform extends AbstractTestWithStaticConfiguratio
   @Test
   public void testTransform1() throws Exception {
     policyFile
-      .addPermissionsToRole("all_db1", "server=server1->db=db_1")
+      .addPermissionsToRole("all_db1", "server=server1->db=" + DB1)
       .addRolesToGroup(USERGROUP1, "all_db1")
       .setUserGroupMapping(StaticUserGroup.getStaticMapping());
     writePolicyFile(policyFile);
 
     // verify by SQL
     // 1, 2
-    String dbName1 = "db_1";
     String tableName1 = "tb_1";
-    String query = "select TRANSFORM(a.under_col, a.value) USING 'cat' AS (tunder_col, tvalue) FROM " + dbName1 + "." + tableName1 + " a";
+    String query = "select TRANSFORM(a.under_col, a.value) USING 'cat' AS (tunder_col, tvalue) FROM " + DB1 + "." + tableName1 + " a";
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE IF EXISTS " + dbName1 + " CASCADE");
-    statement.execute("CREATE DATABASE " + dbName1);
-    statement.execute("DROP TABLE IF EXISTS " + dbName1 + "." + tableName1);
-    statement.execute("create table " + dbName1 + "." + tableName1
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 + " CASCADE");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("DROP TABLE IF EXISTS " + DB1 + "." + tableName1);
+    statement.execute("create table " + DB1 + "." + tableName1
         + " (under_col int, value string)");
     statement.execute("load data local inpath '" + dataFile.getPath()
-            + "' into table " + dbName1 + "." + tableName1);
+            + "' into table " + DB1 + "." + tableName1);
     assertTrue(query, statement.execute(query));
 
     statement.close();
@@ -91,8 +90,8 @@ public class TestPrivilegeAtTransform extends AbstractTestWithStaticConfiguratio
 
     // 4
     policyFile
-      .addPermissionsToRole("select_tb1", "server=server1->db=db_1->table=tb_1->action=select")
-      .addPermissionsToRole("insert_tb1", "server=server1->db=db_1->table=tb_1->action=insert")
+      .addPermissionsToRole("select_tb1", "server=server1->db=" + DB1 + "->table=tb_1->action=select")
+      .addPermissionsToRole("insert_tb1", "server=server1->db=" + DB1 + "->table=tb_1->action=insert")
       .addRolesToGroup(USERGROUP1, "select_tb1", "insert_tb1");
     writePolicyFile(policyFile);
     context.assertAuthzExecHookException(statement, query);

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b6c62f79/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java
index a0669cd..653b6fb 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java
@@ -61,25 +61,25 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
 
     policyFile
         .addRolesToGroup(USERGROUP1, "all_db1")
-        .addPermissionsToRole("all_db1", "server=server1->db=DB_1->action=all")
+        .addPermissionsToRole("all_db1", "server=server1->db=" + DB1 + "->action=all")
         .setUserGroupMapping(StaticUserGroup.getStaticMapping());
     writePolicyFile(policyFile);
 
     // setup db objects needed by the test
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
-    statement.execute("create database db_1");
-    statement.execute("create table db_1.tab1(a int)");
+    statement.execute("create database " + DB1);
+    statement.execute("create table " + DB1 + ".tab1(a int)");
 
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("use db_1");
+    statement.execute("use " + DB1);
     statement.execute("select * from tab1");
 
     policyFile
-        .addPermissionsToRole("all_db1", "server=server1->db=DB_1");
+        .addPermissionsToRole("all_db1", "server=server1->db=" + DB1);
     writePolicyFile(policyFile);
-    statement.execute("use db_1");
+    statement.execute("use " + DB1);
     statement.execute("select * from tab1");
   }
 
@@ -100,8 +100,8 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
     policyFile
         .addRolesToGroup(USERGROUP1, "all_db1", "load_data")
         .addRolesToGroup(USERGROUP2, "all_db2")
-        .addPermissionsToRole("all_db1", "server=server1->db=DB_1")
-        .addPermissionsToRole("all_db2", "server=server1->db=DB_2")
+        .addPermissionsToRole("all_db1", "server=server1->db=" + DB1)
+        .addPermissionsToRole("all_db2", "server=server1->db=" + DB2)
         .addPermissionsToRole("load_data", "server=server1->uri=file://" + dataFile.getPath())
         .setUserGroupMapping(StaticUserGroup.getStaticMapping());
     writePolicyFile(policyFile);
@@ -109,10 +109,10 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
     // setup db objects needed by the test
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
-    statement.execute("DROP DATABASE IF EXISTS DB_2 CASCADE");
-    statement.execute("CREATE DATABASE DB_1");
-    statement.execute("CREATE DATABASE DB_2");
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 + " CASCADE");
+    statement.execute("DROP DATABASE IF EXISTS " + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("CREATE DATABASE " + DB2);
     statement.close();
     connection.close();
 
@@ -120,18 +120,18 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
     // test user can create table
-    statement.execute("CREATE TABLE DB_1.TAB_1(A STRING)");
+    statement.execute("CREATE TABLE " + DB1 + ".TAB_1(A STRING)");
     // test user can execute load
-    statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE DB_1.TAB_1");
-    statement.execute("CREATE TABLE DB_1.TAB_2(A STRING)");
-    statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE DB_1.TAB_2");
+    statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE " + DB1 + ".TAB_1");
+    statement.execute("CREATE TABLE " + DB1 + ".TAB_2(A STRING)");
+    statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE " + DB1 + ".TAB_2");
 
     // test CTAS can reference UDFs
-    statement.execute("USE DB_1");
+    statement.execute("USE " + DB1);
     statement.execute("create table table2 as select A, count(A) from TAB_1 GROUP BY A");
 
     // test user can switch db
-    statement.execute("USE DB_1");
+    statement.execute("USE " + DB1);
     //test user can create view
     statement.execute("CREATE VIEW VIEW_1(A) AS SELECT A FROM TAB_1");
 
@@ -163,7 +163,7 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
 
     //negative test case: user can't drop another user's database
     try {
-      statement.execute("DROP DATABASE DB_2 CASCADE");
+      statement.execute("DROP DATABASE " + DB2 + " CASCADE");
       Assert.fail("Expected SQL exception");
     } catch (SQLException e) {
       context.verifyAuthzException(e);
@@ -171,14 +171,14 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
 
     //negative test case: user can't switch into another user's database
     try {
-      statement.execute("USE DB_2");
+      statement.execute("USE " + DB2);
       Assert.fail("Expected SQL exception");
     } catch (SQLException e) {
       context.verifyAuthzException(e);
     }
 
     //User can drop own database
-    statement.execute("DROP DATABASE DB_1 CASCADE");
+    statement.execute("DROP DATABASE " + DB1 + " CASCADE");
 
     statement.close();
     connection.close();
@@ -186,7 +186,7 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
     //test cleanup
     connection = context.createConnection(ADMIN1);
     statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE DB_2 CASCADE");
+    statement.execute("DROP DATABASE " + DB2 + " CASCADE");
     statement.close();
     connection.close();
     context.close();
@@ -209,8 +209,8 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
     policyFile
         .addRolesToGroup(USERGROUP1, "all_db1", "load_data", "exttab")
         .addRolesToGroup(USERGROUP2, "all_db2")
-        .addPermissionsToRole("all_db1", "server=server1->db=DB_1")
-        .addPermissionsToRole("all_db2", "server=server1->db=DB_2")
+        .addPermissionsToRole("all_db1", "server=server1->db=" + DB1)
+        .addPermissionsToRole("all_db2", "server=server1->db=" + DB2)
         .addPermissionsToRole("exttab", "server=server1->uri=file://" + dataDir.getPath())
         .addPermissionsToRole("load_data", "server=server1->uri=file://" + dataFile.getPath())
         .setUserGroupMapping(StaticUserGroup.getStaticMapping());
@@ -219,11 +219,11 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
     // setup db objects needed by the test
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
-    statement.execute("DROP DATABASE IF EXISTS DB_2 CASCADE");
-    statement.execute("CREATE DATABASE DB_1");
-    statement.execute("CREATE DATABASE DB_2");
-    statement.execute("USE DB_1");
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 + " CASCADE");
+    statement.execute("DROP DATABASE IF EXISTS " + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("CREATE DATABASE " + DB2);
+    statement.execute("USE " + DB1);
     statement.execute("CREATE TABLE TAB_1(A STRING)");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE TAB_1");
     statement.execute("CREATE TABLE PART_TAB_1(A STRING) partitioned by (B INT) STORED AS TEXTFILE");
@@ -236,7 +236,7 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
     // test user can switch db
-    statement.execute("USE DB_1");
+    statement.execute("USE " + DB1);
     // test user can execute load
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE TAB_1");
     statement.execute("CREATE TABLE TAB_2(A STRING)");
@@ -297,8 +297,8 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
     //test cleanup
     connection = context.createConnection(ADMIN1);
     statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE DB_1 CASCADE");
-    statement.execute("DROP DATABASE DB_2 CASCADE");
+    statement.execute("DROP DATABASE " + DB1 + " CASCADE");
+    statement.execute("DROP DATABASE " + DB2 + " CASCADE");
     statement.close();
     connection.close();
     context.close();
@@ -319,8 +319,8 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
         .addRolesToGroup(USERGROUP1, "all_db1")
         .addRolesToGroup(USERGROUP2, "select_db2")
         .addRolesToGroup(USERGROUP3, "all_db3")
-        .addPermissionsToRole("all_db1", "server=server1->db=DB_1")
-        .addPermissionsToRole("select_db2", "server=server1->db=DB_2->table=tab_2->action=select")
+        .addPermissionsToRole("all_db1", "server=server1->db=" + DB1)
+        .addPermissionsToRole("select_db2", "server=server1->db=" + DB2 + "->table=tab_2->action=select")
         .addPermissionsToRole("all_db3", "server=server1->db=DB_3")
         .setUserGroupMapping(StaticUserGroup.getStaticMapping());
     writePolicyFile(policyFile);
@@ -330,40 +330,40 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
     // setup db objects needed by the test
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
-    statement.execute("CREATE DATABASE DB_1");
-    statement.execute("use DB_1");
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 + " CASCADE");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("use " + DB1);
     statement.execute("CREATE TABLE TAB_1(A STRING)");
-    statement.execute("DROP DATABASE IF EXISTS DB_2 CASCADE");
-    statement.execute("CREATE DATABASE DB_2");
-    statement.execute("use DB_1");
+    statement.execute("DROP DATABASE IF EXISTS " + DB2 + " CASCADE");
+    statement.execute("CREATE DATABASE " + DB2);
+    statement.execute("use " + DB1);
     statement.execute("CREATE TABLE TAB_2(A STRING)");
     context.close();
 
     // user1 should be able to connect db_1
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("use DB_1");
+    statement.execute("use " + DB1);
     context.close();
 
     // user2 should not be able to connect db_1
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
     try {
-      statement.execute("use DB_1");
-      assertFalse("user2 shouldn't be able switch to db_1", true);
+      statement.execute("use " + DB1);
+      assertFalse("user2 shouldn't be able switch to " + DB1, true);
     } catch (SQLException e) {
       context.verifyAuthzException(e);
     }
-    statement.execute("use DB_2");
+    statement.execute("use " + DB2);
     context.close();
 
     // user3 who is not listed in policy file should not be able to connect db_2
     connection = context.createConnection(USER3_1);
     statement = context.createStatement(connection);
     try {
-      statement.execute("use DB_2");
-      assertFalse("user3 shouldn't be able switch to db_2", true);
+      statement.execute("use " + DB2);
+      assertFalse("user3 shouldn't be able switch to " + DB2, true);
     } catch (SQLException e) {
       context.verifyAuthzException(e);
     }
@@ -383,8 +383,8 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfigu
         .addRolesToGroup(USERGROUP1, "all_db1")
         .addRolesToGroup(USERGROUP2, "select_db2")
         .addRolesToGroup(USERGROUP3, "all_default")
-        .addPermissionsToRole("all_db1", "server=server1->db=DB_1")
-        .addPermissionsToRole("select_db2", "server=server1->db=DB_2->table=tab_2->action=select")
+        .addPermissionsToRole("all_db1", "server=server1->db=" + DB1)
+        .addPermissionsToRole("select_db2", "server=server1->db=" + DB2 + "->table=tab_2->action=select")
         .addPermissionsToRole("all_default", "server=server1->db=default")
         .setUserGroupMapping(StaticUserGroup.getStaticMapping());
     writePolicyFile(policyFile);

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b6c62f79/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
index 1e1978d..f1f64e6 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
@@ -58,7 +58,6 @@ public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticConfigu
    */
   @Test
   public void testFuncPrivileges1() throws Exception {
-    String dbName1 = "db_1";
     String tableName1 = "tb_1";
     String udfClassName = "org.apache.hadoop.hive.ql.udf.generic.GenericUDFPrintf";
     CodeSource udfSrc = Class.forName(udfClassName).getProtectionDomain().getCodeSource();
@@ -68,13 +67,13 @@ public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticConfigu
     }
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
-    statement.execute("DROP DATABASE IF EXISTS " + dbName1 + " CASCADE");
-    statement.execute("CREATE DATABASE " + dbName1);
-    statement.execute("USE " + dbName1);
-    statement.execute("create table " + dbName1 + "." + tableName1
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 + " CASCADE");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("USE " + DB1);
+    statement.execute("create table " + DB1 + "." + tableName1
         + " (under_col int comment 'the under column', value string)");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE "
-        + dbName1 + "." + tableName1);
+        + DB1 + "." + tableName1);
     statement.execute("DROP TEMPORARY FUNCTION IF EXISTS printf_test");
     statement.execute("DROP TEMPORARY FUNCTION IF EXISTS printf_test_2");
     context.close();
@@ -83,25 +82,25 @@ public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticConfigu
         .addRolesToGroup(USERGROUP1, "db1_all", "UDF_JAR")
         .addRolesToGroup(USERGROUP2, "db1_tab1", "UDF_JAR")
         .addRolesToGroup(USERGROUP3, "db1_tab1")
-        .addPermissionsToRole("db1_all", "server=server1->db=" + dbName1)
-        .addPermissionsToRole("db1_tab1", "server=server1->db=" + dbName1 + "->table=" + tableName1)
+        .addPermissionsToRole("db1_all", "server=server1->db=" + DB1)
+        .addPermissionsToRole("db1_tab1", "server=server1->db=" + DB1 + "->table=" + tableName1)
         .addPermissionsToRole("UDF_JAR", "server=server1->uri=file://" + udfLocation);
     writePolicyFile(policyFile);
 
     // user1 should be able create/drop temp functions
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE " + dbName1);
+    statement.execute("USE " + DB1);
     statement.execute(
         "CREATE TEMPORARY FUNCTION printf_test AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFPrintf'");
     statement.execute("SELECT printf_test(value) FROM " + tableName1);
     statement.execute("DROP TEMPORARY FUNCTION printf_test");
     context.close();
 
-    // user2 has select privilege on one of the tables in db2, should be able create/drop temp functions
+    // user2 has select privilege on one of the tables in db1, should be able create/drop temp functions
     connection = context.createConnection(USER2_1);
     statement = context.createStatement(connection);
-    statement.execute("USE " + dbName1);
+    statement.execute("USE " + DB1);
     statement.execute(
         "CREATE TEMPORARY FUNCTION printf_test_2 AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFPrintf'");
     statement.execute("SELECT printf_test_2(value) FROM " + tableName1);
@@ -112,7 +111,7 @@ public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticConfigu
     connection = context.createConnection(USER3_1);
     statement = context.createStatement(connection);
     try {
-      statement.execute("USE " + dbName1);
+      statement.execute("USE " + DB1);
       statement.execute(
       "CREATE TEMPORARY FUNCTION printf_test_bad AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFPrintf'");
       assertFalse("CREATE TEMPORARY FUNCTION should fail for user3", true);
@@ -138,27 +137,26 @@ public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticConfigu
 
   @Test
   public void testUdfWhiteList () throws Exception {
-    String dbName1 = "db1";
     String tableName1 = "tab1";
 
     policyFile
         .addRolesToGroup(USERGROUP1, "db1_all", "UDF_JAR")
         .addRolesToGroup(USERGROUP2, "db1_tab1", "UDF_JAR")
         .addRolesToGroup(USERGROUP3, "db1_tab1")
-        .addPermissionsToRole("db1_all", "server=server1->db=" + dbName1)
-        .addPermissionsToRole("db1_tab1", "server=server1->db=" + dbName1 + "->table=" + tableName1)
+        .addPermissionsToRole("db1_all", "server=server1->db=" + DB1)
+        .addPermissionsToRole("db1_tab1", "server=server1->db=" + DB1 + "->table=" + tableName1)
         .addPermissionsToRole("UDF_JAR", "server=server1->uri=file://${user.home}/.m2");
     writePolicyFile(policyFile);
 
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = connection.createStatement();
-    statement.execute("DROP DATABASE IF EXISTS " + dbName1 + " CASCADE");
-    statement.execute("CREATE DATABASE " + dbName1);
-    statement.execute("USE " + dbName1);
+    statement.execute("DROP DATABASE IF EXISTS " + DB1 + " CASCADE");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("USE " + DB1);
     statement.execute("create table " + tableName1
         + " (under_col int comment 'the under column', value string)");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE "
-        + dbName1 + "." + tableName1);
+        + DB1 + "." + tableName1);
     statement.execute("SELECT rand(), concat(value, '_foo') FROM " + tableName1);
 
     context.assertAuthzException(statement,

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/b6c62f79/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java
index 2fece0a..45a4b7c 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java
@@ -173,8 +173,8 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     Connection connection = context.createConnection(ADMIN1);
     Statement statement = context.createStatement(connection);
     statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
-    statement.execute("CREATE DATABASE DB_1");
-    statement.execute("USE DB_1");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("USE " + DB1);
     statement.execute("CREATE TABLE TAB_1(A STRING)");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath()
         + "' INTO TABLE TAB_1");
@@ -188,7 +188,7 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE DB_1");
+    statement.execute("USE " + DB1);
     // test user can execute insert on table
     statement.execute("INSERT INTO TABLE TAB_1 SELECT A FROM TAB_2");
 
@@ -262,8 +262,8 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     Statement statement = context.createStatement(connection);
 
     statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
-    statement.execute("CREATE DATABASE DB_1");
-    statement.execute("USE DB_1");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("USE " + DB1);
     statement.execute("CREATE TABLE TAB_1(A STRING)");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath()
         + "' INTO TABLE TAB_1");
@@ -277,7 +277,7 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE DB_1");
+    statement.execute("USE " + DB1);
     // test user can execute query on table
     ResultSet resultSet = statement.executeQuery("SELECT COUNT(A) FROM TAB_1");
     int count = 0;
@@ -350,8 +350,8 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     Statement statement = context.createStatement(connection);
 
     statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
-    statement.execute("CREATE DATABASE DB_1");
-    statement.execute("USE DB_1");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("USE " + DB1);
     statement.execute("CREATE TABLE TAB_1(B INT, A STRING) "
         + " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath()
@@ -367,7 +367,7 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE DB_1");
+    statement.execute("USE " + DB1);
     // test user can execute query TAB_1 JOIN TAB_2
     ResultSet resultSet = statement
         .executeQuery("SELECT COUNT(*) FROM TAB_1 T1 JOIN TAB_2 T2 ON (T1.B = T2.B)");
@@ -428,8 +428,8 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     Statement statement = context.createStatement(connection);
 
     statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
-    statement.execute("CREATE DATABASE DB_1");
-    statement.execute("USE DB_1");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("USE " + DB1);
     statement.execute("CREATE TABLE TAB_1(B INT, A STRING) "
         + " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath()
@@ -445,7 +445,7 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE DB_1");
+    statement.execute("USE " + DB1);
     // test user can execute query on TAB_2
     ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) FROM TAB_2");
     int count = 0;
@@ -513,8 +513,8 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     Statement statement = context.createStatement(connection);
 
     statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
-    statement.execute("CREATE DATABASE DB_1");
-    statement.execute("USE DB_1");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("USE " + DB1);
     statement.execute("CREATE TABLE TAB_1(B INT, A STRING) "
         + " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath()
@@ -530,7 +530,7 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE DB_1");
+    statement.execute("USE " + DB1);
     // test user can execute query on TAB_2
     ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) FROM TAB_2");
     int count = 0;
@@ -614,8 +614,8 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     Statement statement = context.createStatement(connection);
 
     statement.execute("DROP DATABASE IF EXISTS DB_1 CASCADE");
-    statement.execute("CREATE DATABASE DB_1");
-    statement.execute("USE DB_1");
+    statement.execute("CREATE DATABASE " + DB1);
+    statement.execute("USE " + DB1);
     statement.execute("CREATE TABLE TAB_1(B INT, A STRING) "
         + " row format delimited fields terminated by '|'  stored as textfile");
     statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath()
@@ -631,7 +631,7 @@ public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfigurat
     // test execution
     connection = context.createConnection(USER1_1);
     statement = context.createStatement(connection);
-    statement.execute("USE DB_1");
+    statement.execute("USE " + DB1);
 
     // test user can execute query VIEW_1 JOIN TAB_1
     ResultSet resultSet = statement


Mime
View raw message