use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestLiteWorkflowAppService method testCreateprotoConf.
public void testCreateprotoConf() throws Exception {
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
createTestCaseSubDir("lib");
writer = new FileWriter(new File(getTestCaseDir(), "lib/maputil.jar"));
writer.write("bla bla");
writer.close();
writer = new FileWriter(new File(getTestCaseDir(), "lib/reduceutil.so"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("scripts");
writer = new FileWriter(new File(getTestCaseDir(), "scripts/myscript.sh"));
writer.write("bla bla");
writer.close();
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
Configuration protoConf = wps.createProtoActionConf(jobConf, true);
assertEquals(getTestUser(), protoConf.get(OozieClient.USER_NAME));
assertEquals(2, protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST).length);
List<String> found = new ArrayList<String>();
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[0]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1]);
List<String> expected = new ArrayList<String>();
expected.add(getTestCaseFileUri("lib/reduceutil.so"));
expected.add(getTestCaseFileUri("lib/maputil.jar"));
Collections.sort(found);
Collections.sort(expected);
for (int i = 0; i < expected.size(); i++) {
assert (new URI(expected.get(i)).equals(new URI(found.get(i))));
}
Assert.assertTrue(!new URI(found.get(0)).equals(new URI(found.get(1))));
} finally {
services.destroy();
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestLiteWorkflowAppService method testReadDefinition.
public void testReadDefinition() throws Exception {
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
Configuration conf = new XConfiguration();
WorkflowAppService wps = services.get(WorkflowAppService.class);
String wfDef = wps.readDefinition(getTestCaseFileUri("workflow.xml"), getTestUser(), conf);
assertNotNull(reader.toString(), wfDef);
} finally {
services.destroy();
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestLiteWorkflowAppService method testExtSchema.
public void testExtSchema() throws Exception {
setSystemProperty(SchemaService.WF_CONF_EXT_SCHEMAS, "wf-ext-schema.xsd");
setSystemProperty("oozie.service.ActionService.executor.ext.classes", TestActionExecutor.class.getName());
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-ext-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
WorkflowAppService wps = services.get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
LiteWorkflowApp app = (LiteWorkflowApp) wps.parseDef(jobConf);
assertNotNull(app);
assertEquals("test-wf", app.getName());
reader = IOUtils.getResourceAsReader("wf-ext-schema-invalid.xml", -1);
writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
try {
wps.parseDef(jobConf);
fail();
} catch (WorkflowException ex) {
// nop
}
} finally {
services.destroy();
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestLiteWorkflowAppService method testCreateprotoConfWithLibPath.
public void testCreateprotoConfWithLibPath() throws Exception {
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
createTestCaseSubDir("lib");
writer = new FileWriter(new File(getTestCaseDir(), "lib/maputil.jar"));
writer.write("bla bla");
writer.close();
writer = new FileWriter(new File(getTestCaseDir(), "lib/reduceutil.so"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("libx");
writer = new FileWriter(new File(getTestCaseDir(), "libx/maputilx.jar"));
writer.write("bla bla");
writer.close();
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.LIBPATH, getTestCaseFileUri("libx"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
Configuration protoConf = wps.createProtoActionConf(jobConf, true);
assertEquals(getTestUser(), protoConf.get(OozieClient.USER_NAME));
assertEquals(3, protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST).length);
List<String> found = new ArrayList<String>();
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[0]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[2]);
List<String> expected = new ArrayList<String>();
expected.add(getTestCaseFileUri("lib/reduceutil.so"));
expected.add(getTestCaseFileUri("lib/maputil.jar"));
expected.add(getTestCaseFileUri("libx/maputilx.jar"));
Collections.sort(found);
Collections.sort(expected);
assertEquals(expected.size(), found.size());
for (int i = 0; i < expected.size(); i++) {
assert (new URI(expected.get(i)).equals(new URI(found.get(i))));
}
} finally {
services.destroy();
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class TestLiteWorkflowAppService method testCreateprotoConfWithMulipleLibPath.
public void testCreateprotoConfWithMulipleLibPath() throws Exception {
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
createTestCaseSubDir("lib");
writer = new FileWriter(new File(getTestCaseDir(), "lib/maputil.jar"));
writer.write("bla bla");
writer.close();
writer = new FileWriter(new File(getTestCaseDir(), "lib/reduceutil.so"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("libx");
writer = new FileWriter(new File(getTestCaseDir(), "libx/maputil_x.jar"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("liby");
writer = new FileWriter(new File(getTestCaseDir(), "liby/maputil_y1.jar"));
writer.write("bla bla");
writer.close();
writer = new FileWriter(new File(getTestCaseDir(), "liby/maputil_y2.jar"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("libz");
writer = new FileWriter(new File(getTestCaseDir(), "libz/maputil_z.jar"));
writer.write("bla bla");
writer.close();
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.setStrings(OozieClient.LIBPATH, getTestCaseFileUri("libx"), getTestCaseFileUri("liby"), getTestCaseFileUri("libz"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
Configuration protoConf = wps.createProtoActionConf(jobConf, true);
assertEquals(getTestUser(), protoConf.get(OozieClient.USER_NAME));
assertEquals(6, protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST).length);
List<String> found = new ArrayList<String>();
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[0]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[2]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[3]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[4]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[5]);
List<String> expected = new ArrayList<String>();
expected.add(getTestCaseFileUri("lib/reduceutil.so"));
expected.add(getTestCaseFileUri("lib/maputil.jar"));
expected.add(getTestCaseFileUri("libx/maputil_x.jar"));
expected.add(getTestCaseFileUri("liby/maputil_y1.jar"));
expected.add(getTestCaseFileUri("liby/maputil_y2.jar"));
expected.add(getTestCaseFileUri("libz/maputil_z.jar"));
Collections.sort(expected);
Collections.sort(found);
assertEquals(expected.size(), found.size());
for (int i = 0; i < expected.size(); i++) {
assert (new URI(expected.get(i)).equals(new URI(found.get(i))));
}
} finally {
services.destroy();
}
}
Aggregations