FileSystem fs = getFileSystem();
Path jobXmlPath = new Path(appPath, "workflow.xml");
fs.create(jobXmlPath);
int wfCount = MockDagEngineService.workflows.size();
Configuration jobConf = new XConfiguration();
jobConf.set(OozieClient.USER_NAME, getTestUser());
jobConf.set(OozieClient.APP_PATH, appPath);
Map<String, String> params = new HashMap<String, String>();
URL url = createURL("", params);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("content-type", RestConstants.XML_CONTENT_TYPE);
conn.setDoOutput(true);
jobConf.writeXml(conn.getOutputStream());
assertEquals(HttpServletResponse.SC_CREATED, conn.getResponseCode());
JSONObject obj = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream()));
assertEquals(MockDagEngineService.JOB_ID + wfCount + MockDagEngineService.JOB_ID_END,
obj.get(JsonTags.JOB_ID));
assertFalse(MockDagEngineService.started.get(wfCount));
wfCount++;
jobConf = new XConfiguration();
jobConf.set(OozieClient.USER_NAME, getTestUser());
jobConf.set(OozieClient.APP_PATH, appPath);
params = new HashMap<String, String>();
params.put(RestConstants.ACTION_PARAM, RestConstants.JOB_ACTION_START);
url = createURL("", params);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("content-type", RestConstants.XML_CONTENT_TYPE);
conn.setDoOutput(true);
jobConf.writeXml(conn.getOutputStream());
assertEquals(HttpServletResponse.SC_CREATED, conn.getResponseCode());
obj = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream()));
assertEquals(MockDagEngineService.JOB_ID + wfCount + MockDagEngineService.JOB_ID_END,
obj.get(JsonTags.JOB_ID));
assertTrue(MockDagEngineService.started.get(wfCount));
Services services = Services.get();
DagEngine de = services.get(DagEngineService.class).getDagEngine(getTestUser(), "undef");
StringReader sr = new StringReader(de.getJob(MockDagEngineService.JOB_ID + wfCount).getConf());
Configuration conf1 = new XConfiguration(sr);
return null;
}
});
}