| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package net.sf.antcontrib.logic; |
| 17 |
|
| 18 |
import org.apache.tools.ant.BuildFileTest; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
public class IfTaskTest extends BuildFileTest { |
| 24 |
|
| 25 |
public IfTaskTest(String name) { |
| 26 |
super(name); |
| 27 |
} |
| 28 |
|
| 29 |
public void setUp() { |
| 30 |
configureProject("test/resources/logic/if.xml"); |
| 31 |
} |
| 32 |
|
| 33 |
public void testNoCondition() { |
| 34 |
expectSpecificBuildException("noCondition", "no condition", |
| 35 |
"You must nest a condition into <if>"); |
| 36 |
} |
| 37 |
|
| 38 |
public void testTwoConditions() { |
| 39 |
expectSpecificBuildException("twoConditions", "two conditions", |
| 40 |
"You must not nest more than one " |
| 41 |
+ "condition into <if>"); |
| 42 |
} |
| 43 |
|
| 44 |
public void testNothingToDo() { |
| 45 |
expectLog("nothingToDo", ""); |
| 46 |
} |
| 47 |
|
| 48 |
public void testTwoThens() { |
| 49 |
expectSpecificBuildException("twoThens", "two <then>s", |
| 50 |
"You must not nest more than one " |
| 51 |
+ "<then> into <if>"); |
| 52 |
} |
| 53 |
|
| 54 |
public void testTwoElses() { |
| 55 |
expectSpecificBuildException("twoElses", "two <else>s", |
| 56 |
"You must not nest more than one " |
| 57 |
+ "<else> into <if>"); |
| 58 |
} |
| 59 |
|
| 60 |
public void testNormalOperation() { |
| 61 |
executeTarget("normalOperation"); |
| 62 |
assertTrue(getLog().indexOf("In then") > -1); |
| 63 |
assertTrue(getLog().indexOf("some value") > -1); |
| 64 |
assertEquals(-1, getLog().indexOf("${inner}")); |
| 65 |
assertEquals(-1, getLog().indexOf("In else")); |
| 66 |
} |
| 67 |
|
| 68 |
public void testNormalOperation2() { |
| 69 |
executeTarget("normalOperation2"); |
| 70 |
assertTrue(getLog().indexOf("In else") > -1); |
| 71 |
assertEquals(-1, getLog().indexOf("In then")); |
| 72 |
} |
| 73 |
|
| 74 |
public void testNoConditionInElseif() { |
| 75 |
expectSpecificBuildException("noConditionInElseif", "no condition", |
| 76 |
"You must nest a condition into <elseif>"); |
| 77 |
} |
| 78 |
|
| 79 |
public void testTwoConditionInElseif() { |
| 80 |
expectSpecificBuildException("twoConditionsInElseif", "two conditions", |
| 81 |
"You must not nest more than one " |
| 82 |
+ "condition into <elseif>"); |
| 83 |
} |
| 84 |
|
| 85 |
public void testNormalOperationElseif() { |
| 86 |
executeTarget("normalOperationElseif"); |
| 87 |
assertTrue(getLog().indexOf("In elseif") > -1); |
| 88 |
assertEquals(-1, getLog().indexOf("In then")); |
| 89 |
assertEquals(-1, getLog().indexOf("In else-branch")); |
| 90 |
} |
| 91 |
|
| 92 |
public void testNormalOperationElseif2() { |
| 93 |
executeTarget("normalOperationElseif2"); |
| 94 |
assertTrue(getLog().indexOf("In else-branch") > -1); |
| 95 |
assertEquals(-1, getLog().indexOf("In then")); |
| 96 |
assertEquals(-1, getLog().indexOf("In elseif")); |
| 97 |
} |
| 98 |
|
| 99 |
} |