Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
46   114   4   15,33
0   64   0,09   3
3     1,33  
1    
 
  UsageOverloadedDefaultValueTest       Line # 28 46 0% 4 1 98% 0.97959185
 
  (4)
 
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 org.junit.Before;
23    import org.junit.Test;
24   
25    /**
26    * @author OFFIS, Tammo Freese
27    */
 
28    public class UsageOverloadedDefaultValueTest {
29   
30    private IMethods mock;
31   
 
32  4 toggle @Before
33    public void setup() {
34  4 mock = createMock(IMethods.class);
35    }
36   
 
37  2 toggle @Test
38    public void overloading() {
39   
40  2 expect(mock.oneArg(true)).andReturn("true");
41  2 expect(mock.oneArg(anyBoolean())).andStubReturn("false");
42   
43  2 expect(mock.oneArg((byte) 0)).andReturn("byte 0");
44  2 expect(mock.oneArg(anyByte())).andStubReturn("byte 1");
45   
46  2 expect(mock.oneArg((short) 0)).andReturn("short 0");
47  2 expect(mock.oneArg(anyShort())).andStubReturn("short 1");
48   
49  2 expect(mock.oneArg((char) 0)).andReturn("char 0");
50  2 expect(mock.oneArg(anyChar())).andStubReturn("char 1");
51   
52  2 expect(mock.oneArg(0)).andReturn("int 0");
53  2 expect(mock.oneArg(anyInt())).andStubReturn("int 1");
54   
55  2 expect(mock.oneArg(0L)).andReturn("long 0");
56  2 expect(mock.oneArg(anyLong())).andStubReturn("long 1");
57   
58  2 expect(mock.oneArg(0.0f)).andReturn("float 0");
59  2 expect(mock.oneArg(anyFloat())).andStubReturn("float 1");
60   
61  2 expect(mock.oneArg(0.0)).andReturn("double 0");
62  2 expect(mock.oneArg(anyDouble())).andStubReturn("double 1");
63   
64  2 expect(mock.oneArg("Object 0")).andReturn("String 0");
65  2 expect(mock.oneArg((String) anyObject())).andStubReturn("String 1");
66   
67  2 replay(mock);
68   
69  2 assertEquals("true", mock.oneArg(true));
70  2 assertEquals("false", mock.oneArg(false));
71   
72  2 assertEquals("byte 0", mock.oneArg((byte) 0));
73  2 assertEquals("byte 1", mock.oneArg((byte) 1));
74   
75  2 assertEquals("short 0", mock.oneArg((short) 0));
76  2 assertEquals("short 1", mock.oneArg((short) 1));
77   
78  2 assertEquals("char 0", mock.oneArg((char) 0));
79  2 assertEquals("char 1", mock.oneArg((char) 1));
80   
81  2 assertEquals("int 0", mock.oneArg(0));
82  2 assertEquals("int 1", mock.oneArg(1));
83   
84  2 assertEquals("long 0", mock.oneArg((long) 0));
85  2 assertEquals("long 1", mock.oneArg((long) 1));
86   
87  2 assertEquals("float 0", mock.oneArg((float) 0.0));
88  2 assertEquals("float 1", mock.oneArg((float) 1.0));
89   
90  2 assertEquals("double 0", mock.oneArg(0.0));
91  2 assertEquals("double 1", mock.oneArg(1.0));
92   
93  2 assertEquals("String 0", mock.oneArg("Object 0"));
94  2 assertEquals("String 1", mock.oneArg("Object 1"));
95   
96  2 verify(mock);
97    }
98   
 
99  2 toggle @Test
100    public void defaultThrowable() {
101   
102  2 final RuntimeException expected = new RuntimeException();
103  2 expect(mock.oneArg((String) anyObject())).andStubThrow(expected);
104   
105  2 replay(mock);
106   
107  2 try {
108  2 mock.oneArg("Something else");
109  0 fail("runtime exception expected");
110    } catch (final RuntimeException expectedException) {
111  2 assertSame(expected, expectedException);
112    }
113    }
114    }