@Before
public void setUp() throws Exception {
super.setUp();
initFile = File.createTempFile("test", "hive");
tmpDir =
initFile.getParentFile().getAbsoluteFile() + File.separator
+ "TestSessionGlobalInitFile";
initFile.delete();
FileUtils.deleteDirectory(new File(tmpDir));
initFile =
new File(tmpDir + File.separator + SessionManager.HIVERCFILE);
initFile.getParentFile().mkdirs();
initFile.createNewFile();
String[] fileContent =
new String[] { "-- global init hive file for test", "set a=1;",
"set hiveconf:b=1;", "set hivevar:c=1;", "set d\\", " =1;",
"add jar " + initFile.getAbsolutePath() };
FileUtils.writeLines(initFile, Arrays.asList(fileContent));
hiveConf = new HiveConf();
hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_GLOBAL_INIT_FILE_LOCATION,
initFile.getParentFile().getAbsolutePath());
hiveConf
.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER,
"org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
service = new FakeEmbeddedThriftBinaryCLIService(hiveConf);
service.init(new HiveConf());
client = new ThriftCLIServiceClient(service);
}