You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/08/24 18:16:20 UTC
[camel] branch main updated: Convert FTP tests to test infra
This is an automated email from the ASF dual-hosted git repository.
orpiske 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 aee763b034a Convert FTP tests to test infra
aee763b034a is described below
commit aee763b034a8c1c89e597e135f20b4ae945dc4f4
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Aug 22 17:10:56 2022 +0200
Convert FTP tests to test infra
---
components/camel-ftp/pom.xml | 26 +--
.../FileToFtpsExplicitSSLWithoutClientAuthIT.java | 2 +-
.../FileToFtpsExplicitTLSWithClientAuthIT.java | 2 +-
.../FileToFtpsExplicitTLSWithoutClientAuthIT.java | 2 +-
.../FileToFtpsImplicitSSLWithClientAuthIT.java | 2 +-
.../FileToFtpsImplicitSSLWithoutClientAuthIT.java | 2 +-
.../FileToFtpsImplicitTLSWithClientAuthIT.java | 2 +-
.../FileToFtpsImplicitTLSWithoutClientAuthIT.java | 2 +-
...FtpsWithCustomKeyAndTrustStorePropertiesIT.java | 2 +-
...FileToFtpsWithCustomTrustStorePropertiesIT.java | 2 +-
.../FileToFtpsWithDefaultSettingsIT.java | 2 +-
.../FileToFtpsWithFtpClientConfigRefIT.java | 2 +-
.../integration/FtpConsumerAutoCreateIT.java | 9 +-
.../FtpConsumerPostProcessingOnDisconnectIT.java | 7 +-
.../FtpPollEnrichBridgeErrorHandlerIT.java | 2 +-
.../remote/integration/FtpServerTestSupport.java | 12 +-
...ServerExplicitSSLWithClientAuthTestSupport.java | 2 +-
...verExplicitSSLWithoutClientAuthTestSupport.java | 2 +-
...ServerExplicitTLSWithClientAuthTestSupport.java | 2 +-
...verExplicitTLSWithoutClientAuthTestSupport.java | 2 +-
...ServerImplicitSSLWithClientAuthTestSupport.java | 2 +-
...verImplicitSSLWithoutClientAuthTestSupport.java | 2 +-
...ServerImplicitTLSWithClientAuthTestSupport.java | 2 +-
...verImplicitTLSWithoutClientAuthTestSupport.java | 2 +-
...PollEnrichConsumeWithDisconnectAndDeleteIT.java | 2 +-
.../FromSftpRecursiveNotStepwiseNoBasePathIT.java | 2 +-
.../sftp/integration/SftpChangedReadLockIT.java | 2 +-
.../sftp/integration/SftpChmodDirectoryIT.java | 2 +-
.../file/remote/sftp/integration/SftpChmodIT.java | 2 +-
.../sftp/integration/SftpConsumeTemplateIT.java | 2 +-
.../sftp/integration/SftpConsumerAutoCreateIT.java | 2 +-
.../integration/SftpConsumerProcessStrategyIT.java | 2 +-
.../integration/SftpConsumerWithCharsetIT.java | 2 +-
.../sftp/integration/SftpECKeyFileConsumeIT.java | 9 +-
.../integration/SftpEDDSAKeyFileConsumeIT.java | 9 +-
.../remote/sftp/integration/SftpKeyConsumeIT.java | 2 +-
.../sftp/integration/SftpKeyFileConsumeIT.java | 9 +-
.../sftp/integration/SftpKeyPairECConsumeIT.java | 7 +-
.../sftp/integration/SftpKeyPairRSAConsumeIT.java | 2 +-
.../SftpKeyUriConsumeFromClasspathIT.java | 2 +-
.../sftp/integration/SftpKeyUriConsumeIT.java | 2 +-
.../integration/SftpMoveWithOutMessageTest.java | 2 +-
.../sftp/integration/SftpProduceTempFileIT.java | 2 +-
.../integration/SftpProducerFileWithPathIT.java | 2 +-
.../SftpProducerFileWithPathNoStepwiseIT.java | 2 +-
.../integration/SftpProducerMoveExistingIT.java | 2 +-
.../integration/SftpProducerWithCharsetIT.java | 2 +-
.../sftp/integration/SftpServerTestSupport.java | 2 +-
.../remote/sftp/integration/SftpSetCipherIT.java | 2 +-
.../sftp/integration/SftpSetOperationsIT.java | 2 +-
.../sftp/integration/SftpSimpleConsumeIT.java | 2 +-
.../SftpSimpleConsumeNoStartingDirIT.java | 2 +-
.../SftpSimpleConsumeNotStepwiseIT.java | 2 +-
.../integration/SftpSimpleConsumeRecursiveIT.java | 2 +-
.../integration/SftpSimpleConsumeStreamingIT.java | 2 +-
.../SftpSimpleConsumeStreamingPartialReadIT.java | 2 +-
...pSimpleConsumeStreamingWithMultipleFilesIT.java | 2 +-
.../SftpSimpleConsumeThroughProxyIT.java | 2 +-
.../sftp/integration/SftpSimpleIPV6ConsumeIT.java | 2 +-
.../integration/SftpSimpleProduceDisconnectIT.java | 2 +-
.../sftp/integration/SftpSimpleProduceIT.java | 2 +-
.../SftpSimpleProduceNotStepwiseIT.java | 2 +-
.../SftpSimpleProduceThroughProxyIT.java | 2 +-
.../sftp/integration/SftpUseListFalseIT.java | 2 +-
test-infra/camel-test-infra-ftp/pom.xml | 25 ++-
.../services/embedded/EmbeddedConfiguration.java | 174 ++++++++++++++++++++
.../embedded/EmbeddedConfigurationBuilder.java | 178 +++++++++++++++++++++
.../ftp/services/embedded}/FtpEmbeddedService.java | 43 ++---
.../services/embedded}/FtpsEmbeddedService.java | 44 ++---
.../test/infra/ftp/services/embedded/FtpsUtil.java | 63 ++++++++
.../services/embedded}/SftpEmbeddedService.java | 46 +++---
.../test/infra/ftp/services/embedded/SftpUtil.java | 65 ++++++++
72 files changed, 638 insertions(+), 200 deletions(-)
diff --git a/components/camel-ftp/pom.xml b/components/camel-ftp/pom.xml
index 8fdbd4bf5ca..9455666c7ad 100644
--- a/components/camel-ftp/pom.xml
+++ b/components/camel-ftp/pom.xml
@@ -37,7 +37,7 @@
</camel.osgi.import.before.defaults>
<camel.surefire.forkCount>4</camel.surefire.forkCount>
- <camel.surefire.forkTimeout>1800</camel.surefire.forkTimeout>
+ <camel.surefire.forkTimeout>60</camel.surefire.forkTimeout>
<camel.surefire.parallel>false</camel.surefire.parallel>
<!-- This one can run in parallel rather safely-->
@@ -112,31 +112,7 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.ftpserver</groupId>
- <artifactId>ftpserver-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ftpserver</groupId>
- <artifactId>ftplet-api</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- for testing sftp -->
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-sftp</artifactId>
- <version>${sshd-version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-scp</artifactId>
- <version>${sshd-version}</version>
- <scope>test</scope>
- </dependency>
<!-- for testing sftp through http proxy -->
<dependency>
<groupId>org.littleshoot</groupId>
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 2b80012d96d..9f2b97502b7 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
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (explicit) without client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsExplicitSSLWithoutClientAuthIT extends FtpsServerExplicitSSLWithoutClientAuthTestSupport {
protected String getFtpUrl() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithClientAuthIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithClientAuthIT.java
index 404da5c174d..fc2f7486a15 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithClientAuthIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithClientAuthIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over TLS (explicit) with client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsExplicitTLSWithClientAuthIT extends FtpsServerExplicitTLSWithClientAuthTestSupport {
protected String getFtpUrl() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithoutClientAuthIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithoutClientAuthIT.java
index c6875233fa4..f31625fcd62 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithoutClientAuthIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithoutClientAuthIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over TLS (explicit) without client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsExplicitTLSWithoutClientAuthIT extends FtpsServerExplicitTLSWithoutClientAuthTestSupport {
protected String getFtpUrl() {
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 dea0db98cf9..91d8ece0aa8 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
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (implicit) with client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsImplicitSSLWithClientAuthIT extends FtpsServerImplicitSSLWithClientAuthTestSupport {
protected String getFtpUrl() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthIT.java
index 496ab66d00b..5ca7d420bc0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (implicit) without client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsImplicitSSLWithoutClientAuthIT extends FtpsServerImplicitSSLWithoutClientAuthTestSupport {
protected String getFtpUrl() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithClientAuthIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithClientAuthIT.java
index 34000e7cfce..05cbd5ad97c 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithClientAuthIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithClientAuthIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over TLS (implicit) with client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsImplicitTLSWithClientAuthIT extends FtpsServerImplicitTLSWithClientAuthTestSupport {
protected String getFtpUrl() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithoutClientAuthIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithoutClientAuthIT.java
index 56e972f4d33..0b4b6d8fc8d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithoutClientAuthIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithoutClientAuthIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over TLS (implicit) without client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsImplicitTLSWithoutClientAuthIT extends FtpsServerImplicitTLSWithoutClientAuthTestSupport {
protected String getFtpUrl() {
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 4d453346112..b08ffebcbae 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
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (explicit) and without client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsWithCustomKeyAndTrustStorePropertiesIT extends FtpsServerExplicitSSLWithClientAuthTestSupport {
private String getFtpUrl() {
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 c84c514e924..a294b2cae21 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
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (explicit) and without client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsWithCustomTrustStorePropertiesIT extends FtpsServerExplicitSSLWithoutClientAuthTestSupport {
private String getFtpUrl() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIT.java
index 58ccd5826ba..e74567c7603 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over TLS (explicit) and without client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsWithDefaultSettingsIT extends FtpsServerExplicitTLSWithoutClientAuthTestSupport {
private String getFtpUrl() {
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 b4d8d34f919..7b1c9cc75b4 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
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (explicit) and without client authentication
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.FtpsUtil#hasRequiredAlgorithms")
public class FileToFtpsWithFtpClientConfigRefIT extends FtpsServerExplicitSSLWithoutClientAuthTestSupport {
@BindToRegistry("ftpsClient")
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerAutoCreateIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerAutoCreateIT.java
index 0fbb37dea51..87eb5290e9e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerAutoCreateIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerAutoCreateIT.java
@@ -18,6 +18,8 @@ package org.apache.camel.component.file.remote.integration;
import org.apache.camel.component.file.GenericFileOperationFailedException;
import org.apache.camel.component.file.remote.FtpEndpoint;
+import org.apache.commons.io.FileUtils;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
@@ -26,13 +28,18 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
-@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@TestInstance(TestInstance.Lifecycle.PER_METHOD)
public class FtpConsumerAutoCreateIT extends FtpServerTestSupport {
protected String getFtpUrl() {
return "ftp://admin@localhost:{{ftp.server.port}}///foo/bar/baz/xxx?password=admin";
}
+ @BeforeEach
+ void forceRemove() {
+ FileUtils.deleteQuietly(service.getFtpRootDir().toFile());
+ }
+
@Test
public void testAutoCreate() {
FtpEndpoint<?> endpoint = (FtpEndpoint<?>) this.getMandatoryEndpoint(getFtpUrl() + "&autoCreate=true");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerPostProcessingOnDisconnectIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerPostProcessingOnDisconnectIT.java
index bdff9bb2bea..94d7612a9f2 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerPostProcessingOnDisconnectIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpConsumerPostProcessingOnDisconnectIT.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.file.remote.integration;
import java.io.IOException;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import org.apache.camel.Exchange;
@@ -102,7 +103,11 @@ public class FtpConsumerPostProcessingOnDisconnectIT extends FtpServerTestSuppor
}
private void createSampleFile(String fileName) throws IOException {
- Files.write(ftpFile(fileName), SAMPLE_FILE_PAYLOAD.getBytes(SAMPLE_FILE_CHARSET));
+ final Path path = ftpFile(fileName);
+
+ path.getParent().toFile().mkdirs();
+
+ Files.write(path, SAMPLE_FILE_PAYLOAD.getBytes(SAMPLE_FILE_CHARSET));
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpPollEnrichBridgeErrorHandlerIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpPollEnrichBridgeErrorHandlerIT.java
index c146f290718..dfde3005876 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpPollEnrichBridgeErrorHandlerIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpPollEnrichBridgeErrorHandlerIT.java
@@ -21,7 +21,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.remote.BaseServerTestSupport;
-import org.apache.camel.component.file.remote.services.FtpEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpEmbeddedService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpServerTestSupport.java
index ab30da1f3a8..be6ab4ee9f6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpServerTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpServerTestSupport.java
@@ -20,12 +20,10 @@ import java.nio.file.Path;
import org.apache.camel.Exchange;
import org.apache.camel.component.file.remote.BaseServerTestSupport;
-import org.apache.camel.component.file.remote.services.FtpEmbeddedService;
-import org.junit.jupiter.api.BeforeEach;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
import static org.apache.camel.language.simple.SimpleLanguage.simple;
-import static org.apache.camel.test.junit5.TestSupport.createCleanDirectory;
/**
* Base class for unit testing using a FTPServer
@@ -35,17 +33,11 @@ public abstract class FtpServerTestSupport extends BaseServerTestSupport {
@RegisterExtension
static FtpEmbeddedService service = new FtpEmbeddedService();
- @BeforeEach
- @Override
- public void setUp() throws Exception {
- super.setUp();
- createCleanDirectory(service.getFtpRootDir());
- }
-
public void sendFile(String url, Object body, String fileName) {
template.sendBodyAndHeader(url, body, Exchange.FILE_NAME, simple(fileName));
}
+ @Deprecated
protected Path ftpFile(String file) {
return service.getFtpRootDir().resolve(file);
}
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 f03cbe7a178..583c2797e42 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
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file.remote.integration;
-import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpsEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
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 ada85c3ce70..85cbfdce43f 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
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file.remote.integration;
-import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpsEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
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 806e9e958ef..42c7aa18198 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
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file.remote.integration;
-import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpsEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
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 ba3c83f0547..a248292a969 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
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file.remote.integration;
-import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpsEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
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 7ea9a494d0e..c638a423be8 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
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file.remote.integration;
-import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpsEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
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 b8e8b2de18f..34560fc44d0 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
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file.remote.integration;
-import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpsEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
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 24774003a7e..1512d5a4a37 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
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file.remote.integration;
-import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpsEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
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 083438322ab..ce2e1dbbf2b 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
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file.remote.integration;
-import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.FtpsEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/SftpPollEnrichConsumeWithDisconnectAndDeleteIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/SftpPollEnrichConsumeWithDisconnectAndDeleteIT.java
index 1b123313e71..d534d41b69a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/SftpPollEnrichConsumeWithDisconnectAndDeleteIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/SftpPollEnrichConsumeWithDisconnectAndDeleteIT.java
@@ -31,7 +31,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertFalse;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpPollEnrichConsumeWithDisconnectAndDeleteIT extends SftpServerTestSupport {
@Timeout(value = 30)
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/FromSftpRecursiveNotStepwiseNoBasePathIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/FromSftpRecursiveNotStepwiseNoBasePathIT.java
index 3e57c527064..2e235b39450 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/FromSftpRecursiveNotStepwiseNoBasePathIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/FromSftpRecursiveNotStepwiseNoBasePathIT.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.file.remote.sftp.integration;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.remote.BaseServerTestSupport;
-import org.apache.camel.component.file.remote.services.SftpEmbeddedService;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.ftp.services.embedded.SftpEmbeddedService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChangedReadLockIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChangedReadLockIT.java
index 5c7e0e5bf60..ca341721a1e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChangedReadLockIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChangedReadLockIT.java
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
import static org.apache.camel.test.junit5.TestSupport.createDirectory;
import static org.junit.jupiter.api.Assertions.assertEquals;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpChangedReadLockIT extends SftpServerTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(SftpChangedReadLockIT.class);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChmodDirectoryIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChmodDirectoryIT.java
index 8242db114c2..275929c7042 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChmodDirectoryIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChmodDirectoryIT.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.*;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpChmodDirectoryIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChmodIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChmodIT.java
index 9e057d104a1..9bbeb788618 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChmodIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpChmodIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpChmodIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumeTemplateIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumeTemplateIT.java
index 359c605619f..a95c226a2c9 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumeTemplateIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumeTemplateIT.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpConsumeTemplateIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerAutoCreateIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerAutoCreateIT.java
index 0a71c3c6915..da9d73333f0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerAutoCreateIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerAutoCreateIT.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpConsumerAutoCreateIT extends SftpServerTestSupport {
protected String getFtpUrl() {
return "sftp://admin@localhost:{{ftp.server.port}}/{{ftp.root.dir}}/foo/bar/baz/xxx?password=admin";
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerProcessStrategyIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerProcessStrategyIT.java
index acc8f6ce786..7a6e2136934 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerProcessStrategyIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerProcessStrategyIT.java
@@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpConsumerProcessStrategyIT extends SftpServerTestSupport {
@BindToRegistry("myStrategy")
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerWithCharsetIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerWithCharsetIT.java
index ab2d42b175d..2d8f2d0dd85 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerWithCharsetIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerWithCharsetIT.java
@@ -31,7 +31,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpConsumerWithCharsetIT extends SftpServerTestSupport {
private static final String SAMPLE_FILE_NAME
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpECKeyFileConsumeIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpECKeyFileConsumeIT.java
index f11dc56351e..2c542810865 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpECKeyFileConsumeIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpECKeyFileConsumeIT.java
@@ -16,16 +16,13 @@
*/
package org.apache.camel.component.file.remote.sftp.integration;
-import java.security.interfaces.ECPublicKey;
-
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms")
public class SftpECKeyFileConsumeIT extends SftpServerTestSupport {
@Test
@@ -45,10 +42,6 @@ public class SftpECKeyFileConsumeIT extends SftpServerTestSupport {
assertMockEndpointsSatisfied();
}
- protected PublickeyAuthenticator getPublickeyAuthenticator() {
- return (username, key, session) -> key instanceof ECPublicKey;
- }
-
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpEDDSAKeyFileConsumeIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpEDDSAKeyFileConsumeIT.java
index 06a9817d95b..a27e868748b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpEDDSAKeyFileConsumeIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpEDDSAKeyFileConsumeIT.java
@@ -16,16 +16,13 @@
*/
package org.apache.camel.component.file.remote.sftp.integration;
-import java.security.interfaces.ECPublicKey;
-
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpEDDSAKeyFileConsumeIT extends SftpServerTestSupport {
@Test
@@ -45,10 +42,6 @@ public class SftpEDDSAKeyFileConsumeIT extends SftpServerTestSupport {
assertMockEndpointsSatisfied();
}
- protected PublickeyAuthenticator getPublickeyAuthenticator() {
- return (username, key, session) -> key instanceof ECPublicKey;
- }
-
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyConsumeIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyConsumeIT.java
index 9bf94971394..c54273b80c6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyConsumeIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyConsumeIT.java
@@ -27,7 +27,7 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpKeyConsumeIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyFileConsumeIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyFileConsumeIT.java
index 0efd25eb9e8..f45730eaad0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyFileConsumeIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyFileConsumeIT.java
@@ -16,16 +16,13 @@
*/
package org.apache.camel.component.file.remote.sftp.integration;
-import java.security.interfaces.RSAPublicKey;
-
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpKeyFileConsumeIT extends SftpServerTestSupport {
@Test
@@ -45,10 +42,6 @@ public class SftpKeyFileConsumeIT extends SftpServerTestSupport {
assertMockEndpointsSatisfied();
}
- protected PublickeyAuthenticator getPublickeyAuthenticator() {
- return (username, key, session) -> key instanceof RSAPublicKey;
- }
-
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyPairECConsumeIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyPairECConsumeIT.java
index 4505d9ce43a..e483959fb77 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyPairECConsumeIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyPairECConsumeIT.java
@@ -23,13 +23,12 @@ import java.security.KeyPairGenerator;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpKeyPairECConsumeIT extends SftpServerTestSupport {
private static KeyPair keyPair;
@@ -106,10 +105,6 @@ public class SftpKeyPairECConsumeIT extends SftpServerTestSupport {
assertMockEndpointsSatisfied();
}
- protected PublickeyAuthenticator getPublickeyAuthenticator() {
- return (username, key, session) -> key.equals(keyPair.getPublic());
- }
-
@Override
protected RouteBuilder createRouteBuilder() {
// StringBuilder sb = new StringBuilder(256);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyPairRSAConsumeIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyPairRSAConsumeIT.java
index 5bc8eb64296..94092f95999 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyPairRSAConsumeIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyPairRSAConsumeIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpKeyPairRSAConsumeIT extends SftpServerTestSupport {
private static KeyPair keyPair;
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyUriConsumeFromClasspathIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyUriConsumeFromClasspathIT.java
index d2616efcf98..47cb3a92fb7 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyUriConsumeFromClasspathIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyUriConsumeFromClasspathIT.java
@@ -22,7 +22,7 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpKeyUriConsumeFromClasspathIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyUriConsumeIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyUriConsumeIT.java
index 6506fd03148..aacb0594b1e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyUriConsumeIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpKeyUriConsumeIT.java
@@ -22,7 +22,7 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpKeyUriConsumeIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpMoveWithOutMessageTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpMoveWithOutMessageTest.java
index 8bf85f10d6c..f92cda7ed94 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpMoveWithOutMessageTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpMoveWithOutMessageTest.java
@@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test that the existence of a outMessage in an exchange will not break the move-file post-processing
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpMoveWithOutMessageTest extends SftpServerTestSupport {
@Timeout(value = 30)
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProduceTempFileIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProduceTempFileIT.java
index cce9694d2fa..9b20eac7086 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProduceTempFileIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProduceTempFileIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpProduceTempFileIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerFileWithPathIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerFileWithPathIT.java
index 1f5d7c47afa..b2d6e07b03e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerFileWithPathIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerFileWithPathIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpProducerFileWithPathIT extends SftpServerTestSupport {
private String getFtpUrl() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerFileWithPathNoStepwiseIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerFileWithPathNoStepwiseIT.java
index b01d0947c7b..22bf3fb4251 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerFileWithPathNoStepwiseIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerFileWithPathNoStepwiseIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpProducerFileWithPathNoStepwiseIT extends SftpServerTestSupport {
private String getFtpUrl() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerMoveExistingIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerMoveExistingIT.java
index f14a5d76ced..f36adc1fbdb 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerMoveExistingIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerMoveExistingIT.java
@@ -33,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpProducerMoveExistingIT extends SftpServerTestSupport {
private String getFtpUrl() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerWithCharsetIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerWithCharsetIT.java
index ee949fe1c8f..509e2f49f95 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerWithCharsetIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpProducerWithCharsetIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpProducerWithCharsetIT extends SftpServerTestSupport {
private static final String SAMPLE_FILE_NAME
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpServerTestSupport.java
index 7dc1b6c6eca..b92778ffb19 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpServerTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpServerTestSupport.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.file.remote.sftp.integration;
import java.nio.file.Path;
import org.apache.camel.component.file.remote.BaseServerTestSupport;
-import org.apache.camel.component.file.remote.services.SftpEmbeddedService;
+import org.apache.camel.test.infra.ftp.services.embedded.SftpEmbeddedService;
import org.junit.jupiter.api.extension.RegisterExtension;
public class SftpServerTestSupport extends BaseServerTestSupport {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSetCipherIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSetCipherIT.java
index 44fa5cd1516..4431af43bf4 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSetCipherIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSetCipherIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSetCipherIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSetOperationsIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSetOperationsIT.java
index f4faa4fa297..e7b2d3d612e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSetOperationsIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSetOperationsIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSetOperationsIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeIT.java
index 2903052b15f..91887b834a0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeIT.java
@@ -22,7 +22,7 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleConsumeIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNoStartingDirIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNoStartingDirIT.java
index 1ba59d4b87c..d422072c28d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNoStartingDirIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNoStartingDirIT.java
@@ -25,7 +25,7 @@ import org.apache.camel.util.FileUtil;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleConsumeNoStartingDirIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNotStepwiseIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNotStepwiseIT.java
index ee317af5e3e..1de5adb1205 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNotStepwiseIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeNotStepwiseIT.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.file.remote.sftp.integration;
import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleConsumeNotStepwiseIT extends SftpSimpleConsumeIT {
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeRecursiveIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeRecursiveIT.java
index aa515b03ab8..9679903a61a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeRecursiveIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeRecursiveIT.java
@@ -22,7 +22,7 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleConsumeRecursiveIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingIT.java
index 7acbca115dc..c09a570fe7d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleConsumeStreamingIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingPartialReadIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingPartialReadIT.java
index edfb3688539..2e19b412874 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingPartialReadIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingPartialReadIT.java
@@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests that a file move can occur on the server even if the remote stream was only partially read.
*/
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleConsumeStreamingPartialReadIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingWithMultipleFilesIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingWithMultipleFilesIT.java
index eb5e2480bf6..cf093364e8a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingWithMultipleFilesIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeStreamingWithMultipleFilesIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleConsumeStreamingWithMultipleFilesIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeThroughProxyIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeThroughProxyIT.java
index 3a25c708bd3..734a865d5ae 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeThroughProxyIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleConsumeThroughProxyIT.java
@@ -32,7 +32,7 @@ import org.littleshoot.proxy.ProxyAuthenticator;
import org.littleshoot.proxy.impl.DefaultHttpProxyServer;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleConsumeThroughProxyIT extends SftpServerTestSupport {
private static HttpProxyServer proxyServer;
private final int proxyPort = AvailablePortFinder.getNextAvailable();
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleIPV6ConsumeIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleIPV6ConsumeIT.java
index bdc256fb2db..39047400912 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleIPV6ConsumeIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleIPV6ConsumeIT.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
@Disabled
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleIPV6ConsumeIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceDisconnectIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceDisconnectIT.java
index deac13f8b45..4b04493720e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceDisconnectIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceDisconnectIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleProduceDisconnectIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceIT.java
index a1e51dcf077..cc1aab09ae4 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleProduceIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceNotStepwiseIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceNotStepwiseIT.java
index 19864f146d9..e00943af73e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceNotStepwiseIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceNotStepwiseIT.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleProduceNotStepwiseIT extends SftpServerTestSupport {
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceThroughProxyIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceThroughProxyIT.java
index 3eaa7200c6b..398fe923804 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceThroughProxyIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpSimpleProduceThroughProxyIT.java
@@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpSimpleProduceThroughProxyIT extends SftpServerTestSupport {
private static HttpProxyServer proxyServer;
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpUseListFalseIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpUseListFalseIT.java
index 070c719e4a4..d08acc9b79c 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpUseListFalseIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpUseListFalseIT.java
@@ -22,7 +22,7 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
-@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
+@EnabledIf(value = "org.apache.camel.test.infra.ftp.services.embedded.SftpUtil#hasRequiredAlgorithms('src/test/resources/hostkey.pem')")
public class SftpUseListFalseIT extends SftpServerTestSupport {
@Test
diff --git a/test-infra/camel-test-infra-ftp/pom.xml b/test-infra/camel-test-infra-ftp/pom.xml
index 886534a23a4..227e3c9c292 100644
--- a/test-infra/camel-test-infra-ftp/pom.xml
+++ b/test-infra/camel-test-infra-ftp/pom.xml
@@ -33,6 +33,29 @@
<name>Camel :: Test Infra :: Ftp</name>
<dependencies>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <!-- for the embedded FTP server -->
+ <dependency>
+ <groupId>org.apache.ftpserver</groupId>
+ <artifactId>ftpserver-core</artifactId>
+ </dependency>
+
+ <!-- for the embedded SFTP server -->
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-sftp</artifactId>
+ <version>${sshd-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-scp</artifactId>
+ <version>${sshd-version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-infra-common</artifactId>
@@ -51,4 +74,4 @@
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/EmbeddedConfiguration.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/EmbeddedConfiguration.java
new file mode 100644
index 00000000000..b5a3ad6bcbb
--- /dev/null
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/EmbeddedConfiguration.java
@@ -0,0 +1,174 @@
+/*
+ * 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.camel.test.infra.ftp.services.embedded;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class EmbeddedConfiguration {
+ public static class User {
+ public static class UserInfo {
+ private final String home;
+ private final boolean writePermission;
+
+ public UserInfo(String home, boolean writePermission) {
+ this.home = home;
+ this.writePermission = writePermission;
+ }
+
+ public String getHome() {
+ return home;
+ }
+
+ public boolean isWritePermission() {
+ return writePermission;
+ }
+ }
+
+ private final String username;
+ private final String password;
+ private final UserInfo userInfo;
+
+ public User(String username, String password, UserInfo userInfo) {
+ this.username = username;
+ this.password = password;
+ this.userInfo = userInfo;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public UserInfo getUserInfo() {
+ return userInfo;
+ }
+ }
+
+ static final String DEFAULT_KNOWN_HOSTS = "[localhost]:%d ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDdfIWeSV4o68dRrKS"
+ + "zFd/Bk51E65UTmmSrmW0O1ohtzi6HzsDPjXgCtlTt3FqTcfFfI92IlTr4JWqC9UK1QT1ZTeng0MkPQmv68hDANHbt5CpETZHjW5q4OOgWhV"
+ + "vj5IyOC2NZHtKlJBkdsMAa15ouOOJLzBvAvbqOR/yUROsEiQ==";
+
+ private String testDirectory;
+ private List<User> users = new ArrayList<>();
+ private User admin;
+ private String serverAddress;
+ private String keyStore;
+ private String keyStorePassword;
+ private String keyStoreType;
+ private String keyStoreAlgorithm;
+ private String knownHosts;
+ private String knownHostsPath;
+ private String keyPairFile;
+
+ public String getTestDirectory() {
+ return testDirectory;
+ }
+
+ void setTestDirectory(String testDirectory) {
+ this.testDirectory = testDirectory;
+ }
+
+ void addUser(User user) {
+ users.add(user);
+ }
+
+ public List<User> getUsers() {
+ return Collections.unmodifiableList(users);
+ }
+
+ public User getAdmin() {
+ return admin;
+ }
+
+ void setAdmin(User admin) {
+ this.admin = admin;
+ }
+
+ void setAdmin(String username, String password, User.UserInfo userInfo) {
+ this.admin = new User(username, password, userInfo);
+ }
+
+ public String getServerAddress() {
+ return serverAddress;
+ }
+
+ void setServerAddress(String serverAddress) {
+ this.serverAddress = serverAddress;
+ }
+
+ public String getKeyStore() {
+ return keyStore;
+ }
+
+ void setKeyStore(String keyStore) {
+ this.keyStore = keyStore;
+ }
+
+ public String getKeyStorePassword() {
+ return keyStorePassword;
+ }
+
+ void setKeyStorePassword(String keyStorePassword) {
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ public String getKeyStoreType() {
+ return keyStoreType;
+ }
+
+ public void setKeyStoreType(String keyStoreType) {
+ this.keyStoreType = keyStoreType;
+ }
+
+ public String getKeyStoreAlgorithm() {
+ return keyStoreAlgorithm;
+ }
+
+ public void setKeyStoreAlgorithm(String keyStoreAlgorithm) {
+ this.keyStoreAlgorithm = keyStoreAlgorithm;
+ }
+
+ public String getKnownHosts() {
+ return knownHosts;
+ }
+
+ void setKnownHosts(String knownHosts) {
+ this.knownHosts = knownHosts;
+ }
+
+ public String getKnownHostsPath() {
+ return knownHostsPath;
+ }
+
+ void setKnownHostsPath(String knownHostsPath) {
+ this.knownHostsPath = knownHostsPath;
+ }
+
+ public String getKeyPairFile() {
+ return keyPairFile;
+ }
+
+ void setKeyPairFile(String keyPairFile) {
+ this.keyPairFile = keyPairFile;
+ }
+}
diff --git a/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/EmbeddedConfigurationBuilder.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/EmbeddedConfigurationBuilder.java
new file mode 100644
index 00000000000..6de21d38227
--- /dev/null
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/EmbeddedConfigurationBuilder.java
@@ -0,0 +1,178 @@
+/*
+ * 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.camel.test.infra.ftp.services.embedded;
+
+public final class EmbeddedConfigurationBuilder {
+ private final EmbeddedConfiguration embeddedConfiguration = new EmbeddedConfiguration();
+
+ private EmbeddedConfigurationBuilder() {
+
+ }
+
+ public EmbeddedConfigurationBuilder withTestDirectory(String testDirectory) {
+ embeddedConfiguration.setTestDirectory(testDirectory);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder addUser(EmbeddedConfiguration.User user) {
+ embeddedConfiguration.addUser(user);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder addUser(
+ String username, String password, EmbeddedConfiguration.User.UserInfo userInfo) {
+ embeddedConfiguration.addUser(new EmbeddedConfiguration.User(username, password, userInfo));
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withAdmin(EmbeddedConfiguration.User adminUser) {
+ embeddedConfiguration.setAdmin(adminUser);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withAdmin(
+ String username, String password, EmbeddedConfiguration.User.UserInfo userInfo) {
+ embeddedConfiguration.setAdmin(username, password, userInfo);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withServerAddress(String address) {
+ embeddedConfiguration.setServerAddress(address);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withKeyStore(String keyStore) {
+ embeddedConfiguration.setKeyStore(keyStore);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withKeyStorePassword(String keyStorePassword) {
+ embeddedConfiguration.setKeyStorePassword(keyStorePassword);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withKeyStoreType(String keyStoreType) {
+ embeddedConfiguration.setKeyStoreType(keyStoreType);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withKeyStoreAlgorithm(String keyStoreAlgorithm) {
+ embeddedConfiguration.setKeyStoreAlgorithm(keyStoreAlgorithm);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withKnownHosts(String knownHosts) {
+ embeddedConfiguration.setKnownHosts(knownHosts);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withKnownHostsPath(String knownHostsPath) {
+ embeddedConfiguration.setKnownHostsPath(knownHostsPath);
+
+ return this;
+ }
+
+ public EmbeddedConfigurationBuilder withKeyPairFile(String keyPairFile) {
+ embeddedConfiguration.setKeyPairFile(keyPairFile);
+
+ return this;
+ }
+
+ public EmbeddedConfiguration build() {
+ return embeddedConfiguration;
+ }
+
+ public static EmbeddedConfiguration defaultConfiguration() {
+ final EmbeddedConfiguration.User.UserInfo writableUser = new EmbeddedConfiguration.User.UserInfo(null, true);
+ final EmbeddedConfiguration.User.UserInfo nonWritableUser = new EmbeddedConfiguration.User.UserInfo(null, false);
+
+ EmbeddedConfigurationBuilder builder = new EmbeddedConfigurationBuilder()
+ .withTestDirectory("res/home")
+ .addUser("admin", "admin", writableUser)
+ .addUser("scott", "tiger", writableUser)
+ .addUser("dummy", "foo", nonWritableUser)
+ .addUser("us@r", "t%st", writableUser)
+ .addUser("anonymous", null, nonWritableUser)
+ .addUser("joe", "p+%w0&r)d", writableUser)
+ .addUser("jane", "%j#7%c6i", writableUser)
+ .withAdmin("admin", null, null)
+ .withServerAddress("localhost");
+
+ return builder.embeddedConfiguration;
+ }
+
+ public static EmbeddedConfiguration defaultFtpsConfiguration() {
+ final EmbeddedConfiguration.User.UserInfo writableUser = new EmbeddedConfiguration.User.UserInfo(null, true);
+ final EmbeddedConfiguration.User.UserInfo nonWritableUser = new EmbeddedConfiguration.User.UserInfo(null, false);
+
+ EmbeddedConfigurationBuilder builder = new EmbeddedConfigurationBuilder()
+ .withTestDirectory("res/home")
+ .addUser("admin", "admin", writableUser)
+ .addUser("scott", "tiger", writableUser)
+ .addUser("dummy", "foo", nonWritableUser)
+ .addUser("us@r", "t%st", writableUser)
+ .addUser("anonymous", null, nonWritableUser)
+ .addUser("joe", "p+%w0&r)d", writableUser)
+ .addUser("jane", "%j#7%c6i", writableUser)
+ .withAdmin("admin", null, null)
+ .withServerAddress("localhost")
+ .withKeyStore("./src/test/resources/server.jks")
+ .withKeyStorePassword("password")
+ .withKeyStoreType("JKS")
+ .withKeyStoreAlgorithm("SunX509");
+
+ return builder.embeddedConfiguration;
+ }
+
+ public static EmbeddedConfiguration defaultSftpConfiguration() {
+ final EmbeddedConfiguration.User.UserInfo writableUser = new EmbeddedConfiguration.User.UserInfo(null, true);
+ final EmbeddedConfiguration.User.UserInfo nonWritableUser = new EmbeddedConfiguration.User.UserInfo(null, false);
+
+ EmbeddedConfigurationBuilder builder = new EmbeddedConfigurationBuilder()
+ .withTestDirectory("res/home")
+ .addUser("admin", "admin", writableUser)
+ .addUser("scott", "tiger", writableUser)
+ .addUser("dummy", "foo", nonWritableUser)
+ .addUser("us@r", "t%st", writableUser)
+ .addUser("anonymous", null, nonWritableUser)
+ .addUser("joe", "p+%w0&r)d", writableUser)
+ .addUser("jane", "%j#7%c6i", writableUser)
+ .withAdmin("admin", null, null)
+ .withServerAddress("localhost")
+ .withKeyStore("./src/test/resources/server.jks")
+ .withKeyStorePassword("password")
+ .withKeyStoreType("JKS")
+ .withKeyStoreAlgorithm("SunX509")
+ .withKnownHosts(EmbeddedConfiguration.DEFAULT_KNOWN_HOSTS)
+ .withKnownHostsPath("user-home/.ssh/known_hosts")
+ .withKeyPairFile("src/test/resources/hostkey.pem");
+
+ return builder.embeddedConfiguration;
+ }
+}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpEmbeddedService.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/FtpEmbeddedService.java
similarity index 83%
rename from components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpEmbeddedService.java
rename to test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/FtpEmbeddedService.java
index a2234c315e5..37be2214916 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpEmbeddedService.java
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/FtpEmbeddedService.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.camel.component.file.remote.services;
+package org.apache.camel.test.infra.ftp.services.embedded;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -27,6 +27,7 @@ import java.util.function.BiConsumer;
import org.apache.camel.test.infra.common.services.AbstractTestService;
import org.apache.camel.test.infra.ftp.common.FtpProperties;
import org.apache.camel.test.infra.ftp.services.FtpService;
+import org.apache.commons.io.FileUtils;
import org.apache.ftpserver.ConnectionConfigFactory;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
@@ -44,8 +45,6 @@ import org.apache.ftpserver.usermanager.impl.WritePermission;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.camel.test.junit5.TestSupport.createCleanDirectory;
-
public class FtpEmbeddedService extends AbstractTestService implements FtpService {
protected static final String DEFAULT_LISTENER = "default";
@@ -56,13 +55,20 @@ public class FtpEmbeddedService extends AbstractTestService implements FtpServic
protected int port;
protected Path rootDir;
+ private final EmbeddedConfiguration embeddedConfiguration;
+ @Deprecated
public FtpEmbeddedService() {
+ embeddedConfiguration = EmbeddedConfigurationBuilder.defaultConfiguration();
+ }
+
+ protected FtpEmbeddedService(EmbeddedConfiguration embeddedConfiguration) {
+ this.embeddedConfiguration = embeddedConfiguration;
}
public void setUp() throws Exception {
- rootDir = testDirectory().resolve("res/home");
- createCleanDirectory(rootDir);
+ rootDir = testDirectory().resolve(embeddedConfiguration.getTestDirectory());
+ FileUtils.deleteDirectory(rootDir.toFile());
FtpServerFactory factory = createFtpServerFactory();
ftpServer = factory.createServer();
@@ -72,6 +78,7 @@ public class FtpEmbeddedService extends AbstractTestService implements FtpServic
.map(Listener::getPort).findAny().get();
}
+ @Deprecated
private Path testDirectory() {
return Paths.get("target", "ftp", context.getRequiredTestClass().getSimpleName());
}
@@ -96,17 +103,17 @@ public class FtpEmbeddedService extends AbstractTestService implements FtpServic
fsf.setCreateHome(true);
PropertiesUserManagerFactory pumf = new PropertiesUserManagerFactory();
- pumf.setAdminName("admin");
+ pumf.setAdminName(embeddedConfiguration.getAdmin().getUsername());
pumf.setPasswordEncryptor(new ClearTextPasswordEncryptor());
pumf.setFile(null);
+
UserManager userMgr = pumf.createUserManager();
- createUser(userMgr, "admin", "admin", rootDir, true);
- createUser(userMgr, "scott", "tiger", rootDir, true);
- createUser(userMgr, "dummy", "foo", rootDir, false);
- createUser(userMgr, "us@r", "t%st", rootDir, true);
- createUser(userMgr, "anonymous", null, rootDir, false);
- createUser(userMgr, "joe", "p+%w0&r)d", rootDir, true);
- createUser(userMgr, "jane", "%j#7%c6i", rootDir, true);
+ for (EmbeddedConfiguration.User user : embeddedConfiguration.getUsers()) {
+ final EmbeddedConfiguration.User.UserInfo userInfo = user.getUserInfo();
+ final Path homeDir = userInfo.getHome() == null ? rootDir : Path.of(userInfo.getHome());
+
+ createUser(userMgr, user.getUsername(), user.getPassword(), homeDir, userInfo.isWritePermission());
+ }
ListenerFactory factory = new ListenerFactory();
factory.setPort(port);
@@ -137,10 +144,6 @@ public class FtpEmbeddedService extends AbstractTestService implements FtpServic
} finally {
ftpServer = null;
}
-
- // if (port != null) {
- // port.release();
- // }
}
public void disconnectAllSessions() {
@@ -156,7 +159,7 @@ public class FtpEmbeddedService extends AbstractTestService implements FtpServic
@Override
protected void registerProperties(BiConsumer<String, String> store) {
- store.accept(FtpProperties.SERVER_HOST, "localhost");
+ store.accept(FtpProperties.SERVER_HOST, embeddedConfiguration.getServerAddress());
store.accept(FtpProperties.SERVER_PORT, String.valueOf(getPort()));
store.accept(FtpProperties.ROOT_DIR, rootDir.toString());
}
@@ -190,4 +193,8 @@ public class FtpEmbeddedService extends AbstractTestService implements FtpServic
return count;
}
+
+ public EmbeddedConfiguration getEmbeddedConfiguration() {
+ return embeddedConfiguration;
+ }
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpsEmbeddedService.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedService.java
similarity index 61%
rename from components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpsEmbeddedService.java
rename to test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedService.java
index e06449b8cd3..de2f99cc120 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpsEmbeddedService.java
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedService.java
@@ -15,13 +15,9 @@
* limitations under the License.
*/
-package org.apache.camel.component.file.remote.services;
+package org.apache.camel.test.infra.ftp.services.embedded;
import java.io.File;
-import java.security.NoSuchAlgorithmException;
-
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.TrustManagerFactory;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.listener.ListenerFactory;
@@ -31,15 +27,13 @@ import org.slf4j.LoggerFactory;
public class FtpsEmbeddedService extends FtpEmbeddedService {
private static final Logger LOG = LoggerFactory.getLogger(FtpsEmbeddedService.class);
- private static final File FTPSERVER_KEYSTORE = new File("./src/test/resources/server.jks");
- private static final String FTPSERVER_KEYSTORE_PASSWORD = "password";
private boolean useImplicit;
private String authValue;
private boolean clientAuth;
public FtpsEmbeddedService(boolean useImplicit, String authValue, boolean clientAuth) {
- super();
+ super(EmbeddedConfigurationBuilder.defaultFtpsConfiguration());
this.useImplicit = useImplicit;
this.authValue = authValue;
@@ -67,37 +61,21 @@ public class FtpsEmbeddedService extends FtpEmbeddedService {
SslConfigurationFactory sslConfigFactory = new SslConfigurationFactory();
sslConfigFactory.setSslProtocol(authValue);
- sslConfigFactory.setKeystoreFile(FTPSERVER_KEYSTORE);
- sslConfigFactory.setKeystoreType("JKS");
- sslConfigFactory.setKeystoreAlgorithm("SunX509");
- sslConfigFactory.setKeystorePassword(FTPSERVER_KEYSTORE_PASSWORD);
- sslConfigFactory.setKeyPassword(FTPSERVER_KEYSTORE_PASSWORD);
+ sslConfigFactory.setKeystoreFile(new File(getEmbeddedConfiguration().getKeyStore()));
+ sslConfigFactory.setKeystoreType(getEmbeddedConfiguration().getKeyStoreType());
+ sslConfigFactory.setKeystoreAlgorithm(getEmbeddedConfiguration().getKeyStoreAlgorithm());
+ sslConfigFactory.setKeystorePassword(getEmbeddedConfiguration().getKeyStorePassword());
+ sslConfigFactory.setKeyPassword(getEmbeddedConfiguration().getKeyStorePassword());
sslConfigFactory.setClientAuthentication(authValue);
if (clientAuth) {
- sslConfigFactory.setTruststoreFile(FTPSERVER_KEYSTORE);
- sslConfigFactory.setTruststoreType("JKS");
- sslConfigFactory.setTruststoreAlgorithm("SunX509");
- sslConfigFactory.setTruststorePassword(FTPSERVER_KEYSTORE_PASSWORD);
+ sslConfigFactory.setTruststoreFile(new File(getEmbeddedConfiguration().getKeyStore()));
+ sslConfigFactory.setTruststoreType(getEmbeddedConfiguration().getKeyStoreType());
+ sslConfigFactory.setTruststoreAlgorithm(getEmbeddedConfiguration().getKeyStoreAlgorithm());
+ sslConfigFactory.setTruststorePassword(getEmbeddedConfiguration().getKeyStorePassword());
}
return sslConfigFactory;
}
-
- public static boolean hasRequiredAlgorithms() {
- LOG.info("Checking if the system has the required algorithms for the test execution");
- try {
- KeyManagerFactory.getInstance("SunX509");
- TrustManagerFactory.getInstance("SunX509");
-
- return true;
- } catch (NoSuchAlgorithmException e) {
- String name = System.getProperty("os.name");
- String message = e.getMessage();
-
- LOG.warn("SunX509 is not available on this platform [{}] Testing is skipped! Real cause: {}", name, message, e);
- return false;
- }
- }
}
diff --git a/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsUtil.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsUtil.java
new file mode 100644
index 00000000000..e54ca149eb0
--- /dev/null
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsUtil.java
@@ -0,0 +1,63 @@
+/*
+ * 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.camel.test.infra.ftp.services.embedded;
+
+import java.security.NoSuchAlgorithmException;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class FtpsUtil {
+ private static final Logger LOG = LoggerFactory.getLogger(FtpsUtil.class);
+
+ private static boolean checked;
+ private static boolean hasRequiredAlgorithms;
+
+ private FtpsUtil() {
+
+ }
+
+ public static boolean hasRequiredAlgorithms() {
+ if (!checked) {
+ hasRequiredAlgorithms = doCheck();
+ }
+
+ return hasRequiredAlgorithms;
+ }
+
+ private static boolean doCheck() {
+ LOG.debug("Checking if the system has the required algorithms for the test execution");
+ try {
+ KeyManagerFactory.getInstance("SunX509");
+ TrustManagerFactory.getInstance("SunX509");
+
+ return true;
+ } catch (NoSuchAlgorithmException e) {
+ String name = System.getProperty("os.name");
+ String message = e.getMessage();
+
+ LOG.warn("SunX509 is not available on this platform [{}] Testing is skipped! Real cause: {}", name, message, e);
+ return false;
+ } finally {
+ checked = true;
+ }
+ }
+}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/SftpEmbeddedService.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/SftpEmbeddedService.java
similarity index 80%
rename from components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/SftpEmbeddedService.java
rename to test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/SftpEmbeddedService.java
index 5977548e427..08be46c4db5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/SftpEmbeddedService.java
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/SftpEmbeddedService.java
@@ -15,8 +15,9 @@
* limitations under the License.
*/
-package org.apache.camel.component.file.remote.services;
+package org.apache.camel.test.infra.ftp.services.embedded;
+import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.file.Files;
@@ -44,9 +45,6 @@ import org.slf4j.LoggerFactory;
public class SftpEmbeddedService extends AbstractTestService implements FtpService {
private static final Logger LOG = LoggerFactory.getLogger(SftpEmbeddedService.class);
- private static final String KNOWN_HOSTS = "[localhost]:%d ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDdfIWeSV4o68dRrKS"
- + "zFd/Bk51E65UTmmSrmW0O1ohtzi6HzsDPjXgCtlTt3FqTcfFfI92IlTr4JWqC9UK1QT1ZTeng0MkPQmv68hDANHbt5CpETZHjW5q4OOgWhV"
- + "vj5IyOC2NZHtKlJBkdsMAa15ouOOJLzBvAvbqOR/yUROsEiQ==";
protected SshServer sshd;
protected final boolean rootDirMode;
@@ -54,20 +52,28 @@ public class SftpEmbeddedService extends AbstractTestService implements FtpServi
private Path rootDir;
private Path knownHosts;
+ private final EmbeddedConfiguration embeddedConfiguration;
public SftpEmbeddedService() {
this(false);
}
public SftpEmbeddedService(boolean rootDirMode) {
+ this(rootDirMode, EmbeddedConfigurationBuilder.defaultSftpConfiguration());
+ }
+
+ protected SftpEmbeddedService(boolean rootDirMode, EmbeddedConfiguration embeddedConfiguration) {
this.rootDirMode = rootDirMode;
+ this.embeddedConfiguration = embeddedConfiguration;
}
public void setUp() throws Exception {
- rootDir = testDirectory().resolve("res/home");
- knownHosts = testDirectory().resolve("user-home/.ssh/known_hosts");
+ rootDir = testDirectory().resolve(embeddedConfiguration.getTestDirectory());
+ knownHosts = testDirectory().resolve(embeddedConfiguration.getKnownHostsPath());
+
Files.createDirectories(knownHosts.getParent());
Files.write(knownHosts, buildKnownHosts());
+
setUpServer();
}
@@ -78,14 +84,19 @@ public class SftpEmbeddedService extends AbstractTestService implements FtpServi
public void setUpServer() throws Exception {
sshd = SshServer.setUpDefaultServer();
sshd.setPort(port);
- sshd.setKeyPairProvider(new FileKeyPairProvider(Paths.get("src/test/resources/hostkey.pem")));
+
+ sshd.setKeyPairProvider(new FileKeyPairProvider(Paths.get(embeddedConfiguration.getKeyPairFile())));
sshd.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory()));
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setPasswordAuthenticator((username, password, session) -> true);
sshd.setPublickeyAuthenticator(getPublickeyAuthenticator());
if (rootDirMode) {
- sshd.setFileSystemFactory(new VirtualFileSystemFactory(testDirectory().resolve("res").toAbsolutePath()));
+ final File testDirectory = new File(embeddedConfiguration.getTestDirectory());
+
+ sshd.setFileSystemFactory(new VirtualFileSystemFactory(
+ testDirectory().resolve(testDirectory.getParentFile().getName())
+ .toAbsolutePath()));
}
List<NamedFactory<Signature>> signatureFactories = sshd.getSignatureFactories();
signatureFactories.clear();
@@ -135,7 +146,7 @@ public class SftpEmbeddedService extends AbstractTestService implements FtpServi
}
public byte[] buildKnownHosts() {
- return String.format(KNOWN_HOSTS, port).getBytes();
+ return String.format(embeddedConfiguration.getKnownHosts(), port).getBytes();
}
public String getKnownHostsFile() {
@@ -148,7 +159,7 @@ public class SftpEmbeddedService extends AbstractTestService implements FtpServi
@Override
protected void registerProperties(BiConsumer<String, String> store) {
- store.accept(FtpProperties.SERVER_HOST, "localhost");
+ store.accept(FtpProperties.SERVER_HOST, embeddedConfiguration.getServerAddress());
store.accept(FtpProperties.SERVER_PORT, String.valueOf(port));
store.accept(FtpProperties.ROOT_DIR, rootDir.toString());
}
@@ -156,19 +167,4 @@ public class SftpEmbeddedService extends AbstractTestService implements FtpServi
public int getPort() {
return port;
}
-
- public static boolean hasRequiredAlgorithms() {
- try {
- FileKeyPairProvider provider = new FileKeyPairProvider(Paths.get("src/test/resources/hostkey.pem"));
-
- provider.loadKeys(null);
- return true;
- } catch (Exception e) {
- String name = System.getProperty("os.name");
- String message = e.getMessage();
-
- LOG.warn("SunX509 is not available on this platform [{}] Testing is skipped! Real cause: {}", name, message, e);
- return false;
- }
- }
}
diff --git a/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/SftpUtil.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/SftpUtil.java
new file mode 100644
index 00000000000..59172af0934
--- /dev/null
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/embedded/SftpUtil.java
@@ -0,0 +1,65 @@
+/*
+ * 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.camel.test.infra.ftp.services.embedded;
+
+import java.nio.file.Paths;
+
+import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class SftpUtil {
+ private static final Logger LOG = LoggerFactory.getLogger(SftpUtil.class);
+
+ private static boolean checked;
+ private static boolean hasRequiredAlgorithms;
+
+ private SftpUtil() {
+
+ }
+
+ @Deprecated
+ public static boolean hasRequiredAlgorithms() {
+ return hasRequiredAlgorithms("src/test/resources/hostkey.pem");
+ }
+
+ public static boolean hasRequiredAlgorithms(String keyPairFile) {
+ if (!checked) {
+ hasRequiredAlgorithms = doCheck(keyPairFile);
+ }
+
+ return hasRequiredAlgorithms;
+ }
+
+ private static boolean doCheck(String keyPairFile) {
+ try {
+ FileKeyPairProvider provider = new FileKeyPairProvider(Paths.get(keyPairFile));
+
+ provider.loadKeys(null);
+ return true;
+ } catch (Exception e) {
+ String name = System.getProperty("os.name");
+ String message = e.getMessage();
+
+ LOG.warn("SunX509 is not available on this platform [{}] Testing is skipped! Real cause: {}", name, message, e);
+ return false;
+ } finally {
+ checked = true;
+ }
+ }
+}