Author: stevel
Date: Wed Apr 25 04:46:08 2007
New Revision: 532325

URL: http://svn.apache.org/viewvc?view=rev&rev=532325
Log:
bug ID#42231, a static method is package scoped instead of public

Modified:
    
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java

Modified: 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java?view=diff&rev=532325&r1=532324&r2=532325
==============================================================================
--- 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
 (original)
+++ 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
 Wed Apr 25 04:46:08 2007
@@ -25,10 +25,20 @@
 /**
  * Work around for some changes to the public JUnit API between
  * different JUnit releases.
+ * @since Ant 1.7
  */
 public class JUnitVersionHelper {
 
     private static Method testCaseName = null;
+
+    /**
+     * Name of the JUnit4 class we look for.
+     * [EMAIL PROTECTED]
+     * @since Ant 1.7.1
+     */
+    public static final String JUNIT_FRAMEWORK_JUNIT4_TEST_CASE_FACADE = 
"junit.framework.JUnit4TestCaseFacade";
+    private static final String UNKNOWN_TEST_CASE_NAME = "unknown";
+
     static {
         try {
             testCaseName = TestCase.class.getMethod("getName", new Class[0]);
@@ -36,7 +46,7 @@
             // pre JUnit 3.7
             try {
                 testCaseName = TestCase.class.getMethod("name", new Class[0]);
-            } catch (NoSuchMethodException e2) {
+            } catch (NoSuchMethodException ignored) {
                 // ignore
             }
         }
@@ -60,9 +70,9 @@
     public static String getTestCaseName(Test t) {
         if (t == null)
         {
-            return "unknown";
+            return UNKNOWN_TEST_CASE_NAME;
         }
-        if 
(t.getClass().getName().equals("junit.framework.JUnit4TestCaseFacade")) {
+        if 
(t.getClass().getName().equals(JUNIT_FRAMEWORK_JUNIT4_TEST_CASE_FACADE)) {
             // Self-describing as of JUnit 4 (#38811). But trim "(ClassName)".
             String name = t.toString();
             if (name.endsWith(")")) {
@@ -75,7 +85,7 @@
         if (t instanceof TestCase && testCaseName != null) {
             try {
                 return (String) testCaseName.invoke(t, new Object[0]);
-            } catch (Throwable e) {
+            } catch (Throwable ignored) {
                 // ignore
             }
         } else {
@@ -92,23 +102,27 @@
                     && getNameMethod.getReturnType() == String.class) {
                     return (String) getNameMethod.invoke(t, new Object[0]);
                 }
-            } catch (Throwable e) {
+            } catch (Throwable ignored) {
                 // ignore
             }
         }
-        return "unknown";
+        return UNKNOWN_TEST_CASE_NAME;
     }
 
     /**
      * Tries to find the name of the class which a test represents
-     * across JUnit 3 and 4.
+     * across JUnit 3 and 4. For Junit4 it parses the toString() value of the
+     * test, and extracts it from there.
+     * @since Ant 1.7.1 (it was private until then)
+     * @param test test case to look at
+     * @return the extracted class name.
      */
-    static String getTestCaseClassName(Test test) {
+    public static String getTestCaseClassName(Test test) {
         String className = test.getClass().getName();
         if (test instanceof JUnitTaskMirrorImpl.VmExitErrorTest) {
             className = ((JUnitTaskMirrorImpl.VmExitErrorTest) 
test).getClassName();
         } else
-        if (className.equals("junit.framework.JUnit4TestCaseFacade")) {
+        if (className.equals(JUNIT_FRAMEWORK_JUNIT4_TEST_CASE_FACADE)) {
             // JUnit 4 wraps solo tests this way. We can extract
             // the original test name with a little hack.
             String name = test.toString();



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to