1
2
3
4
5
6 package mockit.internal.reflection;
7
8 import static org.junit.jupiter.api.Assertions.assertThrows;
9
10 import java.io.IOException;
11
12 import org.junit.jupiter.api.Test;
13
14 final class ThrowOfCheckedExceptionTest {
15
16 @Test
17 void doThrowThrowsCheckedException() {
18
19 assertThrows(IOException.class, () -> {
20 try {
21 ThrowOfCheckedException.doThrow(new IOException("test checked exception"));
22 } catch (Exception e) {
23 if (e instanceof IOException) {
24 throw (IOException) e;
25 }
26 throw e;
27 }
28 });
29 }
30
31 @Test
32 void doThrowWithRuntimeExceptionSubclass() {
33
34 assertThrows(Exception.class, () -> ThrowOfCheckedException.doThrow(new Exception("generic")));
35 }
36 }