PR: 4870 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269918 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -34,6 +34,9 @@ Fixed bugs: | |||||
| * <fixcrlf> would fail for files that contained lines longer than 8kB. | * <fixcrlf> would fail for files that contained lines longer than 8kB. | ||||
| * Some junit formatters incorrectly assumed that all testcases would | |||||
| inherit from junit.framework.TestCase. | |||||
| Other changes: | Other changes: | ||||
| -------------- | -------------- | ||||
| @@ -56,6 +56,7 @@ package org.apache.tools.ant.taskdefs.optional.junit; | |||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import junit.framework.Test; | |||||
| import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
| /** | /** | ||||
| @@ -85,8 +86,8 @@ public class JUnitVersionHelper { | |||||
| * access to the name of a TestCase via reflection that is | * access to the name of a TestCase via reflection that is | ||||
| * supposed to work with version before and after JUnit 3.7. | * supposed to work with version before and after JUnit 3.7. | ||||
| */ | */ | ||||
| public static String getTestCaseName(TestCase t) { | |||||
| if (testCaseName != null) { | |||||
| public static String getTestCaseName(Test t) { | |||||
| if (t instanceof TestCase && testCaseName != null) { | |||||
| try { | try { | ||||
| return (String) testCaseName.invoke(t, new Object[0]); | return (String) testCaseName.invoke(t, new Object[0]); | ||||
| } catch (Throwable e) {} | } catch (Throwable e) {} | ||||
| @@ -200,7 +200,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { | |||||
| public void endTest(Test test) { | public void endTest(Test test) { | ||||
| synchronized (wri) { | synchronized (wri) { | ||||
| wri.print("Testcase: " | wri.print("Testcase: " | ||||
| + JUnitVersionHelper.getTestCaseName((TestCase) test)); | |||||
| + JUnitVersionHelper.getTestCaseName(test)); | |||||
| if (Boolean.TRUE.equals(failed.get(test))) { | if (Boolean.TRUE.equals(failed.get(test))) { | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -195,7 +195,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
| Element currentTest = doc.createElement(TESTCASE); | Element currentTest = doc.createElement(TESTCASE); | ||||
| currentTest.setAttribute(ATTR_NAME, | currentTest.setAttribute(ATTR_NAME, | ||||
| JUnitVersionHelper.getTestCaseName((TestCase) t)); | |||||
| JUnitVersionHelper.getTestCaseName(t)); | |||||
| rootElement.appendChild(currentTest); | rootElement.appendChild(currentTest); | ||||
| testElements.put(t, currentTest); | testElements.put(t, currentTest); | ||||
| } | } | ||||