1 package org.jbpm.graph.def; 2 3 import java.util.List ; 4 5 import org.jbpm.db.AbstractDbTestCase; 6 7 public class ExceptionHandlerDbTest extends AbstractDbTestCase { 8 9 public void testExceptionClassName() { 10 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 11 "<process-definition>" + 12 " <exception-handler exception-class='org.coincidence.FatalAttractionException' />" + 13 "</process-definition>"); 14 15 processDefinition = saveAndReload(processDefinition); 16 17 ExceptionHandler exceptionHandler = (ExceptionHandler) processDefinition.getExceptionHandlers().get(0); 18 assertNotNull(exceptionHandler); 19 assertEquals("org.coincidence.FatalAttractionException", exceptionHandler.getExceptionClassName()); 20 } 21 22 public void testExceptionHandlerProcessDefinition() { 23 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 24 "<process-definition>" + 25 " <exception-handler exception-class='org.coincidence.FatalAttractionException' />" + 26 "</process-definition>"); 27 28 processDefinition = saveAndReload(processDefinition); 29 30 ExceptionHandler exceptionHandler = (ExceptionHandler) processDefinition.getExceptionHandlers().get(0); 31 assertSame(processDefinition, exceptionHandler.getGraphElement()); 32 } 33 34 public void testExceptionHandlerNode() { 35 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 36 "<process-definition>" + 37 " <node name='a'>" + 38 " <exception-handler exception-class='org.coincidence.FatalAttractionException' />" + 39 " </node>" + 40 "</process-definition>"); 41 42 processDefinition = saveAndReload(processDefinition); 43 44 Node node = processDefinition.getNode("a"); 45 ExceptionHandler exceptionHandler = (ExceptionHandler) node.getExceptionHandlers().get(0); 46 assertSame(node, exceptionHandler.getGraphElement()); 47 } 48 49 public void testExceptionHandlerTransition() { 50 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 51 "<process-definition>" + 52 " <node name='a'>" + 53 " <transition name='self' to='a'>" + 54 " <exception-handler exception-class='org.coincidence.FatalAttractionException' />" + 55 " </transition>" + 56 " </node>" + 57 "</process-definition>"); 58 59 processDefinition = saveAndReload(processDefinition); 60 61 Transition transition = processDefinition.getNode("a").getLeavingTransition("self"); 62 ExceptionHandler exceptionHandler = (ExceptionHandler) transition.getExceptionHandlers().get(0); 63 assertSame(transition, exceptionHandler.getGraphElement()); 64 } 65 66 public void testExceptionHandlerActions() { 67 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( 68 "<process-definition>" + 69 " <exception-handler exception-class='org.coincidence.FatalAttractionException'>" + 70 " <action class='one' />" + 71 " <action class='two' />" + 72 " <action class='three' />" + 73 " <action class='four' />" + 74 " </exception-handler>" + 75 "</process-definition>"); 76 77 processDefinition = saveAndReload(processDefinition); 78 79 ExceptionHandler exceptionHandler = (ExceptionHandler) processDefinition.getExceptionHandlers().get(0); 80 List actions = exceptionHandler.getActions(); 81 assertEquals("one", ((Action)actions.get(0)).getActionDelegation().getClassName()); 82 assertEquals("two", ((Action)actions.get(1)).getActionDelegation().getClassName()); 83 assertEquals("three", ((Action)actions.get(2)).getActionDelegation().getClassName()); 84 assertEquals("four", ((Action)actions.get(3)).getActionDelegation().getClassName()); 85 } 86 } 87 | Popular Tags |