1 package org.jbpm.bpel.xml; 2 3 import junit.framework.Assert; 4 5 import org.w3c.dom.Element ; 6 7 import org.jbpm.bpel.def.Activity; 8 import org.jbpm.bpel.def.Flow; 9 import org.jbpm.bpel.def.Link; 10 11 17 public class ActivityReaderTest extends AbstractReaderTestCase { 18 19 public void testProcessDefinition() throws Exception { 20 Activity activity = readActivity("<empty/>"); 21 assertEquals(pd, activity.getProcessDefinition()); 22 } 23 24 public void testSuperState() throws Exception { 25 Activity activity = readActivity("<empty/>"); 26 assertEquals(scope, activity.getParent()); 27 } 28 29 public void testName() throws Exception { 30 Activity activity = readActivity("<empty name='n'/>"); 31 assertEquals("n", activity.getName() ); 32 } 33 34 public void testNameDefault() throws Exception { 35 Activity activity = readActivity("<empty/>"); 36 assertNull( activity.getName() ); 37 } 38 39 public void testSuppressJoinFailureYes() throws Exception { 40 Activity activity = readActivity("<empty suppressJoinFailure='yes'/>"); 41 assertEquals( Boolean.TRUE, activity.getSuppressJoinFailure() ); 42 } 43 44 public void testSuppressJoinFailureNo() throws Exception { 45 Activity activity = readActivity("<empty suppressJoinFailure='no'/>"); 46 assertEquals( Boolean.FALSE, activity.getSuppressJoinFailure() ); 47 } 48 49 public void testSuppressJoinFailureDefault() throws Exception { 50 Activity activity = readActivity("<empty/>"); 51 assertNull( activity.getSuppressJoinFailure() ); 52 } 53 54 public void testSuppressJoinFailureInheritance() throws Exception { 55 scope.setSuppressJoinFailure(Boolean.TRUE); 56 Activity activity = readActivity("<empty/>"); 57 assertEquals( activity.suppressJoinFailure(), scope.suppressJoinFailure() ); 58 } 59 60 public void testSources() throws Exception { 61 String xml = 62 "<empty>" + 63 "<sources>" + 64 " <source linkName='l1'>" + 65 " <transitionCondition>$tc</transitionCondition>" + 66 " </source>" + 67 " <source linkName='l2'/>" + 68 "</sources>" + 69 "</empty>"; 70 Flow flow = initFlow(); 71 72 Element element = parseAsBpelElement(xml); 73 Activity activity = readActivity(element, flow); 74 75 Link conditionedLink = activity.getSource("l1"); 77 Assert.assertNotNull(conditionedLink); 78 Assert.assertNotNull(activity.getSource("l2")); 79 80 conditionedLink = flow.getLink(conditionedLink.getName()); 82 assertEquals("$tc", conditionedLink.getTransitionCondition().getText()); 83 } 84 85 public void testSourcesDefault() throws Exception { 86 Activity activity = readActivity("<empty/>"); 87 assertNull(activity.getSources()); 88 } 89 90 public void testTargets() throws Exception { 91 String xml = 92 "<empty>" + 93 "<targets> " + 94 " <joinCondition>'l1'</joinCondition>" + 95 " <target linkName='l1'/>" + 96 " <target linkName='l2'/>" + 97 "</targets>" + 98 "</empty>"; 99 Flow flow = initFlow(); 100 Element element = 101 parseAsBpelElement(xml); 102 Activity activity = readActivity(element, flow); 103 104 Assert.assertNotNull(activity.getTarget("l1")); 106 Assert.assertNotNull(activity.getTarget("l2")); 107 108 Assert.assertEquals("'l1'", activity.getJoinCondition().getText()); 110 } 111 112 public void testTargetsDefault() throws Exception { 113 Activity activity = readActivity("<empty/>"); 114 assertEquals(null, activity.getTargets()); 115 } 116 117 public void testJoinConditionWithoutTargets() throws Exception { 118 Activity activity = readActivity("<empty><joinCondition>'jc'</joinCondition></empty>"); 119 assertNull( activity.getJoinCondition() ); 120 } 121 122 public void testJoinConditionDefault() throws Exception { 123 Activity activity = readActivity("<empty/>"); 124 assertNull( activity.getJoinCondition() ); 125 } 126 127 private Flow initFlow() { 128 Flow flow = new Flow(); 129 flow.setName("f1"); 130 Link link1 = new Link("l1"); 131 Link link2 = new Link("l2"); 132 flow.addLink(link1); 133 flow.addLink(link2); 134 scope.addNode(flow); 135 return flow; 136 } 137 } | Popular Tags |