/** * Verify that a {@link Throwable} is a {@link TTransportException} wrapping the expected cause * * @param throwable The {@link Throwable} to check * @param expectedCause The expected cause of the {@link TTransportException} */ private void checkTransportException( Throwable throwable, Class<? extends Throwable> expectedCause) { assertNotNull(throwable); Throwable cause = throwable.getCause(); if (!(throwable instanceof TTransportException)) { fail("Exception of type " + throwable.getClass() + " when expecting a TTransportException"); } else if (!(expectedCause.isAssignableFrom(throwable.getCause().getClass()))) { fail( "TTransportException caused by " + cause.getClass() + " when expecting a TTransportException caused by " + expectedCause); } }
protected void assertInvokeInterfaceThrows( java.lang.Class<? extends Throwable> errorClass, Class target, Extends iface, AbstractMethod method, String... args) { try { assertInvokeInterfaceEquals(0, target, iface, method, args); fail("Expected exception: " + errorClass); } catch (AssertionError e) { Throwable cause = e.getCause(); if (cause == null) throw e; else if ((errorClass.isAssignableFrom(cause.getClass()))) { // this is success return; } else throw e; } }