Browse Source

Throw in some unit tests for <junit> - one of them will fail related to bug 30333

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276899 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
6f4f0c6075
5 changed files with 205 additions and 0 deletions
  1. +27
    -0
      src/etc/testcases/taskdefs/optional/junit.xml
  2. +68
    -0
      src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java
  3. +35
    -0
      src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java
  4. +39
    -0
      src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java
  5. +36
    -0
      src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java

+ 27
- 0
src/etc/testcases/taskdefs/optional/junit.xml View File

@@ -42,4 +42,31 @@
<target name="outputTests"
depends="testForkedOutput,testNonForkedOutput,testForkedThreadedOutput,testNonForkedThreadedOutput" />

<target name="crash">
<junit fork="true" errorproperty="crashed">
<test name="org.apache.tools.ant.taskdefs.optional.junit.VmCrash"/>
<classpath refid="test" />
</junit>
</target>

<target name="nocrash">
<junit fork="true" errorproperty="crashed">
<test name="org.apache.tools.ant.taskdefs.optional.junit.NoVmCrash"/>
<classpath refid="test" />
</junit>
</target>

<target name="timeout">
<junit fork="true" errorproperty="timeout" timeout="1000">
<test name="org.apache.tools.ant.taskdefs.optional.junit.Sleeper"/>
<classpath refid="test" />
</junit>
</target>

<target name="notimeout">
<junit fork="true" errorproperty="timeout" timeout="15000">
<test name="org.apache.tools.ant.taskdefs.optional.junit.Sleeper"/>
<classpath refid="test" />
</junit>
</target>
</project>

+ 68
- 0
src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java View File

@@ -0,0 +1,68 @@
/*
* Copyright 2002,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.
*
*/
package org.apache.tools.ant.taskdefs.optional.junit;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileTest;
import java.lang.reflect.InvocationTargetException;

public class JUnitTaskTest extends BuildFileTest {

/**
* Constructor for the JUnitTaskTest object
*
* @param name we dont know
*/
public JUnitTaskTest(String name) {
super(name);
}


/**
* The JUnit setup method
*/
public void setUp() {
configureProject("src/etc/testcases/taskdefs/optional/junit.xml");
}


/**
* The teardown method for JUnit
*/
public void tearDown() {
//executeTarget("cleanup");
}

public void testCrash() {
expectPropertySet("crash", "crashed");
}

public void testNoCrash() {
expectPropertyUnset("nocrash", "crashed");
}

public void testTimeout() {
expectPropertySet("timeout", "timeout");
}

public void testNoTimeout() {
expectPropertyUnset("notimeout", "timeout");
}

}


+ 35
- 0
src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java View File

@@ -0,0 +1,35 @@
/*
* Copyright 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.
*
*/
package org.apache.tools.ant.taskdefs.optional.junit;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestResult;

/**
* @version $Revision$
*/
public class NoVmCrash extends TestCase {

public NoVmCrash(String name) {
super(name);
}

public void testNoCrash() {
}

}

+ 39
- 0
src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java View File

@@ -0,0 +1,39 @@
/*
* Copyright 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.
*
*/
package org.apache.tools.ant.taskdefs.optional.junit;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestResult;

/**
* @version $Revision$
*/
public class Sleeper extends TestCase {

public Sleeper(String name) {
super(name);
}

public void testSleep() {
try {
Thread.currentThread().sleep(5 * 1000);
} catch (InterruptedException e) {
} // end of try-catch
}

}

+ 36
- 0
src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java View File

@@ -0,0 +1,36 @@
/*
* Copyright 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.
*
*/
package org.apache.tools.ant.taskdefs.optional.junit;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestResult;

/**
* @version $Revision$
*/
public class VmCrash extends TestCase {

public VmCrash(String name) {
super(name);
}

public void testCrash() {
System.exit(0);
}

}

Loading…
Cancel
Save