(tomcat) branch main updated: Make test more robust

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

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


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

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

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

diff --git a/test/org/apache/tomcat/util/net/ocsp/TestOcspSoftFail.java b/test/org/apache/tomcat/util/net/ocsp/TestOcspSoftFail.java
index 26193ece41..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,15 +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. Not observed with NIO but
-            // for consistency / just in case.
-            // 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.