use of org.drools.core.xml.SemanticModules in project jbpm by kiegroup.
the class TestXml method testSimpleXml.
@Test
public void testSimpleXml() throws Exception {
SemanticModules modules = new SemanticModules();
modules.addSemanticModule(new ProcessSemanticModule());
XmlProcessReader reader = new XmlProcessReader(modules, getClass().getClassLoader());
reader.read(new InputStreamReader(TestXml.class.getResourceAsStream("XmlTest.xml")));
List<Process> processes = reader.getProcess();
assertNotNull(processes);
assertEquals(1, processes.size());
RuleFlowProcess process = (RuleFlowProcess) processes.get(0);
assertNotNull(process);
String output = XmlRuleFlowProcessDumper.INSTANCE.dump(process);
logger.info(output);
reader = new XmlProcessReader(new SemanticModules(), getClass().getClassLoader());
reader.read(new StringReader(output));
}
use of org.drools.core.xml.SemanticModules in project jbpm by kiegroup.
the class XmlRuleFlowProcessDumper method readProcess.
@Override
public Process readProcess(String processXml) {
KnowledgeBuilderConfigurationImpl configuration = new KnowledgeBuilderConfigurationImpl();
SemanticModules modules = configuration.getSemanticModules();
modules.addSemanticModule(new ProcessSemanticModule());
XmlProcessReader xmlReader = new XmlProcessReader(modules, Thread.currentThread().getContextClassLoader());
try {
List<Process> processes = xmlReader.read(new StringReader(processXml));
return processes.get(0);
} catch (Throwable t) {
t.printStackTrace();
return null;
}
}
use of org.drools.core.xml.SemanticModules in project jbpm by kiegroup.
the class XmlBPMNProcessDumper method readProcess.
@Override
public Process readProcess(String processXml) {
SemanticModules semanticModules = new SemanticModules();
semanticModules.addSemanticModule(new BPMNSemanticModule());
semanticModules.addSemanticModule(new BPMNExtensionsSemanticModule());
semanticModules.addSemanticModule(new BPMNDISemanticModule());
XmlProcessReader xmlReader = new XmlProcessReader(semanticModules, Thread.currentThread().getContextClassLoader());
try {
List<Process> processes = xmlReader.read(new StringReader(processXml));
return processes.get(0);
} catch (Throwable t) {
t.printStackTrace();
return null;
}
}
use of org.drools.core.xml.SemanticModules in project jbpm by kiegroup.
the class BPMN2XMLTest method testInvalidXML.
public void testInvalidXML() throws Exception, SAXException {
SemanticModules modules = new SemanticModules();
modules.addSemanticModule(new BPMNSemanticModule());
modules.addSemanticModule(new BPMNDISemanticModule());
XmlProcessReader processReader = new XmlProcessReader(modules, getClass().getClassLoader()) {
@Override
protected String processParserMessage(LinkedList<Object> parents, org.xml.sax.Attributes attr, String errorMessage) {
setErrorMessage(super.processParserMessage(parents, attr, errorMessage));
return errorMessage;
}
};
processReader.read(BPMN2XMLTest.class.getResourceAsStream("/BPMN2-XMLProcessWithError.bpmn2"));
assertNotNull(getErrorMessage());
assertThat(getErrorMessage()).contains("Process Info: id:error.process, pkg:org.jbpm, name:errorprocess, version:1.0 \n" + "Node Info: id:_F8A89567-7416-4CCA-9CCD-BC1DDE870F1E name: \n" + "Parser message: (null: 45, 181): cvc-complex-type.2.4.a: Invalid content was found");
}
Aggregations