Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
23   81   9   4,6
0   64   0,39   2,5
5     1,8  
2    
 
 
  RecordStateInvalidThrowableTest       Line # 16 23 9 85,7% 0.85714287
  RecordStateInvalidThrowableTest.CheckedException       Line # 22 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 RecordStateInvalidThrowableTest {
17   
18    MockControl<IMethods> control;
19   
20    IMethods mock;
21   
 
22    private class CheckedException extends Exception {
23    private static final long serialVersionUID = 1L;
24    }
25   
 
26  4 toggle @Before
27    public void setup() {
28  4 control = MockControl.createControl(IMethods.class);
29  4 mock = control.getMock();
30    }
31   
 
32  1 toggle @Test
33    public void throwNull() {
34  1 mock.throwsNothing(false);
35  1 try {
36  1 control.setThrowable(null);
37  0 fail("NullPointerException expected");
38    } catch (NullPointerException expected) {
39  1 assertEquals("null cannot be thrown", expected.getMessage());
40    }
41   
42    }
43   
 
44  1 toggle @Test
45    public void throwCheckedExceptionWhereNoCheckedExceptionIsThrown() {
46  1 mock.throwsNothing(false);
47  1 try {
48  1 control.setThrowable(new CheckedException());
49  0 fail("IllegalArgumentException expected");
50    } catch (IllegalArgumentException expected) {
51  1 assertEquals("last method called on mock cannot throw "
52    + CheckedException.class.getName(), expected.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.setThrowable(new CheckedException());
61  0 fail("IllegalArgumentException expected");
62    } catch (IllegalArgumentException expected) {
63  1 assertEquals("last method called on mock cannot throw "
64    + CheckedException.class.getName(), expected.getMessage());
65    }
66    }
67   
 
68  1 toggle @Test
69    public void throwAfterThrowable() throws IOException {
70  1 mock.throwsIOException(0);
71  1 control.setThrowable(new IOException(), MockControl.ONE_OR_MORE);
72  1 try {
73  1 control.setThrowable(new IOException());
74  0 fail("IllegalStateException expected");
75    } catch (IllegalStateException expected) {
76  1 assertEquals(
77    "last method called on mock already has a non-fixed count set.",
78    expected.getMessage());
79    }
80    }
81    }