This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git


The following commit(s) were added to refs/heads/master by this push:
     new 17cce56e Force TLS 1.2 for all tests
17cce56e is described below

commit 17cce56e0caed2a6c72b8f7518c66a5f5dd19fee
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Nov 26 15:03:42 2022 -0500

    Force TLS 1.2 for all tests
    
    - This should get GitHub tests to pass on macOS and Linux with the
    latest Java 1.8.0+352
    - Rename test class
    - Refactor magic string
---
 .github/workflows/maven.yml                        |  2 +-
 .../ftps/AbstractFtpsProviderTestCase.java         | 41 +++++++++++++++++-----
 ...onTest.java => FtpsMultipleConnectionTest.java} |  2 +-
 3 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index a9823906..ebab203a 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -58,4 +58,4 @@ jobs:
         distribution: 'temurin'
         java-version: ${{ matrix.java }}
     - name: Build with Maven
-      run: mvn -V --file pom.xml --no-transfer-progress -DtrimStackTrace=false
+      run: mvn -V --file pom.xml --no-transfer-progress -DtrimStackTrace=false 
-Djdk.tls.client.protocols='TLSv1.2'
diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/AbstractFtpsProviderTestCase.java
 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/AbstractFtpsProviderTestCase.java
index 83f08935..ecf76859 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/AbstractFtpsProviderTestCase.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/AbstractFtpsProviderTestCase.java
@@ -45,7 +45,10 @@ import org.junit.jupiter.api.Assertions;
  */
 abstract class AbstractFtpsProviderTestCase extends AbstractProviderTestConfig 
{
 
+    private static final String LISTENER_NAME = "default";
+
     static final class FtpProviderTestSuite extends ProviderTestSuite {
+        
         private final boolean implicit;
 
         public FtpProviderTestSuite(final AbstractFtpsProviderTestCase 
providerConfig) throws Exception {
@@ -127,8 +130,8 @@ abstract class AbstractFtpsProviderTestCase extends 
AbstractProviderTestConfig {
         // The user prop file requires the "homedirectory" to be set
         user.setHomeDirectory(getTestDirectory());
         serverFactory.setUserManager(userManager);
-        final ListenerFactory factory = new ListenerFactory();
-        factory.setPort(SocketPort);
+        final ListenerFactory listenerFactory = new ListenerFactory();
+        listenerFactory.setPort(SocketPort);
 
         // define SSL configuration
         final URL serverJksResource = 
ClassLoader.getSystemClassLoader().getResource(SERVER_JKS_RES);
@@ -143,32 +146,52 @@ abstract class AbstractFtpsProviderTestCase extends 
AbstractProviderTestConfig {
         // set the SSL configuration for the listener
         final SslConfiguration sslConfiguration = 
sllConfigFactory.createSslConfiguration();
         final NoProtocolSslConfigurationProxy noProtocolSslConfigurationProxy 
= new NoProtocolSslConfigurationProxy(sslConfiguration);
-        factory.setSslConfiguration(noProtocolSslConfigurationProxy);
-        factory.setImplicitSsl(implicit);
+        listenerFactory.setSslConfiguration(noProtocolSslConfigurationProxy);
+        listenerFactory.setImplicitSsl(implicit);
 
         // replace the default listener
-        serverFactory.addListener("default", factory.createListener());
+        serverFactory.addListener(LISTENER_NAME, 
listenerFactory.createListener());
 
         // start the server
         EmbeddedFtpServer = serverFactory.createServer();
         EmbeddedFtpServer.start();
-        SocketPort = ((org.apache.ftpserver.impl.DefaultFtpServer) 
EmbeddedFtpServer).getListener("default").getPort();
+        Thread.yield();
+        if (EmbeddedFtpServer.isStopped() || EmbeddedFtpServer.isSuspended()) {
+            try {
+                Thread.sleep(200);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+        SocketPort = ((org.apache.ftpserver.impl.DefaultFtpServer) 
EmbeddedFtpServer).getListener(LISTENER_NAME).getPort();
+        // System.out.println("Using port " + SocketPort);
         ConnectionUri = "ftps://test:test@localhost:" + SocketPort;
     }
 
     /**
      * Stops the embedded Apache FTP EmbeddedFtpServer (MINA).
      */
-    static void tearDownClass() {
+    synchronized static void tearDownClass() {
         if (EmbeddedFtpServer != null) {
+            EmbeddedFtpServer.suspend();
             EmbeddedFtpServer.stop();
+            Thread.yield();
+            int count = 10;
+            while (count-- > 0 && !EmbeddedFtpServer.isStopped()) {
+                final int millis = 200;
+                System.out.println(String.format("Waiting %,d milliseconds for 
%s to stop", millis, EmbeddedFtpServer));
+                try {
+                    Thread.sleep(millis);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
             EmbeddedFtpServer = null;
         }
     }
 
     /**
-     * Returns the base folder for tests. You can override the DEFAULT_URI by 
using the system property name defined by
-     * TEST_URI.
+     * Returns the base folder for tests. You can override the DEFAULT_URI by 
using the system property name defined by TEST_URI.
      */
     @Override
     public FileObject getBaseTestFolder(final FileSystemManager manager) 
throws Exception {
diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/MultipleConnectionTest.java
 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/FtpsMultipleConnectionTest.java
similarity index 98%
rename from 
commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/MultipleConnectionTest.java
rename to 
commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/FtpsMultipleConnectionTest.java
index 9fc0ef02..45fd3434 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/MultipleConnectionTest.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/FtpsMultipleConnectionTest.java
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
-public class MultipleConnectionTest {
+public class FtpsMultipleConnectionTest {
 
     @BeforeAll
     public static void setUpClass() throws FtpException {

Reply via email to