KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > types > AssertionsTest


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
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  */

17 package org.apache.tools.ant.types;
18
19 import org.apache.tools.ant.BuildFileTest;
20
21 /**
22  * test assertion handling
23  */

24 public class AssertionsTest extends BuildFileTest {
25
26     public AssertionsTest(String JavaDoc name) {
27         super(name);
28     }
29
30     protected void setUp() throws Exception JavaDoc {
31         configureProject("src/etc/testcases/types/assertions.xml");
32     }
33
34     protected void tearDown() throws Exception JavaDoc {
35         executeTarget("teardown");
36     }
37
38     /**
39      * runs a test and expects an assertion thrown in forked code
40      * @param target
41      */

42     protected void expectAssertion(String JavaDoc target) {
43         expectBuildExceptionContaining(target,
44                 "assertion not thrown in "+target,
45                 "Java returned: 1");
46     }
47
48     public void testClassname() {
49         expectAssertion("test-classname");
50     }
51
52     public void testPackage() {
53         expectAssertion("test-package");
54     }
55
56     public void testEmptyAssertions() {
57         executeTarget("test-empty-assertions");
58     }
59
60     public void testDisable() {
61         executeTarget("test-disable");
62     }
63
64     public void testOverride() {
65         expectAssertion("test-override");
66     }
67
68     public void testOverride2() {
69         executeTarget("test-override2");
70     }
71     public void testReferences() {
72         expectAssertion("test-references");
73     }
74
75     public void testMultipleAssertions() {
76         expectBuildExceptionContaining("test-multiple-assertions",
77                 "multiple assertions rejected",
78                 "Only one assertion declaration is allowed");
79     }
80
81     public void testReferenceAbuse() {
82         expectBuildExceptionContaining("test-reference-abuse",
83                 "reference abuse rejected",
84                 "You must not specify more than one attribute when using refid");
85     }
86
87     public void testNofork() {
88         expectLogContaining("test-nofork",
89                 "Assertion statements are currently ignored in non-forked mode");
90     }
91
92
93 }
94
95
96
Popular Tags