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 9e7892995d Expands tests
9e7892995d is described below

commit 9e7892995d97d6a9827ac82de0f563947e5b91c4
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Sep 24 22:25:20 2026 +0100

    Expands tests
---
 .../apache/catalina/startup/TomcatBaseTest.java    |  2 +-
 ...hannelTls.java => GroupChannelTlsTestBase.java} | 46 +++++++++----
 .../tribes/group/TestGroupChannelTlsFFM.java       | 59 +++++++++++++++++
 .../tribes/group/TestGroupChannelTlsNative.java    | 75 ++++++++++++++++++++++
 4 files changed, 169 insertions(+), 13 deletions(-)

diff --git a/test/org/apache/catalina/startup/TomcatBaseTest.java 
b/test/org/apache/catalina/startup/TomcatBaseTest.java
index 10631c5af6..cd885e5620 100644
--- a/test/org/apache/catalina/startup/TomcatBaseTest.java
+++ b/test/org/apache/catalina/startup/TomcatBaseTest.java
@@ -93,7 +93,7 @@ import org.apache.tomcat.util.scan.StandardJarScanner;
 public abstract class TomcatBaseTest extends LoggingBaseTest {
 
     // Used by parameterized tests. Defined here to reduce duplication.
-    protected static final Boolean[] booleans = new Boolean[] { Boolean.FALSE, 
Boolean.TRUE };
+    public static final Boolean[] booleans = new Boolean[] { Boolean.FALSE, 
Boolean.TRUE };
 
     protected static final int DEFAULT_CLIENT_TIMEOUT_MS = 300_000;
 
diff --git a/test/org/apache/catalina/tribes/group/TestGroupChannelTls.java 
b/test/org/apache/catalina/tribes/group/GroupChannelTlsTestBase.java
similarity index 69%
rename from test/org/apache/catalina/tribes/group/TestGroupChannelTls.java
rename to test/org/apache/catalina/tribes/group/GroupChannelTlsTestBase.java
index 8f2f35375e..3a96019fb1 100644
--- a/test/org/apache/catalina/tribes/group/TestGroupChannelTls.java
+++ b/test/org/apache/catalina/tribes/group/GroupChannelTlsTestBase.java
@@ -18,19 +18,44 @@ package org.apache.catalina.tribes.group;
 
 import java.io.Serializable;
 import java.net.ServerSocket;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import org.junit.Assert;
-import org.junit.Assume;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
 
+import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ChannelListener;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.transport.ReceiverBase;
 
-public class TestGroupChannelTls {
+@RunWith(Parameterized.class)
+public class GroupChannelTlsTestBase {
+
+    @Parameterized.Parameters(name = "{index}: {0} {1} {2}")
+    public static Collection<Object[]> parameters() {
+        List<Object[]> parameterSets = new ArrayList<>();
+        for (Boolean explicit : TomcatBaseTest.booleans) {
+            parameterSets.add(new Object[] { explicit, "TLSv1.2", "SHA256" });
+            parameterSets.add(new Object[] { explicit, "TLSv1.3", "SHA256" });
+            parameterSets.add(new Object[] { explicit, "TLSv1.3", "SHA384" });
+        }
+        return parameterSets;
+    }
+
+    @Parameter(0)
+    public boolean explicit;
+    @Parameter(1)
+    public String protocol;
+    @Parameter(2)
+    public String digest;
 
     @Test
     public void testPskDefaults() {
@@ -39,17 +64,11 @@ public class TestGroupChannelTls {
         Assert.assertEquals("TLSv1.3", channel.getPskProtocol());
     }
 
+
     @Test
     public void testSecureMessage() throws Exception {
-        try (@SuppressWarnings("unused") TribesSslContext ignored =
-                new TribesSslContext("tribes-test", 
"000102030405060708090a0b0c0d0e0f", "TLSv1.3", "SHA256")) {
-            // Verify that a supported TLS provider is available before 
creating the channels.
-        } catch (Exception e) {
-            Assume.assumeNoException(e);
-        }
-
-        GroupChannel sender = createChannel();
-        GroupChannel receiver = createChannel();
+        GroupChannel sender = createChannel(protocol, digest);
+        GroupChannel receiver = createChannel(protocol, digest);
         CountDownLatch received = new CountDownLatch(1);
         receiver.addChannelListener(new ChannelListener() {
             @Override
@@ -77,10 +96,13 @@ public class TestGroupChannelTls {
         }
     }
 
-    private static GroupChannel createChannel() throws Exception {
+
+    private static GroupChannel createChannel(String protocol, String digest) 
throws Exception {
         GroupChannel channel = new GroupChannel();
         channel.setPskIdentity("tribes-test");
         channel.setPskKey("000102030405060708090a0b0c0d0e0f");
+        channel.setPskProtocol(protocol);
+        channel.setPskDigest(digest);
         ReceiverBase receiver = (ReceiverBase) channel.getChannelReceiver();
         receiver.setHost("localhost");
         try (ServerSocket socket = new ServerSocket(0)) {
diff --git a/test/org/apache/catalina/tribes/group/TestGroupChannelTlsFFM.java 
b/test/org/apache/catalina/tribes/group/TestGroupChannelTlsFFM.java
new file mode 100644
index 0000000000..2ca4e0d73d
--- /dev/null
+++ b/test/org/apache/catalina/tribes/group/TestGroupChannelTlsFFM.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.tribes.group;
+
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.net.openssl.OpenSSLStatus;
+import org.apache.tomcat.util.net.openssl.panama.OpenSSLLibrary;
+
+@RunWith(Parameterized.class)
+public class TestGroupChannelTlsFFM extends GroupChannelTlsTestBase {
+
+    @Before
+    public void setup() {
+        if (explicit) {
+            // Models starting cluster when OpenSSLLifecycleListener has 
configured FFM support.
+            OpenSSLLibrary.init();
+            Assume.assumeTrue(OpenSSLStatus.isAvailable());
+        } else {
+            // Test FFM is available but leave it uninitialized so Tribes 
performs initialization
+            try {
+                OpenSSLLibrary.init();
+            } catch (Throwable t) {
+                ExceptionUtils.handleThrowable(t);
+                // Ignore
+            }
+            Assume.assumeTrue(OpenSSLStatus.isAvailable());
+            OpenSSLLibrary.destroy();
+        }
+    }
+
+
+    @After
+    public void teardown() {
+        if (explicit) {
+            // Models OpenSSLLifecycleListener. Stop FFM.
+            OpenSSLLibrary.destroy();
+        }
+    }
+}
diff --git 
a/test/org/apache/catalina/tribes/group/TestGroupChannelTlsNative.java 
b/test/org/apache/catalina/tribes/group/TestGroupChannelTlsNative.java
new file mode 100644
index 0000000000..3493dcd4f3
--- /dev/null
+++ b/test/org/apache/catalina/tribes/group/TestGroupChannelTlsNative.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.tribes.group;
+
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.core.AprLifecycleListener;
+import org.apache.catalina.core.StandardServer;
+import org.apache.tomcat.jni.AprStatus;
+import org.apache.tomcat.jni.Library;
+
+@RunWith(Parameterized.class)
+public class TestGroupChannelTlsNative extends GroupChannelTlsTestBase {
+
+    private static Lifecycle DUMMY_LIFECYCLE = new StandardServer();
+
+    private LifecycleListener listener;
+
+    @Before
+    public void setup() {
+        // Need to make sure FFM is not used.
+        System.setProperty("org.apache.tomcat.util.openssl.LIBRARY_NAME", 
"does-not-exist");
+
+        if (explicit) {
+            // Start Native Library
+            listener = new AprLifecycleListener();
+            listener.lifecycleEvent(new LifecycleEvent(DUMMY_LIFECYCLE, 
Lifecycle.BEFORE_INIT_EVENT, null));
+            Assume.assumeTrue(AprStatus.isAprAvailable());
+            if (Library.TCN_MAJOR_VERSION < 2 || Library.TCN_MAJOR_VERSION == 
2 && Library.TCN_PATCH_VERSION < 17) {
+                listener.lifecycleEvent(new LifecycleEvent(DUMMY_LIFECYCLE, 
Lifecycle.AFTER_DESTROY_EVENT, null));
+                Assume.assumeTrue("Tomvcat Native >= 2.0.17 required", false);
+            }
+        } else {
+            // Need to make sure FFM is not used.
+            System.setProperty("org.apache.tomcat.util.openssl.LIBRARY_NAME", 
"does-not-exist");
+            // Test Native Library
+            LifecycleListener listener = new AprLifecycleListener();
+            listener.lifecycleEvent(new LifecycleEvent(DUMMY_LIFECYCLE, 
Lifecycle.BEFORE_INIT_EVENT, null));
+            Assume.assumeTrue(AprStatus.isAprAvailable());
+            listener.lifecycleEvent(new LifecycleEvent(DUMMY_LIFECYCLE, 
Lifecycle.AFTER_DESTROY_EVENT, null));
+            Assume.assumeFalse("Tomvcat Native >= 2.0.17 required",
+                    Library.TCN_MAJOR_VERSION < 2 || Library.TCN_MAJOR_VERSION 
== 2 && Library.TCN_PATCH_VERSION < 17);
+        }
+    }
+
+
+    @After
+    public void teardown() {
+        if (explicit) {
+            // Models AprLifecycleListener. Stop Native Library.
+            listener.lifecycleEvent(new LifecycleEvent(DUMMY_LIFECYCLE, 
Lifecycle.AFTER_DESTROY_EVENT, null));
+        }
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to