Skip to content

Commit 5087306

Browse files
committed
Add custom exception test.
1 parent 8d76964 commit 5087306

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

httprpc-test/src/test/java/org/httprpc/WebServiceProxyTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import static org.junit.jupiter.api.Assertions.assertEquals;
4343
import static org.junit.jupiter.api.Assertions.assertNotNull;
4444
import static org.junit.jupiter.api.Assertions.assertNull;
45+
import static org.junit.jupiter.api.Assertions.assertThrows;
4546
import static org.junit.jupiter.api.Assertions.assertTrue;
4647

4748
public class WebServiceProxyTest {
@@ -172,6 +173,9 @@ enum Size {
172173
}
173174
}
174175

176+
public static class CustomException extends IOException {
177+
}
178+
175179
private URL serverURL;
176180

177181
private DayOfWeek dayOfWeek = DayOfWeek.MONDAY;
@@ -466,8 +470,14 @@ public void testError() throws IOException {
466470
}
467471

468472
@Test
469-
public void testCustomErrorHandler() throws IOException {
470-
// TODO
473+
public void testCustomException() throws IOException {
474+
WebServiceProxy webServiceProxy = new WebServiceProxy("GET", new URL(serverURL, "test/error"));
475+
476+
webServiceProxy.setErrorHandler((errorStream, contentType, statusCode) -> {
477+
throw new CustomException();
478+
});
479+
480+
assertThrows(CustomException.class, webServiceProxy::invoke);
471481
}
472482

473483
@Test

0 commit comments

Comments
 (0)