This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 305699655e41 CAMEL-23499: Fix FTPS integration test port binding
failures
305699655e41 is described below
commit 305699655e41321434de2d8a568c2dc80c66da59
Author: Omar Atie <[email protected]>
AuthorDate: Wed Aug 5 02:18:49 2026 -0700
CAMEL-23499: Fix FTPS integration test port binding failures
Re-enable eight FileToFtps* IT tests disabled by PR #23327 and fix
the root cause: stale port overwrite in FtpsEmbeddedService, port not
reset on teardown, and static @RegisterExtension sharing server instances
across parallel test classes. Use instance-level extensions and
service.getPort() to avoid port collisions.
Closes #25335
Co-authored-by: Cursor Agent <[email protected]>
---
...ToFtpsExplicitSSLWithClientAuthAndSSLContextParametersIT.java | 2 --
...licitSSLWithoutClientAuthAndGlobalSSLContextParametersIT.java | 4 +---
.../integration/FileToFtpsExplicitSSLWithoutClientAuthIT.java | 4 +---
.../integration/FileToFtpsImplicitSSLWithClientAuthIT.java | 4 +---
...tpsImplicitSSLWithoutClientAuthAndSSLContextParametersIT.java | 4 +---
.../FileToFtpsWithCustomKeyAndTrustStorePropertiesIT.java | 4 +---
.../integration/FileToFtpsWithCustomTrustStorePropertiesIT.java | 4 +---
.../remote/integration/FileToFtpsWithFtpClientConfigRefIT.java | 5 ++---
.../FtpsServerExplicitSSLWithClientAuthTestSupport.java | 4 ++--
.../FtpsServerExplicitSSLWithoutClientAuthTestSupport.java | 4 ++--
.../FtpsServerExplicitTLSWithClientAuthTestSupport.java | 4 ++--
.../FtpsServerExplicitTLSWithoutClientAuthTestSupport.java | 2 +-
.../FtpsServerImplicitSSLWithClientAuthTestSupport.java | 4 ++--
.../FtpsServerImplicitSSLWithoutClientAuthTestSupport.java | 4 ++--
.../FtpsServerImplicitTLSWithClientAuthTestSupport.java | 4 ++--
.../FtpsServerImplicitTLSWithoutClientAuthTestSupport.java | 4 ++--
.../infra/ftp/services/embedded/FtpEmbeddedInfraService.java | 9 +++------
.../infra/ftp/services/embedded/FtpsEmbeddedInfraService.java | 8 ++------
.../test/infra/ftp/services/embedded/FtpsEmbeddedService.java | 5 ++++-
19 files changed, 32 insertions(+), 51 deletions(-)
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersIT.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersIT.java
index 499fff09d758..6cde39a379a4 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersIT.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersIT.java
@@ -21,11 +21,9 @@ import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.TestInstance;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-@Disabled("Test was flaky 4 years ago. It is now completely broken when
launched with Maven. See CAMEL-23499")
public class FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersIT
extends FileToFtpsExplicitSSLWithClientAuthIT {
@BindToRegistry("sslContextParameters")
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersIT.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersIT.java
index 61c4776e5ba6..415eff79ca9b 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersIT.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersIT.java
@@ -21,9 +21,7 @@ import org.apache.camel.SSLContextParametersAware;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
-import org.junit.jupiter.api.Disabled;
-@Disabled("Test was flaky 4 years ago. It is now completely broken when
launched with Maven. See CAMEL-23499")
public class
FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersIT
extends FileToFtpsExplicitSSLWithoutClientAuthIT {
@@ -48,7 +46,7 @@ public class
FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParameters
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:{{ftp.server.port}}"
+ return "ftps://admin@localhost:" + service.getPort()
+
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=false&delete=true";
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthIT.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthIT.java
index 9b50a06e540e..688ab1f71caa 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthIT.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthIT.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.file.remote.integration;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
@@ -26,11 +25,10 @@ import org.junit.jupiter.api.condition.EnabledIf;
* Test the ftps component over SSL (explicit) without client authentication
*/
@EnabledIf(value =
"org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
-@Disabled("Test was flaky 4 years ago. It is now completely broken when
launched with Maven. See CAMEL-23499")
public class FileToFtpsExplicitSSLWithoutClientAuthIT extends
FtpsServerExplicitSSLWithoutClientAuthTestSupport {
protected String getFtpUrl() {
- return "ftps://admin@localhost:{{ftp.server.port}}"
+ return "ftps://admin@localhost:" + service.getPort()
+
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true"
+ "&securityProtocol=TLSv1.2&implicit=false";
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithClientAuthIT.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithClientAuthIT.java
index 72a92002e9a0..95d354883201 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithClientAuthIT.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithClientAuthIT.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.file.remote.integration;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
@@ -26,11 +25,10 @@ import org.junit.jupiter.api.condition.EnabledIf;
* Test the ftps component over SSL (implicit) with client authentication
*/
@EnabledIf(value =
"org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
-@Disabled("Test was flaky 4 years ago. It is now completely broken when
launched with Maven. See CAMEL-23499")
public class FileToFtpsImplicitSSLWithClientAuthIT extends
FtpsServerImplicitSSLWithClientAuthTestSupport {
protected String getFtpUrl() {
- return "ftps://admin@localhost:{{ftp.server.port}}"
+ return "ftps://admin@localhost:" + service.getPort()
+
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+
"&securityProtocol=TLSv1.2&implicit=true&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
+
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true";
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersIT.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersIT.java
index 22c9ad8656e8..3e852de65867 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersIT.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersIT.java
@@ -20,9 +20,7 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
-import org.junit.jupiter.api.Disabled;
-@Disabled("Test was flaky 4 years ago. It is now completely broken when
launched with Maven. See CAMEL-23499")
public class FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersIT
extends FileToFtpsImplicitSSLWithoutClientAuthIT {
@BindToRegistry("sslContextParameters")
@@ -43,7 +41,7 @@ public class
FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersIT
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:{{ftp.server.port}}"
+ return "ftps://admin@localhost:" + service.getPort()
+
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+
"&implicit=true&sslContextParameters=#sslContextParameters&delete=true";
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithCustomKeyAndTrustStorePropertiesIT.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithCustomKeyAndTrustStorePropertiesIT.java
index cdd3741e90d5..45ad1c44356f 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithCustomKeyAndTrustStorePropertiesIT.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithCustomKeyAndTrustStorePropertiesIT.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.file.remote.integration;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
@@ -26,11 +25,10 @@ import org.junit.jupiter.api.condition.EnabledIf;
* Test the ftps component over SSL (explicit) and without client
authentication
*/
@EnabledIf(value =
"org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
-@Disabled("Test was flaky 4 years ago. It is now completely broken when
launched with Maven. See CAMEL-23499")
public class FileToFtpsWithCustomKeyAndTrustStorePropertiesIT extends
FtpsServerExplicitSSLWithClientAuthTestSupport {
private String getFtpUrl() {
- return "ftps://admin@localhost:{{ftp.server.port}}"
+ return "ftps://admin@localhost:" + service.getPort()
+
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+
"&securityProtocol=TLSv1.2&implicit=false&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
+
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password"
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithCustomTrustStorePropertiesIT.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithCustomTrustStorePropertiesIT.java
index 23c5ce8b5257..912eadc5589b 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithCustomTrustStorePropertiesIT.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithCustomTrustStorePropertiesIT.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.file.remote.integration;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
@@ -26,11 +25,10 @@ import org.junit.jupiter.api.condition.EnabledIf;
* Test the ftps component over SSL (explicit) and without client
authentication
*/
@EnabledIf(value =
"org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
-@Disabled("Test was flaky 4 years ago. It is now completely broken when
launched with Maven. See CAMEL-23499")
public class FileToFtpsWithCustomTrustStorePropertiesIT extends
FtpsServerExplicitSSLWithoutClientAuthTestSupport {
private String getFtpUrl() {
- return "ftps://admin@localhost:{{ftp.server.port}}"
+ return "ftps://admin@localhost:" + service.getPort()
+
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+
"&securityProtocol=TLSv1.2&implicit=false&ftpClient.trustStore.file=./src/test/resources/server.jks&ftpClient.trustStore.type=JKS"
+
"&ftpClient.trustStore.algorithm=SunX509&ftpClient.trustStore.password=password&delete=true";
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithFtpClientConfigRefIT.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithFtpClientConfigRefIT.java
index 0607e60459a1..9f098230cd8a 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithFtpClientConfigRefIT.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithFtpClientConfigRefIT.java
@@ -20,7 +20,6 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.commons.net.ftp.FTPSClient;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
@@ -28,7 +27,6 @@ import org.junit.jupiter.api.condition.EnabledIf;
* Test the ftps component over SSL (explicit) and without client
authentication
*/
@EnabledIf(value =
"org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
-@Disabled("Test was flaky 4 years ago. It is now completely broken when
launched with Maven. See CAMEL-23499")
public class FileToFtpsWithFtpClientConfigRefIT extends
FtpsServerExplicitSSLWithoutClientAuthTestSupport {
@BindToRegistry("ftpsClient")
@@ -38,7 +36,8 @@ public class FileToFtpsWithFtpClientConfigRefIT extends
FtpsServerExplicitSSLWit
private final FTPSClient client1 = new FTPSClient("TLSv1.2");
private String getFtpUrl(boolean in) {
- return
"ftps://admin@localhost:{{ftp.server.port}}/tmp2/camel?password=admin&initialDelay=2000&ftpClient=#ftpsClient"
+ return "ftps://admin@localhost:" + service.getPort()
+ +
"/tmp2/camel?password=admin&initialDelay=2000&ftpClient=#ftpsClient"
+ (in ? "In" : "")
+ "&disableSecureDataChannelDefaults=true&delete=true";
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitSSLWithClientAuthTestSupport.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitSSLWithClientAuthTestSupport.java
index b2604bc2829e..8ada3c4baf97 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitSSLWithClientAuthTestSupport.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitSSLWithClientAuthTestSupport.java
@@ -26,11 +26,11 @@ import org.junit.jupiter.api.extension.RegisterExtension;
public abstract class FtpsServerExplicitSSLWithClientAuthTestSupport extends
FtpsServerTestSupport {
@RegisterExtension
- static FtpsEmbeddedService service
+ FtpsEmbeddedService service
= new FtpsEmbeddedService(new
EmbeddedConfiguration.SecurityConfiguration(false, AUTH_VALUE_SSL, true));
@Deprecated
- public static int getPort() {
+ public int getPort() {
return service.getPort();
}
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitSSLWithoutClientAuthTestSupport.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitSSLWithoutClientAuthTestSupport.java
index 3bfb383ec1eb..054651aee2b1 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitSSLWithoutClientAuthTestSupport.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitSSLWithoutClientAuthTestSupport.java
@@ -27,11 +27,11 @@ import org.junit.jupiter.api.extension.RegisterExtension;
public abstract class FtpsServerExplicitSSLWithoutClientAuthTestSupport
extends FtpsServerTestSupport {
@RegisterExtension
- static FtpsEmbeddedService service = FtpServiceFactory
+ FtpsEmbeddedService service = FtpServiceFactory
.createSecureEmbeddedService(new
EmbeddedConfiguration.SecurityConfiguration(false, AUTH_VALUE_SSL, false));
@Deprecated
- public static int getPort() {
+ public int getPort() {
return service.getPort();
}
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitTLSWithClientAuthTestSupport.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitTLSWithClientAuthTestSupport.java
index cd11d647dff2..c5cbb2cbaf65 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitTLSWithClientAuthTestSupport.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitTLSWithClientAuthTestSupport.java
@@ -27,11 +27,11 @@ import org.junit.jupiter.api.extension.RegisterExtension;
public abstract class FtpsServerExplicitTLSWithClientAuthTestSupport extends
FtpsServerTestSupport {
@RegisterExtension
- static FtpsEmbeddedService service = FtpServiceFactory
+ FtpsEmbeddedService service = FtpServiceFactory
.createSecureEmbeddedService(new
EmbeddedConfiguration.SecurityConfiguration(false, AUTH_VALUE_TLS, true));
@Deprecated
- public static int getPort() {
+ public int getPort() {
return service.getPort();
}
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitTLSWithoutClientAuthTestSupport.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitTLSWithoutClientAuthTestSupport.java
index 40dca1b129fb..ab8de1354385 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitTLSWithoutClientAuthTestSupport.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerExplicitTLSWithoutClientAuthTestSupport.java
@@ -26,6 +26,6 @@ import org.junit.jupiter.api.extension.RegisterExtension;
*/
public abstract class FtpsServerExplicitTLSWithoutClientAuthTestSupport
extends FtpsServerTestSupport {
@RegisterExtension
- static FtpsEmbeddedService service = FtpServiceFactory
+ FtpsEmbeddedService service = FtpServiceFactory
.createSecureEmbeddedService(new
EmbeddedConfiguration.SecurityConfiguration(false, AUTH_VALUE_TLS, false));
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitSSLWithClientAuthTestSupport.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitSSLWithClientAuthTestSupport.java
index 3b5599c2a888..005194919c84 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitSSLWithClientAuthTestSupport.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitSSLWithClientAuthTestSupport.java
@@ -26,11 +26,11 @@ import org.junit.jupiter.api.extension.RegisterExtension;
*/
public abstract class FtpsServerImplicitSSLWithClientAuthTestSupport extends
FtpsServerTestSupport {
@RegisterExtension
- static FtpsEmbeddedService service = FtpServiceFactory
+ FtpsEmbeddedService service = FtpServiceFactory
.createSecureEmbeddedService(new
EmbeddedConfiguration.SecurityConfiguration(true, AUTH_VALUE_SSL, true));
@Deprecated
- public static int getPort() {
+ public int getPort() {
return service.getPort();
}
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitSSLWithoutClientAuthTestSupport.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitSSLWithoutClientAuthTestSupport.java
index 1e474130d29e..c269d5ebb4ca 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitSSLWithoutClientAuthTestSupport.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitSSLWithoutClientAuthTestSupport.java
@@ -26,11 +26,11 @@ import org.junit.jupiter.api.extension.RegisterExtension;
*/
public abstract class FtpsServerImplicitSSLWithoutClientAuthTestSupport
extends FtpsServerTestSupport {
@RegisterExtension
- static FtpsEmbeddedService service = FtpServiceFactory
+ FtpsEmbeddedService service = FtpServiceFactory
.createSecureEmbeddedService(new
EmbeddedConfiguration.SecurityConfiguration(true, AUTH_VALUE_SSL, false));
@Deprecated
- public static int getPort() {
+ public int getPort() {
return service.getPort();
}
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitTLSWithClientAuthTestSupport.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitTLSWithClientAuthTestSupport.java
index 9deb7607d02a..78603b3e1a88 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitTLSWithClientAuthTestSupport.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitTLSWithClientAuthTestSupport.java
@@ -26,11 +26,11 @@ import org.junit.jupiter.api.extension.RegisterExtension;
*/
public abstract class FtpsServerImplicitTLSWithClientAuthTestSupport extends
FtpsServerTestSupport {
@RegisterExtension
- static FtpsEmbeddedService service = FtpServiceFactory
+ FtpsEmbeddedService service = FtpServiceFactory
.createSecureEmbeddedService(new
EmbeddedConfiguration.SecurityConfiguration(true, AUTH_VALUE_TLS, true));
@Deprecated
- public static int getPort() {
+ public int getPort() {
return service.getPort();
}
}
diff --git
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitTLSWithoutClientAuthTestSupport.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitTLSWithoutClientAuthTestSupport.java
index c6c37ce33733..62db404aae81 100644
---
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitTLSWithoutClientAuthTestSupport.java
+++
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerImplicitTLSWithoutClientAuthTestSupport.java
@@ -27,11 +27,11 @@ import org.junit.jupiter.api.extension.RegisterExtension;
public abstract class FtpsServerImplicitTLSWithoutClientAuthTestSupport
extends FtpsServerTestSupport {
@RegisterExtension
- static FtpsEmbeddedService service = FtpServiceFactory
+ FtpsEmbeddedService service = FtpServiceFactory
.createSecureEmbeddedService(new
EmbeddedConfiguration.SecurityConfiguration(true, AUTH_VALUE_TLS, false));
@Deprecated
- public static int getPort() {
+ public int getPort() {
return service.getPort();
}
}
diff --git
a/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpEmbeddedInfraService.java
b/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpEmbeddedInfraService.java
index bb6938d98562..7add8bf678ba 100644
---
a/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpEmbeddedInfraService.java
+++
b/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpEmbeddedInfraService.java
@@ -135,12 +135,8 @@ public class FtpEmbeddedInfraService extends
AbstractService implements FtpInfra
serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
ListenerFactory factory = new ListenerFactory();
- // If port was already assigned (restart scenario), reuse it;
otherwise get a new one
- if (port > 0) {
- factory.setPort(port);
- } else {
-
factory.setPort(ContainerEnvironmentUtil.getConfiguredPortOrRandom(FtpProperties.DEFAULT_FTP_PORT));
- }
+ // tearDown() resets port to 0 so each test method gets a fresh port
(CAMEL-23499).
+
factory.setPort(ContainerEnvironmentUtil.getConfiguredPortOrRandom(FtpProperties.DEFAULT_FTP_PORT));
factory.setServerAddress(embeddedConfiguration.getServerAddress());
final Listener listener = factory.createListener();
@@ -164,6 +160,7 @@ public class FtpEmbeddedInfraService extends
AbstractService implements FtpInfra
LOG.trace("Exception while shutting down: {}", e.getMessage(), e);
} finally {
ftpServer = null;
+ port = 0;
}
}
diff --git
a/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedInfraService.java
b/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedInfraService.java
index 80334f4b6aec..093cb006f8f5 100644
---
a/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedInfraService.java
+++
b/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedInfraService.java
@@ -64,12 +64,8 @@ public class FtpsEmbeddedInfraService extends
FtpEmbeddedInfraService {
FtpServerFactory serverFactory =
super.createFtpServerFactory(embeddedConfiguration);
ListenerFactory listenerFactory = new
ListenerFactory(serverFactory.getListener(DEFAULT_LISTENER));
- // If port was already assigned (restart scenario), reuse it;
otherwise get a new one
- if (port > 0) {
- listenerFactory.setPort(port);
- } else {
-
listenerFactory.setPort(ContainerEnvironmentUtil.getConfiguredPortOrRandom(FtpProperties.DEFAULT_FTPS_PORT));
- }
+ // Always assign the FTPS default port; do not reuse the instance
field which may be stale (CAMEL-23499).
+
listenerFactory.setPort(ContainerEnvironmentUtil.getConfiguredPortOrRandom(FtpProperties.DEFAULT_FTPS_PORT));
listenerFactory.setImplicitSsl(embeddedConfiguration.getSecurityConfiguration().isUseImplicit());
listenerFactory.setSslConfiguration(createSslConfiguration(embeddedConfiguration).createSslConfiguration());
diff --git
a/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedService.java
b/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedService.java
index 95f7bb757dc9..4b88d2687746 100644
---
a/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedService.java
+++
b/test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedService.java
@@ -19,6 +19,8 @@ package org.apache.camel.test.infra.ftp.services.embedded;
import java.io.File;
+import org.apache.camel.test.infra.common.services.ContainerEnvironmentUtil;
+import org.apache.camel.test.infra.ftp.common.FtpProperties;
import org.apache.camel.test.infra.ftp.services.FtpService;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.listener.ListenerFactory;
@@ -44,7 +46,8 @@ public class FtpsEmbeddedService extends FtpEmbeddedService
implements FtpServic
FtpServerFactory serverFactory =
super.createFtpServerFactory(embeddedConfiguration);
ListenerFactory listenerFactory = new
ListenerFactory(serverFactory.getListener(DEFAULT_LISTENER));
- listenerFactory.setPort(port);
+ // Always assign the FTPS default port; do not reuse the instance
field which may be stale (CAMEL-23499).
+
listenerFactory.setPort(ContainerEnvironmentUtil.getConfiguredPortOrRandom(FtpProperties.DEFAULT_FTPS_PORT));
listenerFactory.setImplicitSsl(embeddedConfiguration.getSecurityConfiguration().isUseImplicit());
listenerFactory.setSslConfiguration(createSslConfiguration(embeddedConfiguration).createSslConfiguration());