< bean id=
根據這個思路
import static org
final class MockTestHelper {
public static void resetAll(Object testObject) {
reset(getDeclaredMockedFields(testObject));
}
public static void verifyAll(Object testObject) {
verify(getDeclaredMockedFields(testObject));
}
public static void replayAll(Object testObject) {
replay(getDeclaredMockedFields(testObject));
}
private static Object[] getDeclaredMockedFields(Object testObject) {
Field[] declaredFields = testObject
List declaredMockedFields = new ArrayList();
for (Field field : declaredFields) {
if (field
boolean isAccessible = field
try {
field
Object value = field
if (isClassProxy(value
declaredMockedFields
}
} catch (IllegalAccessException e) {
e
}
finally {
field
}
}
}
return declaredMockedFields
}
private static boolean isClassProxy(Class clazz) {
String className = clazz
return className
}
}
好了
這樣看起來就好多了
[
From:http://tw.wingwit.com/Article/program/Java/ky/201311/29008.html