diff --git a/src/etc/testcases/taskdefs/optional/junit.xml b/src/etc/testcases/taskdefs/optional/junit.xml index 721bd8874..afc665465 100644 --- a/src/etc/testcases/taskdefs/optional/junit.xml +++ b/src/etc/testcases/taskdefs/optional/junit.xml @@ -258,4 +258,20 @@ + + + + + + + + + + + + + + + + diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java index 18ae9bd27..715a396da 100644 --- a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java +++ b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java @@ -115,6 +115,16 @@ public abstract class BuildFileTest extends TestCase { realLog.indexOf(substring) >= 0); } + /** + * Assert that the given substring is not in the log messages. + */ + public void assertLogNotContaining(String substring) { + String realLog = getLog(); + assertFalse("didn't expect log to contain \"" + substring + "\" log was \"" + + realLog + "\"", + realLog.indexOf(substring) >= 0); + } + /** * Assert that the given substring is in the output messages. * @since Ant1.7 @@ -160,6 +170,15 @@ public abstract class BuildFileTest extends TestCase { assertLogContaining(log); } + /** + * Assert that the given message has not been logged with a + * priority <= INFO when running the given target. + */ + public void expectLogNotContaining(String target, String log) { + executeTarget(target); + assertLogNotContaining(log); + } + /** * Gets the log the BuildFileTest object. * Only valid if configureProject() has been called. diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java index a8fc76d8b..3e428b8e2 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java @@ -216,11 +216,22 @@ public class JUnitTaskTest extends BuildFileTest { } } - public void testBatchTestForkOnceCustomFormatter() { assertResultFilesExist("testBatchTestForkOnceCustomFormatter", "foo"); } + // Bugzilla Issue 45411 + public void testMultilineAssertsNoFork() { + expectLogNotContaining("testMultilineAssertsNoFork", "messed up)"); + assertLogNotContaining("crashed)"); + } + + // Bugzilla Issue 45411 + public void XtestMultilineAssertsFork() { + expectLogNotContaining("testMultilineAssertsFork", "messed up)"); + assertLogNotContaining("crashed)"); + } + private void assertResultFilesExist(String target, String extension) { executeTarget(target); assertResultFileExists("JUnitClassLoader", extension); diff --git a/src/tests/junit/org/example/junit/MultilineAsserts.java b/src/tests/junit/org/example/junit/MultilineAsserts.java new file mode 100644 index 000000000..06e10390d --- /dev/null +++ b/src/tests/junit/org/example/junit/MultilineAsserts.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.example.junit; + +import junit.framework.TestCase; + +public class MultilineAsserts extends TestCase { + public void testFoo() { assertTrue("testFoo \nmessed up", false); } + public void testBar() { assertTrue("testBar \ndidn't work", true); } + public void testFee() { assertTrue("testFee \ncrashed", false); } + public void testFie() { assertTrue("testFie \nbroke", true); } +}