1 package org.jbpm.bpel.xml; 2 3 import java.util.List ; 4 5 import org.jbpm.bpel.def.Activity; 6 import org.jbpm.bpel.def.Switch; 7 8 12 public class SwitchReaderTest extends AbstractReaderTestCase { 13 14 public void testCases() throws Exception { 15 String xml = 16 "<switch>" + 17 " <case><condition>$condition1</condition><empty name='case1'/></case>" + 18 " <case><condition>$condition2</condition><empty name='case2'/></case>" + 19 "</switch>"; 20 Switch switchBlock = (Switch) readActivity(xml); 21 List cases = switchBlock.getCases(); 22 assertEquals(2, cases.size()); 23 24 Activity case1 = (Activity) cases.get(0); 25 assertNotNull(case1); 26 assertEquals("case1", case1.getName()); 27 assertEquals(case1.getCompositeActivity(), switchBlock); 28 assertEquals("$condition1", switchBlock.getCondition(case1).getText()); 29 30 Activity case2 = (Activity) cases.get(1); 31 assertEquals("case2", case2.getName()); 32 assertNotNull(case2); 33 assertEquals(case2.getCompositeActivity(), switchBlock); 34 assertEquals("$condition2", switchBlock.getCondition(case2).getText()); 35 } 36 37 public void testOtherwise() throws Exception { 38 String xml = 39 "<switch>" + 40 " <case><condition>$condition1</condition><empty name='case1'/></case>" + 41 " <otherwise><empty name='o'/></otherwise>" + 42 "</switch>"; 43 Switch switchBlock = (Switch) readActivity(xml); 44 Activity otherwise = switchBlock.getOtherwise(); 45 assertNotNull(otherwise); 46 assertEquals("o", otherwise.getName()); 47 assertEquals(otherwise.getCompositeActivity(), switchBlock); 48 } 49 50 public void testOtherwiseDefault() throws Exception { 51 String xml = 52 "<switch>" + 53 " <case><condition>$condition1</condition><empty name='case1'/></case>" + 54 "</switch>"; 55 Switch switchBlock = (Switch) readActivity(xml); 56 Activity otherwise = switchBlock.getOtherwise(); 57 assertNull(otherwise); 58 } 59 } | Popular Tags |