Skip to content

Commit e516e03

Browse files
committed
Add unit tests for UncheckedThrow
1 parent 56b772b commit e516e03

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.nordstrom.common.base;
2+
3+
import java.io.IOException;
4+
5+
import org.testng.annotations.Test;
6+
7+
public class UncheckedThrowTest {
8+
9+
@Test(expectedExceptions = {IOException.class})
10+
public void testCheckedException() {
11+
try {
12+
throwCheckedException();
13+
} catch (Throwable t) {
14+
throw UncheckedThrow.throwUnchecked(t);
15+
}
16+
}
17+
18+
@Test(expectedExceptions = {AssertionError.class})
19+
public void testUncheckedException() {
20+
try {
21+
throwUncheckedException();
22+
} catch (Throwable t) {
23+
throw UncheckedThrow.throwUnchecked(t);
24+
}
25+
}
26+
27+
private void throwCheckedException() throws IOException {
28+
throw new IOException("This is a checked exception");
29+
}
30+
31+
private void throwUncheckedException() {
32+
throw new AssertionError("This is an unchecked exception");
33+
}
34+
35+
}

0 commit comments

Comments
 (0)