| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 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") |
|
|
|
| 100% |
Uncovered Elements: 0 (113) |
Complexity: 21 |
Complexity Density: 0,23 |
|
| 14 |
|
public class UsageExpectAndReturnTest { |
| 15 |
|
private MockControl<IMethods> control; |
| 16 |
|
|
| 17 |
|
private IMethods mock; |
| 18 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 19 |
20
|
@Before... |
| 20 |
|
public void setup() { |
| 21 |
20
|
control = MockControl.createControl(IMethods.class); |
| 22 |
20
|
mock = control.getMock(); |
| 23 |
|
} |
| 24 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 25 |
1
|
@Test... |
| 26 |
|
public void booleanType() { |
| 27 |
1
|
control.expectAndReturn(mock.booleanReturningMethod(4), true); |
| 28 |
1
|
control.replay(); |
| 29 |
1
|
assertEquals(true, mock.booleanReturningMethod(4)); |
| 30 |
1
|
control.verify(); |
| 31 |
|
} |
| 32 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 33 |
1
|
@Test... |
| 34 |
|
public void longType() { |
| 35 |
1
|
control.expectAndReturn(mock.longReturningMethod(4), 12l); |
| 36 |
1
|
control.replay(); |
| 37 |
1
|
assertEquals((long) 12, mock.longReturningMethod(4)); |
| 38 |
1
|
control.verify(); |
| 39 |
|
} |
| 40 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 41 |
1
|
@Test... |
| 42 |
|
public void floatType() { |
| 43 |
1
|
control.expectAndReturn(mock.floatReturningMethod(4), 12f); |
| 44 |
1
|
control.replay(); |
| 45 |
1
|
assertEquals(12f, mock.floatReturningMethod(4), 0f); |
| 46 |
1
|
control.verify(); |
| 47 |
|
} |
| 48 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 49 |
1
|
@Test... |
| 50 |
|
public void doubleType() { |
| 51 |
1
|
control.expectAndReturn(mock.doubleReturningMethod(4), 12.0); |
| 52 |
1
|
control.replay(); |
| 53 |
1
|
assertEquals(12.0, mock.doubleReturningMethod(4), 0.0); |
| 54 |
1
|
control.verify(); |
| 55 |
|
} |
| 56 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 57 |
1
|
@Test... |
| 58 |
|
public void object() { |
| 59 |
1
|
control.expectAndReturn(mock.objectReturningMethod(4), "12"); |
| 60 |
1
|
control.replay(); |
| 61 |
1
|
assertEquals("12", mock.objectReturningMethod(4)); |
| 62 |
1
|
control.verify(); |
| 63 |
|
} |
| 64 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 65 |
1
|
@Test... |
| 66 |
|
public void booleanAndRange() { |
| 67 |
1
|
control.expectAndReturn(mock.booleanReturningMethod(4), true, |
| 68 |
|
MockControl.ONE); |
| 69 |
1
|
control.replay(); |
| 70 |
1
|
assertEquals(true, mock.booleanReturningMethod(4)); |
| 71 |
1
|
control.verify(); |
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 74 |
1
|
@Test... |
| 75 |
|
public void longAndRange() { |
| 76 |
1
|
control.expectAndReturn(mock.longReturningMethod(4), 12l, |
| 77 |
|
MockControl.ONE); |
| 78 |
1
|
control.replay(); |
| 79 |
1
|
assertEquals((long) 12, mock.longReturningMethod(4)); |
| 80 |
1
|
control.verify(); |
| 81 |
|
} |
| 82 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 83 |
1
|
@Test... |
| 84 |
|
public void floatAndRange() { |
| 85 |
1
|
control.expectAndReturn(mock.floatReturningMethod(4), 12f, |
| 86 |
|
MockControl.ONE); |
| 87 |
1
|
control.replay(); |
| 88 |
1
|
assertEquals(12f, mock.floatReturningMethod(4), 0f); |
| 89 |
1
|
control.verify(); |
| 90 |
|
} |
| 91 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 92 |
1
|
@Test... |
| 93 |
|
public void doubleAndRange() { |
| 94 |
1
|
control.expectAndReturn(mock.doubleReturningMethod(4), 12.0, |
| 95 |
|
MockControl.ONE); |
| 96 |
1
|
control.replay(); |
| 97 |
1
|
assertEquals(12.0, mock.doubleReturningMethod(4), 0.0); |
| 98 |
1
|
control.verify(); |
| 99 |
|
} |
| 100 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
| 101 |
1
|
@Test... |
| 102 |
|
public void objectAndRange() { |
| 103 |
1
|
control.expectAndReturn(mock.objectReturningMethod(4), "12", |
| 104 |
|
MockControl.ONE); |
| 105 |
1
|
control.replay(); |
| 106 |
1
|
assertEquals("12", mock.objectReturningMethod(4)); |
| 107 |
1
|
control.verify(); |
| 108 |
|
} |
| 109 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 110 |
1
|
@Test... |
| 111 |
|
public void booleanAndCount() { |
| 112 |
1
|
control.expectAndReturn(mock.booleanReturningMethod(4), true, 2); |
| 113 |
1
|
control.replay(); |
| 114 |
1
|
assertEquals(true, mock.booleanReturningMethod(4)); |
| 115 |
1
|
assertEquals(true, mock.booleanReturningMethod(4)); |
| 116 |
1
|
control.verify(); |
| 117 |
|
} |
| 118 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 119 |
1
|
@Test... |
| 120 |
|
public void longAndCount() { |
| 121 |
1
|
control.expectAndReturn(mock.longReturningMethod(4), 12l, 2); |
| 122 |
1
|
control.replay(); |
| 123 |
1
|
assertEquals((long) 12, mock.longReturningMethod(4)); |
| 124 |
1
|
assertEquals((long) 12, mock.longReturningMethod(4)); |
| 125 |
1
|
control.verify(); |
| 126 |
|
} |
| 127 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 128 |
1
|
@Test... |
| 129 |
|
public void floatAndCount() { |
| 130 |
1
|
control.expectAndReturn(mock.floatReturningMethod(4), 12f, 2); |
| 131 |
1
|
control.replay(); |
| 132 |
1
|
assertEquals(12f, mock.floatReturningMethod(4), 0f); |
| 133 |
1
|
assertEquals(12f, mock.floatReturningMethod(4), 0f); |
| 134 |
1
|
control.verify(); |
| 135 |
|
} |
| 136 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 137 |
1
|
@Test... |
| 138 |
|
public void doubleAndCount() { |
| 139 |
1
|
control.expectAndReturn(mock.doubleReturningMethod(4), 12.0, 2); |
| 140 |
1
|
control.replay(); |
| 141 |
1
|
assertEquals(12.0, mock.doubleReturningMethod(4), 0.0); |
| 142 |
1
|
assertEquals(12.0, mock.doubleReturningMethod(4), 0.0); |
| 143 |
1
|
control.verify(); |
| 144 |
|
} |
| 145 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 146 |
1
|
@Test... |
| 147 |
|
public void objectAndCount() { |
| 148 |
1
|
control.expectAndReturn(mock.objectReturningMethod(4), "12", 2); |
| 149 |
1
|
control.replay(); |
| 150 |
1
|
assertEquals("12", mock.objectReturningMethod(4)); |
| 151 |
1
|
assertEquals("12", mock.objectReturningMethod(4)); |
| 152 |
1
|
control.verify(); |
| 153 |
|
} |
| 154 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 155 |
1
|
@Test... |
| 156 |
|
public void booleanAndMinMax() { |
| 157 |
1
|
control.expectAndReturn(mock.booleanReturningMethod(4), true, 2, 3); |
| 158 |
1
|
control.replay(); |
| 159 |
1
|
assertEquals(true, mock.booleanReturningMethod(4)); |
| 160 |
1
|
assertEquals(true, mock.booleanReturningMethod(4)); |
| 161 |
1
|
control.verify(); |
| 162 |
|
} |
| 163 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 164 |
1
|
@Test... |
| 165 |
|
public void longAndMinMax() { |
| 166 |
1
|
control.expectAndReturn(mock.longReturningMethod(4), 12l, 2, 3); |
| 167 |
1
|
control.replay(); |
| 168 |
1
|
assertEquals((long) 12, mock.longReturningMethod(4)); |
| 169 |
1
|
assertEquals((long) 12, mock.longReturningMethod(4)); |
| 170 |
1
|
control.verify(); |
| 171 |
|
} |
| 172 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 173 |
1
|
@Test... |
| 174 |
|
public void floatAndMinMax() { |
| 175 |
1
|
control.expectAndReturn(mock.floatReturningMethod(4), 12f, 2, 3); |
| 176 |
1
|
control.replay(); |
| 177 |
1
|
assertEquals(12f, mock.floatReturningMethod(4), 0f); |
| 178 |
1
|
assertEquals(12f, mock.floatReturningMethod(4), 0f); |
| 179 |
1
|
control.verify(); |
| 180 |
|
} |
| 181 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 182 |
1
|
@Test... |
| 183 |
|
public void doubleAndMinMax() { |
| 184 |
1
|
control.expectAndReturn(mock.doubleReturningMethod(4), 12.0, 2, 3); |
| 185 |
1
|
control.replay(); |
| 186 |
1
|
assertEquals(12.0, mock.doubleReturningMethod(4), 0.0); |
| 187 |
1
|
assertEquals(12.0, mock.doubleReturningMethod(4), 0.0); |
| 188 |
1
|
control.verify(); |
| 189 |
|
} |
| 190 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
| 191 |
1
|
@Test... |
| 192 |
|
public void objectAndMinMax() { |
| 193 |
1
|
control.expectAndReturn(mock.objectReturningMethod(4), "12", 2, 3); |
| 194 |
1
|
control.replay(); |
| 195 |
1
|
assertEquals("12", mock.objectReturningMethod(4)); |
| 196 |
1
|
assertEquals("12", mock.objectReturningMethod(4)); |
| 197 |
1
|
control.verify(); |
| 198 |
|
} |
| 199 |
|
} |