1 48 49 package net.sf.antcontrib.logic; 50 51 import org.apache.tools.ant.BuildFileTest; 52 53 58 public class SwitchTest extends BuildFileTest { 59 60 public SwitchTest(String name) { 61 super(name); 62 } 63 64 public void setUp() { 65 configureProject("test/resources/logic/switch.xml"); 66 } 67 68 public void testNoValue() { 69 expectSpecificBuildException("noValue", "no value", 70 "Value is missing"); 71 } 72 73 public void testNoChildren() { 74 expectSpecificBuildException("noChildren", "no children", 75 "No cases supplied"); 76 } 77 78 public void testTwoDefaults() { 79 expectSpecificBuildException("twoDefaults", "two defaults", 80 "Cannot specify multiple default cases"); 81 } 82 83 public void testNoMatch() { 84 expectSpecificBuildException("noMatch", "no match", 85 "No case matched the value foo" 86 + " and no default has been specified."); 87 } 88 89 public void testCaseNoValue() { 90 expectSpecificBuildException("caseNoValue", "<case> no value", 91 "Value is required for case."); 92 } 93 94 public void testDefault() { 95 executeTarget("testDefault"); 96 assertTrue(getLog().indexOf("In default") > -1); 97 assertTrue(getLog().indexOf("baz") > -1); 98 assertEquals(-1, getLog().indexOf("${inner}")); 99 assertEquals(-1, getLog().indexOf("In case")); 100 } 101 102 public void testCase() { 103 executeTarget("testCase"); 104 assertTrue(getLog().indexOf("In case") > -1); 105 assertTrue(getLog().indexOf("baz") > -1); 106 assertEquals(-1, getLog().indexOf("${inner}")); 107 assertEquals(-1, getLog().indexOf("In default")); 108 } 109 110 public void testCaseSensitive() { 111 executeTarget("testCaseSensitive"); 112 assertTrue(getLog().indexOf("In default") > -1); 113 assertEquals(-1, getLog().indexOf("In case")); 114 } 115 116 public void testCaseInSensitive() { 117 executeTarget("testCaseInSensitive"); 118 assertTrue(getLog().indexOf("In case") > -1); 119 assertEquals(-1, getLog().indexOf("In default")); 120 } 121 122 } 123 | Popular Tags |