(tomcat) branch 9.0.x updated: Make test more robust

[email protected]
Newsgroups gmane.comp.jakarta.tomcat.devel
Message-ID <178663343723.1506351.9241008363208262176@gitbox3-he-fi.apache.org>
This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new f4b9376f63 Make test more robust
f4b9376f63 is described below

commit f4b9376f630210420e2e9e7bd8ddc5dff3caf5ac
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Aug 13 16:01:40 2026 +0100

    Make test more robust
---
 .../tomcat/util/net/ocsp/TestOcspSoftFail.java     | 23 +++++++++++-----------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/test/org/apache/tomcat/util/net/ocsp/TestOcspSoftFail.java b/test/org/apache/tomcat/util/net/ocsp/TestOcspSoftFail.java
index 699a808ddd..2c3e6bc7e2 100644
--- a/test/org/apache/tomcat/util/net/ocsp/TestOcspSoftFail.java
+++ b/test/org/apache/tomcat/util/net/ocsp/TestOcspSoftFail.java
@@ -16,10 +16,7 @@
  */
 package org.apache.tomcat.util.net.ocsp;
 
-import java.net.SocketException;
-
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLHandshakeException;
+import java.io.IOException;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -44,14 +41,16 @@ public class TestOcspSoftFail extends OcspBaseTest {
     }
 
 
-    @Test(expected = SSLHandshakeException.class)
+    /*
+     * Generally expect to see SSLHandshakeException here. APR or NIO2 may throw a SocketException or IOException rather
+     * than a SSLHandshakeException. This hasn't been observed with NIO.
+     *
+     * Different Java versions may throw an SSLException rather than a SSLHandshakeException.
+     *
+     * All over these are sub-classes of IOException so check for that.
+     */
+    @Test(expected = IOException.class)
     public void testNoResponderWithoutSoftFail() throws Exception {
-        try {
-            doTest(false, false, ClientCertificateVerification.ENABLED, false, Boolean.FALSE);
-        } catch (SocketException | SSLException e) {
-            // APR or NIO2 may throw a SocketException rather than a SSLHandshakeException
-            // Different Java versions may throw an SSLException rather than a SSLHandshakeException
-            throw new SSLHandshakeException(e.getMessage());
-        }
+        doTest(false, false, ClientCertificateVerification.ENABLED, false, Boolean.FALSE);
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.