1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| package org.easymock.internal; |
6 |
| |
7 |
| import java.lang.reflect.InvocationHandler; |
8 |
| import java.lang.reflect.Method; |
9 |
| |
10 |
| public final class MockInvocationHandler implements InvocationHandler { |
11 |
| |
12 |
| final MocksControl control; |
13 |
| |
14 |
366
| public MockInvocationHandler(MocksControl control) {
|
15 |
366
| this.control = control;
|
16 |
| } |
17 |
| |
18 |
984
| public Object invoke(Object proxy, Method method, Object[] args)
|
19 |
| throws Throwable { |
20 |
984
| try {
|
21 |
984
| if (control.getState() instanceof RecordState) {
|
22 |
436
| LastControl.reportLastControl(control);
|
23 |
| } |
24 |
984
| return control.getState().invoke(
|
25 |
| new Invocation(proxy, method, args)); |
26 |
| } catch (RuntimeExceptionWrapper e) { |
27 |
1
| throw e.getRuntimeException().fillInStackTrace();
|
28 |
| } catch (AssertionErrorWrapper e) { |
29 |
37
| throw e.getAssertionError().fillInStackTrace();
|
30 |
| } catch (ThrowableWrapper t) { |
31 |
77
| throw t.getThrowable().fillInStackTrace();
|
32 |
| } |
33 |
| } |
34 |
| |
35 |
104
| public MocksControl getControl() {
|
36 |
104
| return control;
|
37 |
| } |
38 |
| } |