Browse Source

Tests for PR 45411

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@691622 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
5a0c835c6c
4 changed files with 74 additions and 1 deletions
  1. +16
    -0
      src/etc/testcases/taskdefs/optional/junit.xml
  2. +19
    -0
      src/tests/junit/org/apache/tools/ant/BuildFileTest.java
  3. +12
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java
  4. +27
    -0
      src/tests/junit/org/example/junit/MultilineAsserts.java

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

@@ -258,4 +258,20 @@
</echo>
</target>
<!-- Bugzilla Issue 45411 -->
<target name="testMultilineAssertsNoFork">
<junit>
<test name="org.example.junit.MultilineAsserts"/>
<classpath refid="test"/>
</junit>
</target>

<!-- Bugzilla Issue 45411 -->
<target name="testMultilineAssertsFork">
<junit fork="true">
<test name="org.example.junit.MultilineAsserts"/>
<classpath refid="test"/>
</junit>
</target>

</project>

+ 19
- 0
src/tests/junit/org/apache/tools/ant/BuildFileTest.java View File

@@ -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 &lt;= 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.


+ 12
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java View File

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


+ 27
- 0
src/tests/junit/org/example/junit/MultilineAsserts.java View File

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

Loading…
Cancel
Save