Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
21   81   9   4,2
0   64   0,43   2,5
5     1,8  
2    
 
 
  RecordStateInvalidDefaultThrowableTest       Line # 16 21 9 84,6% 0.84615386
  RecordStateInvalidDefaultThrowableTest.CheckedException       Line # 21 0 0 - -1.0
 
  (4)
 
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.tests;
6   
7    import static org.junit.Assert.*;
8   
9    import java.io.IOException;
10   
11    import org.easymock.MockControl;
12    import org.junit.Before;
13    import org.junit.Test;
14   
15    @SuppressWarnings("deprecation")
 
16    public class RecordStateInvalidDefaultThrowableTest {
17    MockControl<IMethods> control;
18   
19    IMethods mock;
20   
 
21    private class CheckedException extends Exception {
22    private static final long serialVersionUID = 1L;
23    }
24   
 
25  4 toggle @Before
26    public void setup() {
27  4 control = MockControl.createControl(IMethods.class);
28  4 mock = control.getMock();
29    }
30   
 
31  1 toggle @Test
32    public void throwNull() {
33  1 mock.throwsNothing(false);
34  1 try {
35  1 control.setDefaultThrowable(null);
36  0 fail("NullPointerException expected");
37    } catch (NullPointerException expected) {
38  1 assertEquals("null cannot be thrown", expected.getMessage());
39    }
40   
41    }
42   
 
43  1 toggle @Test
44    public void throwCheckedExceptionWhereNoCheckedExceptionIsThrown() {
45  1 mock.throwsNothing(false);
46  1 try {
47  1 control.setDefaultThrowable(new CheckedException());
48  0 fail("IllegalArgumentException expected");
49    } catch (IllegalArgumentException expected) {
50  1 assertEquals("last method called on mock cannot throw "
51    + this.getClass().getName() + "$CheckedException", expected
52    .getMessage());
53    }
54    }
55   
 
56  1 toggle @Test
57    public void throwWrongCheckedException() throws IOException {
58  1 mock.throwsIOException(0);
59  1 try {
60  1 control.setDefaultThrowable(new CheckedException());
61  0 fail("IllegalArgumentException expected");
62    } catch (IllegalArgumentException expected) {
63  1 assertEquals("last method called on mock cannot throw "
64    + this.getClass().getName() + "$CheckedException", expected
65    .getMessage());
66    }
67    }
68   
 
69  1 toggle @Test
70    public void setDefaultThrowableWithoutMethodCall() throws IOException {
71  1 try {
72  1 control.setDefaultThrowable(new RuntimeException());
73  0 fail("IllegalStateException expected");
74    } catch (IllegalStateException expected) {
75  1 assertEquals(
76    "method call on the mock needed before setting default Throwable",
77    expected.getMessage());
78    }
79    }
80   
81    }