Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
33   132   25   1,43
2   96   0,76   23
23     1,09  
1    
 
 
  ReplayState       Line # 12 33 25 100% 1.0
 
  (257)
 
1    /*
2    * Copyright (c) 2001-2008 OFFIS, Tammo Freese.
3    * This program is made available under the terms of the MIT License.
4    */
5    package org.easymock.internal;
6   
7    import java.io.Serializable;
8    import java.lang.reflect.Method;
9   
10    import org.easymock.IAnswer;
11   
 
12    public class ReplayState implements IMocksControlState, Serializable {
13   
14    private static final long serialVersionUID = 6314142602251047572L;
15   
16    private IMocksBehavior behavior;
17   
 
18  425 toggle public ReplayState(IMocksBehavior behavior) {
19  425 this.behavior = behavior;
20    }
21   
 
22  629 toggle public Object invoke(Invocation invocation) throws Throwable {
23   
24  629 if (behavior.isThreadSafe()) {
25    // If thread safe, synchronize the mock
26  10 synchronized (this) {
27  10 return invokeInner(invocation);
28    }
29    }
30   
31    // Check that the same thread is called all the time...
32  619 behavior.checkCurrentThreadSameAsLastThread();
33  610 return invokeInner(invocation);
34    }
35   
 
36  620 toggle private Object invokeInner(Invocation invocation) throws Throwable {
37  620 Result result = behavior.addActual(invocation);
38  570 LastControl.pushCurrentArguments(invocation.getArguments());
39  570 try {
40  570 try {
41  570 return result.answer();
42    } catch (Throwable t) {
43  74 throw new ThrowableWrapper(t);
44    }
45    } finally {
46  570 LastControl.popCurrentArguments();
47    }
48    }
49   
 
50  185 toggle public void verify() {
51  185 behavior.verify();
52    }
53   
 
54  2 toggle public void replay() {
55  2 throwWrappedIllegalStateException();
56    }
57   
 
58  1 toggle public void callback(Runnable runnable) {
59  1 throwWrappedIllegalStateException();
60    }
61   
 
62  2 toggle public void checkOrder(boolean value) {
63  2 throwWrappedIllegalStateException();
64    }
65   
 
66  2 toggle public void makeThreadSafe(boolean threadSafe) {
67  2 throwWrappedIllegalStateException();
68    }
69   
 
70  2 toggle public void andReturn(Object value) {
71  2 throwWrappedIllegalStateException();
72    }
73   
 
74  2 toggle public void andThrow(Throwable throwable) {
75  2 throwWrappedIllegalStateException();
76    }
77   
 
78  1 toggle public void andAnswer(IAnswer<?> answer) {
79  1 throwWrappedIllegalStateException();
80    }
81   
 
82  2 toggle public void andStubReturn(Object value) {
83  2 throwWrappedIllegalStateException();
84    }
85   
 
86  2 toggle public void andStubThrow(Throwable throwable) {
87  2 throwWrappedIllegalStateException();
88    }
89   
 
90  1 toggle public void andStubAnswer(IAnswer<?> answer) {
91  1 throwWrappedIllegalStateException();
92    }
93   
 
94  2 toggle public void asStub() {
95  2 throwWrappedIllegalStateException();
96    }
97   
 
98  3 toggle public void times(Range range) {
99  3 throwWrappedIllegalStateException();
100    }
101   
 
102  2 toggle @SuppressWarnings("deprecation")
103    public void setMatcher(Method method, org.easymock.ArgumentsMatcher matcher) {
104  2 throwWrappedIllegalStateException();
105    }
106   
 
107  3 toggle @SuppressWarnings("deprecation")
108    public void setDefaultMatcher(org.easymock.ArgumentsMatcher matcher) {
109  3 throwWrappedIllegalStateException();
110    }
111   
 
112  7 toggle public void setDefaultReturnValue(Object value) {
113  7 throwWrappedIllegalStateException();
114    }
115   
 
116  3 toggle public void setDefaultThrowable(Throwable throwable) {
117  3 throwWrappedIllegalStateException();
118    }
119   
 
120  2 toggle public void setDefaultVoidCallable() {
121  2 throwWrappedIllegalStateException();
122    }
123   
 
124  41 toggle private void throwWrappedIllegalStateException() {
125  41 throw new RuntimeExceptionWrapper(new IllegalStateException(
126    "This method must not be called in replay state."));
127    }
128   
 
129  2 toggle public void assertRecordState() {
130  2 throwWrappedIllegalStateException();
131    }
132    }