From 6f4f0c60756a92b3a5dbc1c123904be0db030ad3 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 30 Sep 2004 09:39:57 +0000 Subject: [PATCH] Throw in some unit tests for - 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 --- src/etc/testcases/taskdefs/optional/junit.xml | 27 ++++++++ .../optional/junit/JUnitTaskTest.java | 68 +++++++++++++++++++ .../taskdefs/optional/junit/NoVmCrash.java | 35 ++++++++++ .../ant/taskdefs/optional/junit/Sleeper.java | 39 +++++++++++ .../ant/taskdefs/optional/junit/VmCrash.java | 36 ++++++++++ 5 files changed, 205 insertions(+) create mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java create mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java create mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java create mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java diff --git a/src/etc/testcases/taskdefs/optional/junit.xml b/src/etc/testcases/taskdefs/optional/junit.xml index 766266889..a8074ddb5 100644 --- a/src/etc/testcases/taskdefs/optional/junit.xml +++ b/src/etc/testcases/taskdefs/optional/junit.xml @@ -42,4 +42,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java new file mode 100644 index 000000000..9fb5e5430 --- /dev/null +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java @@ -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"); + } + +} + diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java new file mode 100644 index 000000000..2a540c54c --- /dev/null +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java @@ -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() { + } + +} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java new file mode 100644 index 000000000..e0cb08862 --- /dev/null +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java @@ -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 + } + +} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java new file mode 100644 index 000000000..b75d6ff21 --- /dev/null +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java @@ -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); + } + +}