use of org.apache.hadoop.hive.ql.Context in project hive by apache.
the class TestDummyTxnManager method setUp.
@Before
public void setUp() throws Exception {
conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, true);
conf.setVar(HiveConf.ConfVars.HIVE_TXN_MANAGER, DummyTxnManager.class.getName());
conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
SessionState.start(conf);
ctx = new Context(conf);
txnMgr = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf);
Assert.assertTrue(txnMgr instanceof DummyTxnManager);
// Use reflection to set LockManager since creating the object using the
// relection in DummyTxnManager won't take Mocked object
Field field = DummyTxnManager.class.getDeclaredField("lockMgr");
field.setAccessible(true);
field.set(txnMgr, mockLockManager);
Field field2 = DummyTxnManager.class.getDeclaredField("lockManagerCtx");
field2.setAccessible(true);
field2.set(txnMgr, mockLockManagerCtx);
}
use of org.apache.hadoop.hive.ql.Context in project hive by apache.
the class TestHiveAuthorizationTaskFactory method setup.
@Before
public void setup() throws Exception {
queryState = new QueryState.Builder().build();
HiveConf conf = queryState.getConf();
conf.setVar(ConfVars.HIVE_AUTHORIZATION_TASK_FACTORY, TestHiveAuthorizationTaskFactory.DummyHiveAuthorizationTaskFactoryImpl.class.getName());
conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
db = Mockito.mock(Hive.class);
table = new Table(DB, TABLE);
partition = new Partition(table);
SessionState.start(conf);
context = new Context(conf);
parseDriver = new ParseDriver();
analyzer = new DDLSemanticAnalyzer(queryState, db);
Mockito.when(db.getTable(DB, TABLE, false)).thenReturn(table);
Mockito.when(db.getTable(TABLE_QNAME, false)).thenReturn(table);
Mockito.when(db.getPartition(table, new HashMap<String, String>(), false)).thenReturn(partition);
HadoopDefaultAuthenticator auth = new HadoopDefaultAuthenticator();
auth.setConf(conf);
currentUser = auth.getUserName();
DummyHiveAuthorizationTaskFactoryImpl.reset();
}
Aggregations