Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
57   112   4   19
0   77   0,07   3
3     1,33  
1    
 
 
  UsageOverloadedDefaultValueTest       Line # 14 57 4 98,3% 0.98333335
 
  (2)
 
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 org.easymock.MockControl;
10    import org.junit.Before;
11    import org.junit.Test;
12   
13    @SuppressWarnings("deprecation")
 
14    public class UsageOverloadedDefaultValueTest {
15    MockControl<IMethods> control;
16   
17    IMethods mock;
18   
 
19  2 toggle @Before
20    public void setup() {
21  2 control = MockControl.createControl(IMethods.class);
22  2 mock = control.getMock();
23    }
24   
 
25  1 toggle @Test
26    public void overloading() {
27   
28  1 mock.oneArg(true);
29  1 control.setReturnValue("true");
30  1 control.setDefaultReturnValue("false");
31   
32  1 mock.oneArg((byte) 0);
33  1 control.setReturnValue("byte 0");
34  1 control.setDefaultReturnValue("byte 1");
35   
36  1 mock.oneArg((short) 0);
37  1 control.setReturnValue("short 0");
38  1 control.setDefaultReturnValue("short 1");
39   
40  1 mock.oneArg((char) 0);
41  1 control.setReturnValue("char 0");
42  1 control.setDefaultReturnValue("char 1");
43   
44  1 mock.oneArg(0);
45  1 control.setReturnValue("int 0");
46  1 control.setDefaultReturnValue("int 1");
47   
48  1 mock.oneArg((long) 0);
49  1 control.setReturnValue("long 0");
50  1 control.setDefaultReturnValue("long 1");
51   
52  1 mock.oneArg((float) 0);
53  1 control.setReturnValue("float 0");
54  1 control.setDefaultReturnValue("float 1");
55   
56  1 mock.oneArg(0.0);
57  1 control.setReturnValue("double 0");
58  1 control.setDefaultReturnValue("double 1");
59   
60  1 mock.oneArg("Object 0");
61  1 control.setReturnValue("String 0");
62  1 control.setDefaultReturnValue("String 1");
63   
64  1 control.replay();
65   
66  1 assertEquals("true", mock.oneArg(true));
67  1 assertEquals("false", mock.oneArg(false));
68   
69  1 assertEquals("byte 0", mock.oneArg((byte) 0));
70  1 assertEquals("byte 1", mock.oneArg((byte) 1));
71   
72  1 assertEquals("short 0", mock.oneArg((short) 0));
73  1 assertEquals("short 1", mock.oneArg((short) 1));
74   
75  1 assertEquals("char 0", mock.oneArg((char) 0));
76  1 assertEquals("char 1", mock.oneArg((char) 1));
77   
78  1 assertEquals("int 0", mock.oneArg(0));
79  1 assertEquals("int 1", mock.oneArg(1));
80   
81  1 assertEquals("long 0", mock.oneArg((long) 0));
82  1 assertEquals("long 1", mock.oneArg((long) 1));
83   
84  1 assertEquals("float 0", mock.oneArg((float) 0.0));
85  1 assertEquals("float 1", mock.oneArg((float) 1.0));
86   
87  1 assertEquals("double 0", mock.oneArg(0.0));
88  1 assertEquals("double 1", mock.oneArg(1.0));
89   
90  1 assertEquals("String 0", mock.oneArg("Object 0"));
91  1 assertEquals("String 1", mock.oneArg("Object 1"));
92   
93  1 control.verify();
94    }
95   
 
96  1 toggle @Test
97    public void defaultThrowable() {
98   
99  1 mock.oneArg("Object");
100  1 RuntimeException expected = new RuntimeException();
101  1 control.setDefaultThrowable(expected);
102   
103  1 control.replay();
104   
105  1 try {
106  1 mock.oneArg("Something else");
107  0 fail("runtime exception expected");
108    } catch (RuntimeException expectedException) {
109  1 assertSame(expected, expectedException);
110    }
111    }
112    }