You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2015/08/26 23:39:05 UTC
svn commit: r1698009 -
/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
Author: ggregory
Date: Wed Aug 26 21:39:05 2015
New Revision: 1698009
URL: http://svn.apache.org/r1698009
Log:
Make this test different on Windows vs. other OSs.
Modified:
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java?rev=1698009&r1=1698008&r2=1698009&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java Wed Aug 26 21:39:05 2015
@@ -33,6 +33,7 @@ import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.SocketException;
import java.net.URL;
import java.security.KeyStore;
import java.security.Principal;
@@ -560,7 +561,7 @@ public class TestSSLContextBuilder {
}
}
- @Test(expected = SSLHandshakeException.class)
+ @Test
public void testSSLHanskshakeProtocolMismatch2() throws Exception {
final URL resource1 = getClass().getResource("/test-server.keystore");
final String storePassword = "nopassword";
@@ -597,11 +598,20 @@ public class TestSSLContextBuilder {
final int localPort = serverSocket.getLocalPort();
final SSLSocket clientSocket = (SSLSocket) clientSslContext.getSocketFactory().createSocket();
try {
- final Set<String> supportedClientProtocols = new LinkedHashSet<>(Arrays.asList(clientSocket.getSupportedProtocols()));
+ final Set<String> supportedClientProtocols = new LinkedHashSet<>(
+ Arrays.asList(clientSocket.getSupportedProtocols()));
Assert.assertTrue(supportedClientProtocols.contains("TLSv1"));
- clientSocket.setEnabledProtocols(new String[] {"TLSv1"});
+ clientSocket.setEnabledProtocols(new String[] { "TLSv1" });
clientSocket.connect(new InetSocketAddress("localhost", localPort), 5000);
- clientSocket.startHandshake();
+ final boolean isWindows = System.getProperty("os.name").contains("Windows");
+ final Class<? extends IOException> expectedExceptionClass = isWindows ? SocketException.class
+ : SSLHandshakeException.class;
+ try {
+ clientSocket.startHandshake();
+ Assert.fail();
+ } catch (Exception e) {
+ Assert.assertEquals(expectedExceptionClass, e.getClass());
+ }
} finally {
clientSocket.close();
}