@@ -71,9 +71,6 @@ public void testSSLAuth() throws NoSuchAlgorithmException, KeyManagementExceptio
7171 .withSSLContext (sslContext , x509trustMgr )
7272 .withSSLHostnameVerifier (SSLHostnameVerifier .ANY ));
7373
74- String expectedException = "com.marklogic.client.MarkLogicIOException: " +
75- "javax.net.ssl.SSLException: " ;
76-
7774 try {
7875 // make use of the client connection so we get an auth exception if it
7976 // is a non SSL connection and a successful write if it is an SSL connection
@@ -89,9 +86,22 @@ public void testSSLAuth() throws NoSuchAlgorithmException, KeyManagementExceptio
8986 docMgr .delete (docId );
9087 } catch (MarkLogicIOException e ) {
9188 String exception = e .toString ();
92- System .out .println (exception );
93- assertTrue (exception .startsWith (expectedException ));
94- assertTrue (exception .toLowerCase ().contains ("unrecognized ssl message" ));
89+ String message = exception .toLowerCase ();
90+
91+ boolean foundExpected = false ;
92+
93+ String [] expectedClasses = {"javax.net.ssl.SSLException" , "java.net.UnknownServiceException" };
94+ String [] expectedMessages = {"unrecognized ssl message" , "unable to find acceptable protocols" };
95+ for (int i =0 ; i < expectedClasses .length ; i ++) {
96+ String expectedException = "com.marklogic.client.MarkLogicIOException: " + expectedClasses [i ] +": " ;
97+ if (exception .startsWith (expectedException ) && message .contains (expectedMessages [i ])) {
98+ foundExpected = true ;
99+ break ;
100+ }
101+ }
102+ if (!foundExpected ) {
103+ fail ("unexpected exception for SSL over HTTPS or HTTP connection:\n " +exception );
104+ }
95105 }
96106 }
97107
0 commit comments