| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 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.Test; |
| 13 |
|
|
| 14 |
|
@SuppressWarnings("deprecation") |
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 6 |
Complexity Density: 0,25 |
|
| 15 |
|
public class LegacyBehaviorTests { |
| 16 |
|
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 6 |
Complexity Density: 0,25 |
4
-
|
|
| 17 |
0
|
@Test... |
| 18 |
|
public void throwAfterThrowable() throws IOException { |
| 19 |
|
|
| 20 |
0
|
MockControl<IMethods> control = MockControl |
| 21 |
|
.createControl(IMethods.class); |
| 22 |
0
|
IMethods mock = control.getMock(); |
| 23 |
|
|
| 24 |
0
|
mock.throwsIOException(0); |
| 25 |
0
|
control.setThrowable(new IOException()); |
| 26 |
0
|
control.setThrowable(new IOException(), MockControl.ONE_OR_MORE); |
| 27 |
|
|
| 28 |
0
|
control.replay(); |
| 29 |
|
|
| 30 |
0
|
try { |
| 31 |
0
|
mock.throwsIOException(0); |
| 32 |
0
|
fail("IOException expected"); |
| 33 |
|
} catch (IOException expected) { |
| 34 |
|
} |
| 35 |
|
|
| 36 |
0
|
boolean exceptionOccured = true; |
| 37 |
0
|
try { |
| 38 |
0
|
control.verify(); |
| 39 |
0
|
exceptionOccured = false; |
| 40 |
|
} catch (AssertionError expected) { |
| 41 |
0
|
assertEquals( |
| 42 |
|
"\n Expectation failure on verify:" |
| 43 |
|
+ "\n throwsIOException(0): expected: at least 2, actual: 1", |
| 44 |
|
expected.getMessage()); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
0
|
if (!exceptionOccured) |
| 48 |
0
|
fail("exception expected"); |
| 49 |
|
|
| 50 |
0
|
try { |
| 51 |
0
|
mock.throwsIOException(0); |
| 52 |
0
|
fail("IOException expected"); |
| 53 |
|
} catch (IOException expected) { |
| 54 |
|
} |
| 55 |
|
|
| 56 |
0
|
control.verify(); |
| 57 |
|
|
| 58 |
0
|
try { |
| 59 |
0
|
mock.throwsIOException(0); |
| 60 |
0
|
fail("IOException expected"); |
| 61 |
|
} catch (IOException expected) { |
| 62 |
|
} |
| 63 |
|
|
| 64 |
0
|
control.verify(); |
| 65 |
|
} |
| 66 |
|
} |