mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-22 21:05:23 +00:00
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:
parent
f1029aaad5
commit
1d8c507684
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user