use of org.jboss.drools.DocumentRoot in project jbpm by kiegroup.
the class BPMN2EmfExtTest method testOnEntryScriptElement.
public void testOnEntryScriptElement() throws Exception {
// write
XMLResource inResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
inResource.setEncoding("UTF-8");
DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot();
OnEntryScriptType root = DroolsFactory.eINSTANCE.createOnEntryScriptType();
root.setScript("script");
root.setScriptFormat("format");
documentRoot.setOnEntryScript(root);
inResource.getContents().add(documentRoot);
StringWriter stringWriter = new StringWriter();
inResource.save(stringWriter, null);
assertNotNull(stringWriter.getBuffer().toString());
if (stringWriter.getBuffer().toString().length() < 1) {
fail("generated xml is empty");
}
// read
XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
outResource.setEncoding("UTF-8");
Map<String, Object> options = new HashMap<String, Object>();
options.put(XMLResource.OPTION_ENCODING, "UTF-8");
InputStream is = new ByteArrayInputStream(stringWriter.getBuffer().toString().getBytes("UTF-8"));
outResource.load(is, options);
DocumentRoot outRoot = (DocumentRoot) outResource.getContents().get(0);
assertNotNull(outRoot.getOnEntryScript());
OnEntryScriptType scriptType = outRoot.getOnEntryScript();
assertEquals("script", scriptType.getScript());
assertEquals("format", scriptType.getScriptFormat());
}
use of org.jboss.drools.DocumentRoot in project jbpm by kiegroup.
the class BPMN2EmfExtTest method testImportElement.
public void testImportElement() throws Exception {
// write
XMLResource inResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
inResource.setEncoding("UTF-8");
DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot();
ImportType root = DroolsFactory.eINSTANCE.createImportType();
root.setName("import");
documentRoot.setImport(root);
inResource.getContents().add(documentRoot);
StringWriter stringWriter = new StringWriter();
inResource.save(stringWriter, null);
assertNotNull(stringWriter.getBuffer().toString());
if (stringWriter.getBuffer().toString().length() < 1) {
fail("generated xml is empty");
}
// read
XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
outResource.setEncoding("UTF-8");
Map<String, Object> options = new HashMap<String, Object>();
options.put(XMLResource.OPTION_ENCODING, "UTF-8");
InputStream is = new ByteArrayInputStream(stringWriter.getBuffer().toString().getBytes("UTF-8"));
outResource.load(is, options);
DocumentRoot outRoot = (DocumentRoot) outResource.getContents().get(0);
assertNotNull(outRoot.getImport());
ImportType importType = outRoot.getImport();
assertEquals("import", importType.getName());
}
use of org.jboss.drools.DocumentRoot in project jbpm by kiegroup.
the class BPMN2EmfExtTest method testMetadataElement.
@SuppressWarnings("unchecked")
public void testMetadataElement() throws Exception {
// write
XMLResource inResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
inResource.setEncoding("UTF-8");
DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot();
MetaDataType metadataType = DroolsFactory.eINSTANCE.createMetaDataType();
metadataType.setName("testvalue");
metadataType.setMetaValue("testentry");
documentRoot.setMetaData(metadataType);
inResource.getContents().add(documentRoot);
StringWriter stringWriter = new StringWriter();
inResource.save(stringWriter, null);
assertNotNull(stringWriter.getBuffer().toString());
if (stringWriter.getBuffer().toString().length() < 1) {
fail("generated xml is empty");
}
// read
XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
outResource.setEncoding("UTF-8");
Map<String, Object> options = new HashMap<String, Object>();
options.put(XMLResource.OPTION_ENCODING, "UTF-8");
InputStream is = new ByteArrayInputStream(stringWriter.getBuffer().toString().getBytes("UTF-8"));
outResource.load(is, options);
DocumentRoot outRoot = (DocumentRoot) outResource.getContents().get(0);
assertNotNull(outRoot.getMetaData());
MetaDataType outMetadataType = outRoot.getMetaData();
assertEquals(outMetadataType.getName(), "testvalue");
assertEquals(outMetadataType.getMetaValue(), "testentry");
}
use of org.jboss.drools.DocumentRoot in project jbpm by kiegroup.
the class BPMN2EmfExtTest method testGlobalElement.
public void testGlobalElement() throws Exception {
// write
XMLResource inResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
inResource.setEncoding("UTF-8");
DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot();
GlobalType root = DroolsFactory.eINSTANCE.createGlobalType();
root.setIdentifier("identifier");
root.setType("type");
documentRoot.setGlobal(root);
inResource.getContents().add(documentRoot);
StringWriter stringWriter = new StringWriter();
inResource.save(stringWriter, null);
assertNotNull(stringWriter.getBuffer().toString());
if (stringWriter.getBuffer().toString().length() < 1) {
fail("generated xml is empty");
}
// read
XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
outResource.setEncoding("UTF-8");
Map<String, Object> options = new HashMap<String, Object>();
options.put(XMLResource.OPTION_ENCODING, "UTF-8");
InputStream is = new ByteArrayInputStream(stringWriter.getBuffer().toString().getBytes("UTF-8"));
outResource.load(is, options);
DocumentRoot outRoot = (DocumentRoot) outResource.getContents().get(0);
assertNotNull(outRoot.getGlobal());
GlobalType globalType = outRoot.getGlobal();
assertEquals("identifier", globalType.getIdentifier());
assertEquals("type", globalType.getType());
}
use of org.jboss.drools.DocumentRoot in project jbpm by kiegroup.
the class BPMN2EmfExtTest method testOnExitScriptElement.
public void testOnExitScriptElement() throws Exception {
// write
XMLResource inResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
inResource.setEncoding("UTF-8");
DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot();
OnExitScriptType root = DroolsFactory.eINSTANCE.createOnExitScriptType();
root.setScript("script");
root.setScriptFormat("format");
documentRoot.setOnExitScript(root);
inResource.getContents().add(documentRoot);
StringWriter stringWriter = new StringWriter();
inResource.save(stringWriter, null);
assertNotNull(stringWriter.getBuffer().toString());
if (stringWriter.getBuffer().toString().length() < 1) {
fail("generated xml is empty");
}
// read
XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
outResource.setEncoding("UTF-8");
Map<String, Object> options = new HashMap<String, Object>();
options.put(XMLResource.OPTION_ENCODING, "UTF-8");
InputStream is = new ByteArrayInputStream(stringWriter.getBuffer().toString().getBytes("UTF-8"));
outResource.load(is, options);
DocumentRoot outRoot = (DocumentRoot) outResource.getContents().get(0);
assertNotNull(outRoot.getOnExitScript());
OnExitScriptType scriptType = outRoot.getOnExitScript();
assertEquals("script", scriptType.getScript());
assertEquals("format", scriptType.getScriptFormat());
}
Aggregations