1 48 49 package net.sf.antcontrib.logic; 50 51 import org.apache.tools.ant.BuildFileTest; 52 53 58 public class IfTaskTest extends BuildFileTest { 59 60 public IfTaskTest(String name) { 61 super(name); 62 } 63 64 public void setUp() { 65 configureProject("test/resources/logic/if.xml"); 66 } 67 68 public void testNoCondition() { 69 expectSpecificBuildException("noCondition", "no condition", 70 "You must nest a condition into <if>"); 71 } 72 73 public void testTwoConditions() { 74 expectSpecificBuildException("twoConditions", "two conditions", 75 "You must not nest more than one " 76 + "condition into <if>"); 77 } 78 79 public void testNothingToDo() { 80 expectLog("nothingToDo", ""); 81 } 82 83 public void testTwoThens() { 84 expectSpecificBuildException("twoThens", "two <then>s", 85 "You must not nest more than one " 86 + "<then> into <if>"); 87 } 88 89 public void testTwoElses() { 90 expectSpecificBuildException("twoElses", "two <else>s", 91 "You must not nest more than one " 92 + "<else> into <if>"); 93 } 94 95 public void testNormalOperation() { 96 executeTarget("normalOperation"); 97 assertTrue(getLog().indexOf("In then") > -1); 98 assertTrue(getLog().indexOf("some value") > -1); 99 assertEquals(-1, getLog().indexOf("${inner}")); 100 assertEquals(-1, getLog().indexOf("In else")); 101 } 102 103 public void testNormalOperation2() { 104 executeTarget("normalOperation2"); 105 assertTrue(getLog().indexOf("In else") > -1); 106 assertEquals(-1, getLog().indexOf("In then")); 107 } 108 109 } 110 | Popular Tags |