This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit ad3e591a9da69e43fa6359ce113f024d20d5297f Author: James Netherton <[email protected]> AuthorDate: Mon May 15 15:29:16 2023 +0100 Align org.apache.ftpserver test dependency versions with Camel --- .../component/ftps/it/FtpsTestResource.java | 34 ++++++++++++++++++++-- pom.xml | 2 +- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/integration-tests/ftp/src/test/java/org/apache/camel/quarkus/component/ftps/it/FtpsTestResource.java b/integration-tests/ftp/src/test/java/org/apache/camel/quarkus/component/ftps/it/FtpsTestResource.java index cdbbca59cc..d009f5229c 100644 --- a/integration-tests/ftp/src/test/java/org/apache/camel/quarkus/component/ftps/it/FtpsTestResource.java +++ b/integration-tests/ftp/src/test/java/org/apache/camel/quarkus/component/ftps/it/FtpsTestResource.java @@ -16,7 +16,12 @@ */ package org.apache.camel.quarkus.component.ftps.it; -import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Map; +import java.util.Objects; import org.apache.camel.quarkus.component.ftp.it.FtpTestResource; import org.apache.ftpserver.listener.ListenerFactory; @@ -24,20 +29,45 @@ import org.apache.ftpserver.ssl.SslConfigurationFactory; public class FtpsTestResource extends FtpTestResource { + private Path keystoreFilePath; + public FtpsTestResource() { super("ftps"); } + @Override + public Map<String, String> start() { + try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("server.jks")) { + Objects.requireNonNull(stream, "FTP keystore file server.jks could not be loaded"); + keystoreFilePath = Files.createTempFile("camel-ftps-keystore", "jks"); + Files.write(keystoreFilePath, stream.readAllBytes()); + } catch (IOException e) { + throw new RuntimeException(e); + } + return super.start(); + } + @Override protected ListenerFactory createListenerFactory(int port) { SslConfigurationFactory sslConfigFactory = new SslConfigurationFactory(); - sslConfigFactory.setKeystoreFile(new File("server.jks")); + sslConfigFactory.setKeystoreFile(keystoreFilePath.toFile()); sslConfigFactory.setKeystoreType("PKCS12"); sslConfigFactory.setKeystorePassword("password"); sslConfigFactory.setKeyPassword("password"); + sslConfigFactory.setSslProtocol("TLSv1.3"); ListenerFactory factory = super.createListenerFactory(port); factory.setSslConfiguration(sslConfigFactory.createSslConfiguration()); return factory; } + + @Override + public void stop() { + super.stop(); + try { + Files.deleteIfExists(keystoreFilePath); + } catch (IOException e) { + // Ignored + } + } } diff --git a/pom.xml b/pom.xml index 4a1e0215dc..be73664508 100644 --- a/pom.xml +++ b/pom.xml @@ -153,7 +153,7 @@ <!-- Test dependency versions (keep sorted alphabetically) --> <consul-client.version>${consul-client-version}</consul-client.version> - <ftpserver.version>1.1.1</ftpserver.version> + <ftpserver.version>${ftpserver-version}</ftpserver.version> <greenmail.version>1.6.7</greenmail.version> <hamcrest.version>2.2</hamcrest.version><!-- Awaitility and Wiremock --> <htmlunit-driver.version>2.47.1</htmlunit-driver.version>
