Path script = new Path(getTestCaseDir(), "script.q");
Writer w = new FileWriter(script.toString());
w.write(getHiveScript("${IN}", "${OUT}"));
w.close();
XConfiguration jobConf = new XConfiguration();
jobConf.set("mapreduce.framework.name", "yarn");
jobConf.set("oozie.hive.log.level", "DEBUG");
jobConf.set("user.name", getTestUser());
jobConf.set("group.name", getTestGroup());
jobConf.setInt("mapred.map.tasks", 1);
jobConf.setInt("mapred.map.max.attempts", 1);
jobConf.setInt("mapred.reduce.max.attempts", 1);
jobConf.set("mapred.job.tracker", getJobTrackerUri());
jobConf.set("fs.default.name", getNameNodeUri());
jobConf.set("javax.jdo.option.ConnectionURL", "jdbc:derby:" + getTestCaseDir() + "/db;create=true");
jobConf.set("javax.jdo.option.ConnectionDriverName", "org.apache.derby.jdbc.EmbeddedDriver");
jobConf.set("javax.jdo.option.ConnectionUserName", "sa");
jobConf.set("javax.jdo.option.ConnectionPassword", " ");
SharelibUtils.addToDistributedCache("hive", fs, getFsTestCaseDir(), jobConf);
HiveMain.setHiveScript(jobConf, script.toString(), new String[]{"IN=" + inputDir.toUri().getPath(),
"OUT=" + outputDir.toUri().getPath()});
File actionXml = new File(getTestCaseDir(), "action.xml");
OutputStream os = new FileOutputStream(actionXml);
jobConf.writeXml(os);
os.close();
//needed in the testcase classpath
URL url = Thread.currentThread().getContextClassLoader().getResource("PigMain.txt");
File classPathDir = new File(url.getPath()).getParentFile();
assertTrue(classPathDir.exists());
File hiveSite = new File(classPathDir, "hive-site.xml");
InputStream is = IOUtils.getResourceAsStream("user-hive-default.xml", -1);
os = new FileOutputStream(new File(classPathDir, "hive-default.xml"));
IOUtils.copyStream(is, os);
File outputDataFile = new File(getTestCaseDir(), "outputdata.properties");
setSystemProperty("oozie.launcher.job.id", "" + System.currentTimeMillis());
setSystemProperty("oozie.action.conf.xml", actionXml.getAbsolutePath());
setSystemProperty("oozie.action.output.properties", outputDataFile.getAbsolutePath());
new LauncherSecurityManager();
String user = System.getProperty("user.name");
try {
os = new FileOutputStream(hiveSite);
jobConf.writeXml(os);
os.close();
HiveMain.main(null);
}
catch (SecurityException ex) {
if (LauncherSecurityManager.getExitInvoked()) {