Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
../../../img/srcFileCovDistChart10.png 0% of files have more coverage
38   157   27   1,58
4   104   0,71   24
24     1,12  
1    
 
  ReplayState       Line # 27 38 0% 27 0 100% 1.0
 
  (656)
 
1    /**
2    * Copyright 2001-2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16   
17    package org.easymock.internal;
18   
19    import java.io.Serializable;
20    import java.util.concurrent.locks.ReentrantLock;
21   
22    import org.easymock.IAnswer;
23   
24    /**
25    * @author OFFIS, Tammo Freese
26    */
 
27    public class ReplayState implements IMocksControlState, Serializable {
28   
29    private static final long serialVersionUID = 6314142602251047572L;
30   
31    private final IMocksBehavior behavior;
32   
33    private final ReentrantLock lock = new ReentrantLock();
34   
 
35  836 toggle public ReplayState(final IMocksBehavior behavior) {
36  836 this.behavior = behavior;
37    }
38   
 
39  1772 toggle public Object invoke(final Invocation invocation) throws Throwable {
40   
41  1772 behavior.checkThreadSafety();
42   
43  1754 if (behavior.isThreadSafe()) {
44    // If thread safe, synchronize the mock
45  1752 lock.lock();
46  1752 try {
47  1752 return invokeInner(invocation);
48    } finally {
49  1752 lock.unlock();
50    }
51    }
52   
53  2 return invokeInner(invocation);
54    }
55   
 
56  1754 toggle private Object invokeInner(final Invocation invocation) throws Throwable {
57  1754 LastControl.pushCurrentInvocation(invocation);
58  1754 try {
59  1754 final Result result = behavior.addActual(invocation);
60  1560 try {
61  1560 return result.answer();
62    } catch (final Throwable t) {
63  166 if (result.shouldFillInStackTrace()) {
64  156 throw new ThrowableWrapper(t);
65    }
66  10 throw t;
67    }
68    } finally {
69  1754 LastControl.popCurrentInvocation();
70    }
71    }
72   
 
73  576 toggle public void verify() {
74  576 behavior.verify();
75    }
76   
 
77  4 toggle public void replay() {
78  4 throwWrappedIllegalStateException();
79    }
80   
 
81  2 toggle public void callback(final Runnable runnable) {
82  2 throwWrappedIllegalStateException();
83    }
84   
 
85  4 toggle public void checkOrder(final boolean value) {
86  4 throwWrappedIllegalStateException();
87    }
88   
 
89  4 toggle public void makeThreadSafe(final boolean threadSafe) {
90  4 throwWrappedIllegalStateException();
91    }
92   
 
93  2 toggle public void checkIsUsedInOneThread(final boolean shouldBeUsedInOneThread) {
94  2 throwWrappedIllegalStateException();
95    }
96   
 
97  4 toggle public void andReturn(final Object value) {
98  4 throwWrappedIllegalStateException();
99    }
100   
 
101  4 toggle public void andThrow(final Throwable throwable) {
102  4 throwWrappedIllegalStateException();
103    }
104   
 
105  2 toggle public void andAnswer(final IAnswer<?> answer) {
106  2 throwWrappedIllegalStateException();
107    }
108   
 
109  2 toggle public void andDelegateTo(final Object answer) {
110  2 throwWrappedIllegalStateException();
111    }
112   
 
113  4 toggle public void andStubReturn(final Object value) {
114  4 throwWrappedIllegalStateException();
115    }
116   
 
117  4 toggle public void andStubThrow(final Throwable throwable) {
118  4 throwWrappedIllegalStateException();
119    }
120   
 
121  2 toggle public void andStubAnswer(final IAnswer<?> answer) {
122  2 throwWrappedIllegalStateException();
123    }
124   
 
125  2 toggle public void andStubDelegateTo(final Object delegateTo) {
126  2 throwWrappedIllegalStateException();
127    }
128   
 
129  4 toggle public void asStub() {
130  4 throwWrappedIllegalStateException();
131    }
132   
 
133  6 toggle public void times(final Range range) {
134  6 throwWrappedIllegalStateException();
135    }
136   
 
137  4 toggle public void setDefaultReturnValue(final Object value) {
138  4 throwWrappedIllegalStateException();
139    }
140   
 
141  4 toggle public void setDefaultThrowable(final Throwable throwable) {
142  4 throwWrappedIllegalStateException();
143    }
144   
 
145  4 toggle public void setDefaultVoidCallable() {
146  4 throwWrappedIllegalStateException();
147    }
148   
 
149  66 toggle private void throwWrappedIllegalStateException() {
150  66 throw new RuntimeExceptionWrapper(new IllegalStateException(
151    "This method must not be called in replay state."));
152    }
153   
 
154  4 toggle public void assertRecordState() {
155  4 throwWrappedIllegalStateException();
156    }
157    }