use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class TestCoordUpdateXCommand method testDefinitionChange.
// test definition change
public void testDefinitionChange() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile1 = new File(getTestCaseDir(), "coordinator.xml");
String jobId = setupCoord(conf, "coord-multiple-input-instance3.xml");
CoordinatorJobBean job = getCoordJobs(jobId);
Element processedJobXml = XmlUtils.parseXml(job.getJobXml());
Namespace namespace = processedJobXml.getNamespace();
String text = ((Element) processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("instance", namespace).get(0)).getText();
assertEquals(text, "${coord:latest(0)}");
Reader reader = IOUtils.getResourceAsReader("coord-multiple-input-instance4.xml", -1);
Writer writer = new OutputStreamWriter(new FileOutputStream(appPathFile1), StandardCharsets.UTF_8);
IOUtils.copyCharStream(reader, writer);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile1.toURI().toString());
job = getCoordJobs(jobId);
CoordUpdateXCommand update = new CoordUpdateXCommand(false, conf, jobId);
update.call();
job = getCoordJobs(jobId);
processedJobXml = XmlUtils.parseXml(job.getJobXml());
namespace = processedJobXml.getNamespace();
text = ((Element) processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("instance", namespace).get(0)).getText();
assertEquals(text, "${coord:future(0, 1)}");
}
use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.
the class TestHiveActionExecutor method testHiveAction.
public void testHiveAction() throws Exception {
Path inputDir = new Path(getFsTestCaseDir(), INPUT_DIRNAME);
Path outputDir = new Path(getFsTestCaseDir(), OUTPUT_DIRNAME);
String hiveScript = getHiveScript(inputDir.toString(), outputDir.toString());
FileSystem fs = getFileSystem();
{
Path script = new Path(getAppPath(), HIVE_SCRIPT_FILENAME);
Writer scriptWriter = new OutputStreamWriter(fs.create(script), StandardCharsets.UTF_8);
scriptWriter.write(hiveScript);
scriptWriter.close();
Writer dataWriter = new OutputStreamWriter(fs.create(new Path(inputDir, DATA_FILENAME)), StandardCharsets.UTF_8);
dataWriter.write(SAMPLE_DATA_TEXT);
dataWriter.close();
Context context = createContext(getActionScriptXml());
Namespace ns = Namespace.getNamespace("uri:oozie:hive-action:0.2");
final String launcherId = submitAction(context, ns);
waitUntilYarnAppDoneAndAssertSuccess(launcherId, 180 * 1000);
Configuration conf = new XConfiguration();
conf.set("user.name", getTestUser());
Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
assertFalse(LauncherHelper.hasIdSwap(actionData));
HiveActionExecutor ae = new HiveActionExecutor();
ae.check(context, context.getAction());
assertTrue(launcherId.equals(context.getAction().getExternalId()));
assertEquals("SUCCEEDED", context.getAction().getExternalStatus());
ae.end(context, context.getAction());
assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus());
assertNotNull(context.getExternalChildIDs());
// while this works in a real cluster, it does not with miniMR
// assertTrue(outputData.getProperty(LauncherMain.HADOOP_JOBS).trim().length() > 0);
// assertTrue(!actionData.get(LauncherAMUtils.ACTION_DATA_EXTERNAL_CHILD_IDS).isEmpty());
assertTrue(fs.exists(outputDir));
assertTrue(fs.isDirectory(outputDir));
}
{
Context context = createContext(getActionQueryXml(hiveScript));
Namespace ns = Namespace.getNamespace("uri:oozie:hive-action:0.6");
final String launcherId = submitAction(context, ns);
waitUntilYarnAppDoneAndAssertSuccess(launcherId, 180 * 1000);
Configuration conf = new XConfiguration();
conf.set("user.name", getTestUser());
Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
assertFalse(LauncherHelper.hasIdSwap(actionData));
HiveActionExecutor ae = new HiveActionExecutor();
ae.check(context, context.getAction());
assertTrue(launcherId.equals(context.getAction().getExternalId()));
assertEquals("SUCCEEDED", context.getAction().getExternalStatus());
ae.end(context, context.getAction());
assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus());
assertNotNull(context.getAction().getExternalChildIDs());
// while this works in a real cluster, it does not with miniMR
// assertTrue(outputData.getProperty(LauncherMain.HADOOP_JOBS).trim().length() > 0);
// assertTrue(!actionData.get(LauncherAMUtils.ACTION_DATA_EXTERNAL_CHILD_IDS).isEmpty());
assertTrue(fs.exists(outputDir));
assertTrue(fs.isDirectory(outputDir));
}
}
use of com.google.cloud.servicedirectory.v1.Namespace in project goobi-viewer-indexer by intranda.
the class JDomXP method splitLidoFile.
/**
* Splits a multi-record LIDO document into a list of individual record documents.
*
* @throws io.goobi.viewer.indexer.exceptions.FatalIndexerException
* @should split multi record documents correctly
* @should leave single record documents as is
* @should return empty list for non lido documents
* @should return empty list for non-existing files
* @should return empty list given null
* @param file a {@link java.io.File} object.
* @return a {@link java.util.List} object.
*/
public static List<Document> splitLidoFile(File file) throws FatalIndexerException {
if (file == null) {
return Collections.emptyList();
}
try {
JDomXP xp = new JDomXP(file);
if (xp.doc.getRootElement().getName().equals("lidoWrap")) {
// Multiple LIDO document file
Namespace nsXsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
List<Element> lidoElements = xp.doc.getRootElement().getChildren("lido", Configuration.getInstance().getNamespaces().get("lido"));
if (lidoElements != null) {
List<Document> ret = new ArrayList<>(lidoElements.size());
for (Element eleLidoDoc : lidoElements) {
Document doc = new Document();
doc.setRootElement(eleLidoDoc.clone());
doc.getRootElement().addNamespaceDeclaration(nsXsi);
doc.getRootElement().setAttribute(new Attribute("schemaLocation", "http://www.lido-schema.org http://www.lido-schema.org/schema/v1.0/lido-v1.0.xsd", nsXsi));
ret.add(doc);
}
return ret;
}
} else if (xp.doc.getRootElement().getName().equals("lido")) {
// Single LIDO document file
return Collections.singletonList(xp.doc);
} else {
logger.warn("Unknown root element: {}", xp.doc.getRootElement().getName());
}
} catch (IOException e) {
logger.error(e.getMessage());
} catch (JDOMException e) {
logger.error(e.getMessage());
}
return Collections.emptyList();
}
use of com.google.cloud.servicedirectory.v1.Namespace in project maven-archetype by apache.
the class XMLOutputter method printAttributes.
/**
* This will handle printing of a <code>{@link Attribute}</code> list.
*
* @param attributes <code>List</code> of Attribute objcts
* @param out <code>Writer</code> to use
*/
protected void printAttributes(Writer out, List<?> attributes, Element parent, NamespaceStack namespaces) throws IOException {
// Set prefixes = new HashSet();
for (int i = 0; i < attributes.size(); i++) {
Attribute attribute = (Attribute) attributes.get(i);
Namespace ns = attribute.getNamespace();
if ((ns != Namespace.NO_NAMESPACE) && (ns != Namespace.XML_NAMESPACE)) {
printNamespace(out, ns, namespaces);
}
out.write(" ");
printQualifiedName(out, attribute);
out.write("=");
out.write("\"");
out.write(escapeAttributeEntities(attribute.getValue()));
out.write("\"");
}
}
use of com.google.cloud.servicedirectory.v1.Namespace in project qpp-conversion-tool by CMSgov.
the class PiMeasurePerformedRnRDecoderTest method internalDecodeReturnsTreeContinue.
@Test
void internalDecodeReturnsTreeContinue() {
// set-up
PiMeasurePerformedRnRDecoder objectUnderTest = new PiMeasurePerformedRnRDecoder(new Context());
Namespace rootns = Namespace.getNamespace("urn:hl7-org:v3");
Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Element element = new Element("organizer", rootns);
Element templateIdElement = new Element("templateId", rootns).setAttribute("root", "2.16.840.1.113883.10.20.27.3.28");
Element referenceElement = new Element("reference", rootns);
Element externalDocumentElement = new Element("externalDocument", rootns);
Element idElement = new Element("id", rootns).setAttribute("extension", MEASURE_ID);
externalDocumentElement.addContent(idElement);
referenceElement.addContent(externalDocumentElement);
element.addContent(templateIdElement);
element.addContent(referenceElement);
element.addNamespaceDeclaration(ns);
Node piMeasurePerformedNode = new Node();
objectUnderTest.setNamespace(element.getNamespace());
// execute
DecodeResult decodeResult = objectUnderTest.decode(element, piMeasurePerformedNode);
// assert
assertThat(decodeResult).isEqualTo(DecodeResult.TREE_CONTINUE);
String actualMeasureId = piMeasurePerformedNode.getValue("measureId");
assertThat(actualMeasureId).isEqualTo(MEASURE_ID);
}
Aggregations