|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| package org.easymock.internal; |
|
6 |
| |
|
7 |
| import java.lang.reflect.Method; |
|
8 |
| |
|
9 |
| import org.easymock.ArgumentsMatcher; |
|
10 |
| import org.easymock.IAnswer; |
|
11 |
| |
|
12 |
| public class ReplayState implements IMocksControlState { |
|
13 |
| |
|
14 |
| private IMocksBehavior behavior; |
|
15 |
| |
|
16 |
393
| public ReplayState(IMocksBehavior behavior) {
|
|
17 |
393
| this.behavior = behavior;
|
|
18 |
| } |
|
19 |
| |
|
20 |
548
| public Object invoke(Invocation invocation) throws Throwable {
|
|
21 |
548
| Result result = behavior.addActual(invocation);
|
|
22 |
510
| LastControl.pushCurrentArguments(invocation.getArguments());
|
|
23 |
510
| try {
|
|
24 |
510
| try {
|
|
25 |
510
| return result.answer();
|
|
26 |
| } catch (Throwable t) { |
|
27 |
77
| throw new ThrowableWrapper(t);
|
|
28 |
| } |
|
29 |
| } finally { |
|
30 |
510
| LastControl.popCurrentArguments();
|
|
31 |
| } |
|
32 |
| } |
|
33 |
| |
|
34 |
165
| public void verify() {
|
|
35 |
165
| behavior.verify();
|
|
36 |
| } |
|
37 |
| |
|
38 |
2
| public void replay() {
|
|
39 |
2
| throwWrappedIllegalStateException();
|
|
40 |
| } |
|
41 |
| |
|
42 |
1
| public void callback(Runnable runnable) {
|
|
43 |
1
| throwWrappedIllegalStateException();
|
|
44 |
| } |
|
45 |
| |
|
46 |
2
| public void checkOrder(boolean value) {
|
|
47 |
2
| throwWrappedIllegalStateException();
|
|
48 |
| } |
|
49 |
| |
|
50 |
2
| public void andReturn(Object value) {
|
|
51 |
2
| throwWrappedIllegalStateException();
|
|
52 |
| } |
|
53 |
| |
|
54 |
2
| public void andThrow(Throwable throwable) {
|
|
55 |
2
| throwWrappedIllegalStateException();
|
|
56 |
| } |
|
57 |
| |
|
58 |
1
| public void andAnswer(IAnswer answer) {
|
|
59 |
1
| throwWrappedIllegalStateException();
|
|
60 |
| } |
|
61 |
| |
|
62 |
2
| public void andStubReturn(Object value) {
|
|
63 |
2
| throwWrappedIllegalStateException();
|
|
64 |
| } |
|
65 |
| |
|
66 |
2
| public void andStubThrow(Throwable throwable) {
|
|
67 |
2
| throwWrappedIllegalStateException();
|
|
68 |
| } |
|
69 |
| |
|
70 |
1
| public void andStubAnswer(IAnswer answer) {
|
|
71 |
1
| throwWrappedIllegalStateException();
|
|
72 |
| } |
|
73 |
| |
|
74 |
2
| public void asStub() {
|
|
75 |
2
| throwWrappedIllegalStateException();
|
|
76 |
| } |
|
77 |
| |
|
78 |
3
| public void times(Range range) {
|
|
79 |
3
| throwWrappedIllegalStateException();
|
|
80 |
| } |
|
81 |
| |
|
82 |
2
| public void setMatcher(Method method, ArgumentsMatcher matcher) {
|
|
83 |
2
| throwWrappedIllegalStateException();
|
|
84 |
| } |
|
85 |
| |
|
86 |
3
| public void setDefaultMatcher(ArgumentsMatcher matcher) {
|
|
87 |
3
| throwWrappedIllegalStateException();
|
|
88 |
| } |
|
89 |
| |
|
90 |
7
| public void setDefaultReturnValue(Object value) {
|
|
91 |
7
| throwWrappedIllegalStateException();
|
|
92 |
| } |
|
93 |
| |
|
94 |
3
| public void setDefaultThrowable(Throwable throwable) {
|
|
95 |
3
| throwWrappedIllegalStateException();
|
|
96 |
| } |
|
97 |
| |
|
98 |
2
| public void setDefaultVoidCallable() {
|
|
99 |
2
| throwWrappedIllegalStateException();
|
|
100 |
| } |
|
101 |
| |
|
102 |
38
| private void throwWrappedIllegalStateException() {
|
|
103 |
38
| throw new RuntimeExceptionWrapper(new IllegalStateException(
|
|
104 |
| "This method must not be called in replay state.")); |
|
105 |
| } |
|
106 |
| |
|
107 |
1
| public void assertRecordState() {
|
|
108 |
1
| throwWrappedIllegalStateException();
|
|
109 |
| } |
|
110 |
| } |