-
Notifications
You must be signed in to change notification settings - Fork 713
/
LoggingInteraction.java
executable file
·37 lines (33 loc) · 1.41 KB
/
LoggingInteraction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package fitnesse.slim.fixtureInteraction;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import fitnesse.slim.MethodExecutionResult;
public class LoggingInteraction extends SimpleInteraction {
@Override
public Object methodInvoke(Method method, Object instance, Object... convertedArgs) throws Throwable {
long startTime = System.nanoTime();
Exception anyException = null;
Object o = null;
try{
o = super.methodInvoke(method, instance, convertedArgs);
} catch (Exception e) {
anyException = e;
}
String methodName = method.getDeclaringClass().getName() + "." + MethodExecutionResult.methodToString(method)
+ "." + ((instance == null) ? "" : " On instance of: " + instance.getClass().getName());
System.out.println("methodInvoke : " + ((anyException != null) ? "EX" : "OK") + " : " + methodName + " = " + (System.nanoTime() - startTime));
if (anyException == null) {
return o;
} else {
throw anyException;
}
}
@Override
public Object newInstance(Constructor<?> constructor, Object... initargs) throws InvocationTargetException, InstantiationException, IllegalAccessException {
long startTime = System.nanoTime();
Object o = super.newInstance(constructor, initargs);
System.out.println("newInstance : " + (System.nanoTime() - startTime));
return o;
}
}