Browse Source

This is a test that demonstrates that assert checks dont get through properly. Fix in progress.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276341 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 21 years ago
parent
commit
14d5a4009a
4 changed files with 73 additions and 7 deletions
  1. +19
    -1
      src/etc/testcases/types/assertions.xml
  2. +30
    -0
      src/etc/testcases/types/assertions/AssertionMain.java
  3. +21
    -6
      src/etc/testcases/types/assertions/AssertionTest.java
  4. +3
    -0
      src/testcases/org/apache/tools/ant/types/AssertionsTest.java

+ 19
- 1
src/etc/testcases/types/assertions.xml View File

@@ -4,7 +4,8 @@

<property name="build.dir" location="assertions/build"/>
<property name="src.dir" location="assertions"/>
<property name="classname" value="AssertionTest"/>
<property name="classname" value="AssertionMain"/>
<property name="test.classname" value="AssertionTest"/>
<path id="assert.classpath">
<pathelement location="${build.dir}"/>
@@ -150,4 +151,21 @@
</java>
</target>
<target name="test-junit" depends="setup">
<junit fork="true"
haltonerror="true" haltonfailure="true"
>
<classpath>
<path refid="assert.classpath"/>
</classpath>
<formatter type="plain" usefile="false"/>
<assertions enablesystemassertions="true">
<enable package="..." />
</assertions>
<test name="${test.classname}"/>
</junit>
</target>
</project>

+ 30
- 0
src/etc/testcases/types/assertions/AssertionMain.java View File

@@ -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");
}
}

+ 21
- 6
src/etc/testcases/types/assertions/AssertionTest.java View File

@@ -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);
}
}

+ 3
- 0
src/testcases/org/apache/tools/ant/types/AssertionsTest.java View File

@@ -90,6 +90,9 @@ public class AssertionsTest extends BuildFileTest {
}


public void testJunit() {
executeTarget("test-junit");
}
}



Loading…
Cancel
Save