Debian Codegraph @

test/src/net/sf/antcontrib/logic/ForeachTaskTest.java

raw symbols SCIP
1 /*
2 * Copyright (c) 2001-2004 Ant-Contrib project. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.antcontrib.logic;
17
18 import org.apache.tools.ant.BuildFileTest;
19
20 /**
21 * Testcase for <foreach>.
22 */
23 public class ForeachTaskTest extends BuildFileTest {
24
25 public ForeachTaskTest(String name) {
26 super(name);
27 }
28
29 public void setUp() {
30 configureProject("test/resources/logic/foreach.xml");
31 }
32
33 public void tearDown() {
34 executeTarget("teardown");
35 }
36
37 public void testSimpleList() {
38 simpleTest("simpleList");
39 }
40
41 public void testDelimiter() {
42 simpleTest("delimiter");
43 }
44
45 public void testFileset() {
46 simpleTest("fileset");
47 assertTrue(getLog().indexOf("The nested fileset element is deprectated,"
48 + " use a nested path instead") > -1);
49 }
50
51 public void testFilesetAndList() {
52 simpleTest("filesetAndList");
53 assertTrue(getLog().indexOf("The nested fileset element is deprectated,"
54 + " use a nested path instead") > -1);
55 }
56
57 public void testNoList() {
58 expectSpecificBuildException("noList", "neither list nor fileset",
59 "You must have a list or path to iterate through");
60 }
61
62 public void testNoTarget() {
63 expectSpecificBuildException("noTarget", "no target",
64 "You must supply a target to perform");
65 }
66
67 public void testNoParam() {
68 expectSpecificBuildException("noParam", "no param",
69 "You must supply a property name to set on each iteration in param");
70 }
71
72 public void testNestedParam() {
73 executeTarget("nestedParam");
74 assertTrue(getLog().indexOf("Called with param: rincewind") > -1);
75 }
76
77 public void testNestedReference() {
78 executeTarget("nestedReference");
79 assertTrue(getLog().indexOf("Called with param: twoflower") > -1);
80 }
81
82 public void testPath() {
83 simpleTest("path");
84 }
85
86 public void testPathAndList() {
87 simpleTest("pathAndList");
88 }
89
90 private void simpleTest(String target) {
91 executeTarget(target);
92 int last = -1;
93 for (int i = 1; i < 4; i++) {
94 int thisIdx = getLog().indexOf("Called with param: " + i);
95 assertTrue(thisIdx > last);
96 last = thisIdx;
97 }
98 }
99 }