|
@@ -64,6 +64,12 @@ public class TestRPCUtil {
|
|
|
verifyRemoteExceptionUnwrapping(exception, exception.getName());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testRemoteRuntimeExceptionUnwrapping() {
|
|
|
+ Class<? extends Throwable> exception = NullPointerException.class;
|
|
|
+ verifyRemoteExceptionUnwrapping(exception, exception.getName());
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testUnexpectedRemoteExceptionUnwrapping() {
|
|
|
// Non IOException, YarnException thrown by the remote side.
|
|
@@ -110,6 +116,23 @@ public class TestRPCUtil {
|
|
|
Assert.assertTrue(t.getMessage().contains(message));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testRPCRuntimeExceptionUnwrapping() {
|
|
|
+ String message = "RPCRuntimeExceptionUnwrapping";
|
|
|
+ RuntimeException re = new NullPointerException(message);
|
|
|
+ ServiceException se = new ServiceException(re);
|
|
|
+
|
|
|
+ Throwable t = null;
|
|
|
+ try {
|
|
|
+ RPCUtil.unwrapAndThrowException(se);
|
|
|
+ } catch (Throwable thrown) {
|
|
|
+ t = thrown;
|
|
|
+ }
|
|
|
+
|
|
|
+ Assert.assertTrue(NullPointerException.class.isInstance(t));
|
|
|
+ Assert.assertTrue(t.getMessage().contains(message));
|
|
|
+ }
|
|
|
+
|
|
|
private void verifyRemoteExceptionUnwrapping(
|
|
|
Class<? extends Throwable> expectedLocalException,
|
|
|
String realExceptionClassName) {
|