Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
13   75   7   3,25
0   45   0,54   2
4     1,75  
2    
 
  RecordStateInvalidDefaultThrowableTest       Line # 30 13 0% 7 3 82,4% 0.8235294
  RecordStateInvalidDefaultThrowableTest.CheckedException       Line # 34 0 - 0 0 - -1.0
 
  (6)
 
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.tests;
18   
19    import static org.easymock.EasyMock.*;
20    import static org.junit.Assert.*;
21   
22    import java.io.IOException;
23   
24    import org.junit.Before;
25    import org.junit.Test;
26   
27    /**
28    * @author OFFIS, Tammo Freese
29    */
 
30    public class RecordStateInvalidDefaultThrowableTest {
31   
32    private IMethods mock;
33   
 
34    private class CheckedException extends Exception {
35    private static final long serialVersionUID = 1L;
36    }
37   
 
38  6 toggle @Before
39    public void setup() {
40  6 mock = createMock(IMethods.class);
41    }
42   
 
43  2 toggle @Test
44    public void throwNull() {
45  2 try {
46  2 expect(mock.throwsNothing(false)).andStubThrow(null);
47  0 fail("NullPointerException expected");
48    } catch (final NullPointerException expected) {
49  2 assertEquals("null cannot be thrown", expected.getMessage());
50    }
51   
52    }
53   
 
54  2 toggle @Test
55    public void throwCheckedExceptionWhereNoCheckedExceptionIsThrown() {
56  2 try {
57  2 expect(mock.throwsNothing(false)).andStubThrow(new CheckedException());
58  0 fail("IllegalArgumentException expected");
59    } catch (final IllegalArgumentException expected) {
60  2 assertEquals("last method called on mock cannot throw " + this.getClass().getName()
61    + "$CheckedException", expected.getMessage());
62    }
63    }
64   
 
65  2 toggle @Test
66    public void throwWrongCheckedException() throws IOException {
67  2 try {
68  2 expect(mock.throwsIOException(0)).andStubThrow(new CheckedException());
69  0 fail("IllegalArgumentException expected");
70    } catch (final IllegalArgumentException expected) {
71  2 assertEquals("last method called on mock cannot throw " + this.getClass().getName()
72    + "$CheckedException", expected.getMessage());
73    }
74    }
75    }