Browse Source

the package name ends at the last dot of a classname, not the first. PR 45227.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1027142 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 14 years ago
parent
commit
a18d38bbd2
3 changed files with 15 additions and 7 deletions
  1. +7
    -1
      WHATSNEW
  2. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  3. +7
    -5
      src/tests/antunit/taskdefs/optional/junit/junit-test.xml

+ 7
- 1
WHATSNEW View File

@@ -175,7 +175,13 @@ Fixed bugs:


* <parallel> could allow tasks to start executing even if a task * <parallel> could allow tasks to start executing even if a task
scheduled to run before them timed out. scheduled to run before them timed out.
Bugzilla Report 49527
Bugzilla Report 49527.

* If a <junit> batch with multiple tests times out Ant logs a message
about a test named Batch-With-Multiple-Tests since 1.8.0 but the
logic that determined the Java package of this pseudo-test has been
wrong.
Bugzilla Report 45227.


Other changes: Other changes:
-------------- --------------


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -2057,7 +2057,7 @@ public class JUnitTask extends Task {
*/ */
private static JUnitTest createDummyTestForBatchTest(JUnitTest test) { private static JUnitTest createDummyTestForBatchTest(JUnitTest test) {
JUnitTest t = (JUnitTest) test.clone(); JUnitTest t = (JUnitTest) test.clone();
int index = test.getName().indexOf('.');
int index = test.getName().lastIndexOf('.');
// make sure test looks as if it was in the same "package" as // make sure test looks as if it was in the same "package" as
// the last test of the batch // the last test of the batch
String pack = index > 0 ? test.getName().substring(0, index + 1) : ""; String pack = index > 0 ? test.getName().substring(0, index + 1) : "";


+ 7
- 5
src/tests/antunit/taskdefs/optional/junit/junit-test.xml View File

@@ -24,9 +24,10 @@


<macrodef name="empty-test"> <macrodef name="empty-test">
<attribute name="classname"/> <attribute name="classname"/>
<attribute name="package" default="test"/>
<sequential> <sequential>
<echo file="${input}/@{classname}.java"><![CDATA[ <echo file="${input}/@{classname}.java"><![CDATA[
package test;
package @{package};
import junit.framework.TestCase; import junit.framework.TestCase;


public class @{classname} extends TestCase { public class @{classname} extends TestCase {
@@ -44,9 +45,9 @@ public class @{classname} extends TestCase {
<target name="testTimeoutLogOfBatchTests"> <target name="testTimeoutLogOfBatchTests">
<mkdir dir="${input}"/> <mkdir dir="${input}"/>
<mkdir dir="${output}"/> <mkdir dir="${output}"/>
<empty-test classname="ATest"/>
<empty-test classname="ATest" package="org.apache.ant.test"/>
<echo file="${input}/BTest.java"><![CDATA[ <echo file="${input}/BTest.java"><![CDATA[
package test;
package org.apache.ant.test;
import junit.framework.TestCase; import junit.framework.TestCase;


public class BTest extends TestCase { public class BTest extends TestCase {
@@ -55,8 +56,8 @@ public class BTest extends TestCase {
} }
} }
]]> </echo> ]]> </echo>
<empty-test classname="CTest"/>
<empty-test classname="DTest"/>
<empty-test classname="CTest" package="org.apache.ant.test"/>
<empty-test classname="DTest" package="org.apache.ant.test"/>
<javac srcdir="${input}" destdir="${output}"> <javac srcdir="${input}" destdir="${output}">
<classpath refid="junit"/> <classpath refid="junit"/>
</javac> </javac>
@@ -71,6 +72,7 @@ public class BTest extends TestCase {
</junit> </junit>
<au:assertLogContains text="ATest"/> <au:assertLogContains text="ATest"/>
<au:assertLogContains text="BTest"/> <au:assertLogContains text="BTest"/>
<au:assertLogContains text="org.apache.ant.test.Batch-With-Multiple-Tests"/>
<au:assertLogDoesntContain text="CTest"/> <au:assertLogDoesntContain text="CTest"/>
<au:assertLogDoesntContain text="DTest"/> <au:assertLogDoesntContain text="DTest"/>
</target> </target>


Loading…
Cancel
Save