Client: Add missing test

Previously I added wrapping for an SSL exception without a test. That
was lame. This adds the test.
This commit is contained in:
Nik Everett 2018-03-17 20:08:03 -04:00
parent f1029aaad5
commit 1d8c507684

View File

@ -35,6 +35,7 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.SocketTimeoutException;
import java.net.URISyntaxException;
import javax.net.ssl.SSLHandshakeException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -211,6 +212,23 @@ public class SyncResponseListenerTests extends RestClientTestCase {
}
}
public void testSSLHandshakeExceptionIsWrapped() throws Exception {
RestClient.SyncResponseListener syncResponseListener = new RestClient.SyncResponseListener(10000);
SSLHandshakeException exception = new SSLHandshakeException(randomAsciiAlphanumOfLength(5));
syncResponseListener.onFailure(exception);
try {
syncResponseListener.get();
fail("get should have failed");
} catch (SSLHandshakeException e) {
// We preserve the original exception in the cause
assertSame(exception, e.getCause());
// We copy the message
assertEquals(exception.getMessage(), e.getMessage());
// And we do all that so the thrown exception has our method in the stacktrace
assertExceptionStackContainsCallingMethod(e);
}
}
public void testIOExceptionIsBuiltCorrectly() throws Exception {
RestClient.SyncResponseListener syncResponseListener = new RestClient.SyncResponseListener(10000);
IOException ioException = new IOException();