1
|
|
/* Generated by AspectJ version 1.0.5 */
|
2
|
|
package org.apache.cactus.util;
|
3
|
|
import java.lang.reflect.Method;
|
4
|
|
import junit.framework.TestCase;
|
5
|
|
import junit.framework.Test;
|
6
|
|
|
7
|
|
/**
|
8
|
|
* Work around for some changes to the public JUnit API between
|
9
|
|
* different JUnit releases.
|
10
|
|
*
|
11
|
|
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
|
12
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
13
|
|
*
|
14
|
|
* @version $Id: JUnitVersionHelper.java,v 1.4 2002/05/27 15:23:35 vmassol Exp $
|
15
|
|
*/
|
16
|
|
public class JUnitVersionHelper {
|
17
|
|
/**
|
18
|
|
* The <code>Method</code> to use to get the test name from a
|
19
|
|
* <code>TestCase</code> object.
|
20
|
|
*/
|
21
|
|
private static Method testCaseName;
|
22
|
|
/**
|
23
|
|
* JUnit 3.7 introduces TestCase.getName() and subsequent versions
|
24
|
|
* of JUnit remove the old name() method. This method provides
|
25
|
|
* access to the name of a TestCase via reflection that is
|
26
|
|
* supposed to work with version before and after JUnit 3.7.
|
27
|
|
*
|
28
|
|
* @param theTest the test case for which to retrieve the name
|
29
|
|
* @return the test case name
|
30
|
|
*/
|
31
|
366
|
public static String getTestCaseName(Test theTest) {
|
32
|
366
|
if (theTest instanceof TestCase && JUnitVersionHelper.testCaseName != null) {
|
33
|
366
|
try {
|
34
|
366
|
return ((String)JUnitVersionHelper.testCaseName.invoke(theTest, new java.lang.Object[0]));
|
35
|
|
} catch (Throwable e) {
|
36
|
|
}
|
37
|
|
}
|
38
|
0
|
return "unknown";
|
39
|
|
}
|
40
|
|
|
41
|
|
/**
|
42
|
|
* Work around for some changes to the public JUnit API between
|
43
|
|
* different JUnit releases.
|
44
|
|
*
|
45
|
|
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
|
46
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
47
|
|
*
|
48
|
|
* @version $Id: JUnitVersionHelper.java,v 1.4 2002/05/27 15:23:35 vmassol Exp $
|
49
|
|
*/
|
50
|
0
|
public JUnitVersionHelper() {
|
51
|
0
|
super();
|
52
|
|
}
|
53
|
|
/**
|
54
|
|
* Work around for some changes to the public JUnit API between
|
55
|
|
* different JUnit releases.
|
56
|
|
*
|
57
|
|
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
|
58
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
59
|
|
*
|
60
|
|
* @version $Id: JUnitVersionHelper.java,v 1.4 2002/05/27 15:23:35 vmassol Exp $
|
61
|
|
*/
|
62
|
|
static {
|
63
|
|
/**
|
64
|
|
* The <code>Method</code> to use to get the test name from a
|
65
|
|
* <code>TestCase</code> object.
|
66
|
|
*/
|
67
|
10
|
JUnitVersionHelper.testCaseName = null;
|
68
|
10
|
try {
|
69
|
10
|
JUnitVersionHelper.testCaseName = TestCase.class.getMethod("getName",
|
70
|
|
new java.lang.Class[0]);
|
71
|
|
} catch (NoSuchMethodException e) {
|
72
|
0
|
try {
|
73
|
0
|
JUnitVersionHelper.testCaseName = TestCase.class.getMethod("name", new java.lang.Class[0]);
|
74
|
|
} catch (NoSuchMethodException e2) {
|
75
|
0
|
throw new ChainedRuntimeException("Cannot find method name()");
|
76
|
|
}
|
77
|
|
}
|
78
|
|
}
|
79
|
|
|
80
|
|
}
|