Debian Codegraph @

test/src/net/sf/antcontrib/logic/SwitchTest.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 <switch>.
22 */
23 public class SwitchTest extends BuildFileTest {
24
25 public SwitchTest(String name) {
26 super(name);
27 }
28
29 public void setUp() {
30 configureProject("test/resources/logic/switch.xml");
31 }
32
33 public void testNoValue() {
34 expectSpecificBuildException("noValue", "no value",
35 "Value is missing");
36 }
37
38 public void testNoChildren() {
39 expectSpecificBuildException("noChildren", "no children",
40 "No cases supplied");
41 }
42
43 public void testTwoDefaults() {
44 expectSpecificBuildException("twoDefaults", "two defaults",
45 "Cannot specify multiple default cases");
46 }
47
48 public void testNoMatch() {
49 expectSpecificBuildException("noMatch", "no match",
50 "No case matched the value foo"
51 + " and no default has been specified.");
52 }
53
54 public void testCaseNoValue() {
55 expectSpecificBuildException("caseNoValue", "<case> no value",
56 "Value is required for case.");
57 }
58
59 public void testDefault() {
60 executeTarget("testDefault");
61 assertTrue(getLog().indexOf("In default") > -1);
62 assertTrue(getLog().indexOf("baz") > -1);
63 assertEquals(-1, getLog().indexOf("${inner}"));
64 assertEquals(-1, getLog().indexOf("In case"));
65 }
66
67 public void testCase() {
68 executeTarget("testCase");
69 assertTrue(getLog().indexOf("In case") > -1);
70 assertTrue(getLog().indexOf("baz") > -1);
71 assertEquals(-1, getLog().indexOf("${inner}"));
72 assertEquals(-1, getLog().indexOf("In default"));
73 }
74
75 public void testCaseSensitive() {
76 executeTarget("testCaseSensitive");
77 assertTrue(getLog().indexOf("In default") > -1);
78 assertEquals(-1, getLog().indexOf("In case"));
79 }
80
81 public void testCaseInSensitive() {
82 executeTarget("testCaseInSensitive");
83 assertTrue(getLog().indexOf("In case") > -1);
84 assertEquals(-1, getLog().indexOf("In default"));
85 }
86
87 }