*/
public void createProcessAndRemoveProcessDef() throws Exception {
ProcessDefinitionDirectory pdd = null;
try {
WfRequester cont = new DefaultRequester(workflowService());
Process process = (Process)createProcess("N1", "N2", cont);
process.start();
Thread.sleep(5000);
// get processdata
ProcessData data = process.processContext();
Object value = data.get("result");
if (value != null) {
SAXEventBufferImpl myBuffer
= (SAXEventBufferImpl)value;
TransformerFactory tf
= TransformerFactory.newInstance();
SAXTransformerFactory saxTransFact = null;
if (tf.getFeature(SAXTransformerFactory.FEATURE)) {
saxTransFact = (SAXTransformerFactory)tf;
}
TransformerHandler transHand = null;
transHand = saxTransFact.newTransformerHandler();
StreamResult streamResult = new StreamResult
(new java.io.ByteArrayOutputStream());
transHand.setResult(streamResult);
myBuffer.emit(transHand);
System.out.println(streamResult.getOutputStream().toString());
DOMResult domResult = new DOMResult();
transHand = saxTransFact.newTransformerHandler();
transHand.setResult(domResult);
myBuffer.emit(transHand);
Element returnResult = ((Document)domResult.getNode())
.getDocumentElement();
XPath xpath = new DOMXPath("/parent/firstChild");
String value2 = xpath.stringValueOf(returnResult);
assertTrue(value2.equals("I'm number one"));
XPath xpath2 = new DOMXPath("/parent/thirdChild");
Element child = (Element)xpath2.selectSingleNode(returnResult);
System.out.println("child = " + child.getClass());
org.jdom.Element child2 = new org.jdom.input.DOMBuilder().build(child);
org.jdom.output.XMLOutputter output= new org.jdom.output.XMLOutputter();
java.io.StringWriter sw = new java.io.StringWriter();
output.output(child2, sw);
System.out.println(sw.toString());
}
// remove its process definition
pdd = workflowService().processDefinitionDirectory ();
ProcessDefinition pd
= pdd.lookupProcessDefinition("N1", "N2");
assertTrue(pd!=null);
pdd.removeProcessDefinition("N1", "N2");
boolean gotEx = false;
try {
pd = pdd.lookupProcessDefinition("N1", "N2");
} catch (Exception ex) {
gotEx = true;
}
assertTrue(gotEx);
// check the process definition of the process
ProcessDefinition procDef = process.processDefinition();
assertTrue(procDef.packageId().equals("N1"));
assertTrue(procDef.processId().equals("N2"));
// import the process definition again.
importProcessDefinitions();
pd = pdd.lookupProcessDefinition("N1", "N2");