diff --git a/src/etc/testcases/types/assertions.xml b/src/etc/testcases/types/assertions.xml index d9d8a7894..3f8ab1be4 100644 --- a/src/etc/testcases/types/assertions.xml +++ b/src/etc/testcases/types/assertions.xml @@ -4,7 +4,8 @@ - + + @@ -150,4 +151,21 @@ + + + + + + + + + + + + + + + diff --git a/src/etc/testcases/types/assertions/AssertionMain.java b/src/etc/testcases/types/assertions/AssertionMain.java new file mode 100644 index 000000000..d93a87bc2 --- /dev/null +++ b/src/etc/testcases/types/assertions/AssertionMain.java @@ -0,0 +1,30 @@ +/* + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +/** + * this is an assertion tester + * It has a main() entry + */ +public class AssertionMain { + + public static void main(String args[]) { + assert true == false : "there exist no facts that are both true and false"; + System.out.println("Assertions are disabled"); + } + +} diff --git a/src/etc/testcases/types/assertions/AssertionTest.java b/src/etc/testcases/types/assertions/AssertionTest.java index c79e74a2a..c1ad1cafa 100644 --- a/src/etc/testcases/types/assertions/AssertionTest.java +++ b/src/etc/testcases/types/assertions/AssertionTest.java @@ -15,15 +15,30 @@ * */ + import junit.framework.TestCase; /** - * this is an assertion tester + * this is an assertion tester for junit */ -public class AssertionTest { +public class AssertionTest extends TestCase { - public static void main(String args[]) { - assert true == false : "there exist no facts that are both true and false"; - System.out.println("Assertions are disabled"); - } + public AssertionTest(String name) { + super(name); + } + + public void testAssertRaised() { + try { + assert true == false; + fail("expected an assertion"); + } catch(AssertionError asserto) { + //if we got here, all was well + } + } + + + public void testAssertNotRaised() { + assert(2+2==4); + } + } diff --git a/src/testcases/org/apache/tools/ant/types/AssertionsTest.java b/src/testcases/org/apache/tools/ant/types/AssertionsTest.java index 999028ab9..bd3610874 100644 --- a/src/testcases/org/apache/tools/ant/types/AssertionsTest.java +++ b/src/testcases/org/apache/tools/ant/types/AssertionsTest.java @@ -90,6 +90,9 @@ public class AssertionsTest extends BuildFileTest { } + public void testJunit() { + executeTarget("test-junit"); + } }