*/
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("/BLUB/root/element1");
Element element1
= (Element)xpath.selectSingleNode(returnResult);
String value1 = element1.getAttribute("attr1");
// check testXSLT.xml for the expected result
assertTrue(value1.equals("42"));
xpath = new DOMXPath("/BLUB/root/element2");
Element element2
= (Element)xpath.selectSingleNode(returnResult);
String value2 = element2.getAttribute("attr2");
// check testXSLT.xml for the expected result
assertTrue(value2.equals("66"));
}
// 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");