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

ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus-examples.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e7c17f  Use MP config instead of System.getProperty() in a test to 
simplify testing against manuanlly started services
5e7c17f is described below

commit 5e7c17f7a73fab3b36cbbf0b1d6c88d89f832823
Author: Peter Palaga <ppal...@redhat.com>
AuthorDate: Tue Apr 6 11:55:54 2021 +0200

    Use MP config instead of System.getProperty() in a test to simplify testing 
against manuanlly started services
---
 file-bindy-ftp/src/main/resources/application.properties      |  8 ++++----
 .../src/test/java/org/apache/camel/example/FileToFtpTest.java | 11 ++++++++---
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/file-bindy-ftp/src/main/resources/application.properties 
b/file-bindy-ftp/src/main/resources/application.properties
index 4fd8027..e0bdf53 100644
--- a/file-bindy-ftp/src/main/resources/application.properties
+++ b/file-bindy-ftp/src/main/resources/application.properties
@@ -28,10 +28,10 @@ timer.delay = 10000
 csv.location = {{sys:java.io.tmpdir}}/books
 
 # FTP server location
-ftp.host = {{env:FTP_SERVER_SERVICE_HOST:localhost}}
-ftp.port = {{env:FTP_SERVER_SERVICE_PORT:2222}}
-ftp.username = {{env:FTP_USER:ftpuser}}
-ftp.password = {{env:FTP_PASSWORD:ftppassword}}
+ftp.host = ${FTP_SERVER_SERVICE_HOST:localhost}
+ftp.port = ${FTP_SERVER_SERVICE_PORT:2222}
+ftp.username = ${FTP_USER:ftpuser}
+ftp.password = ${FTP_PASSWORD:ftppassword}
 
 # Kubernetes
 
diff --git 
a/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpTest.java 
b/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpTest.java
index 8e6e182..9f354a7 100644
--- a/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpTest.java
+++ b/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpTest.java
@@ -25,6 +25,8 @@ import com.jcraft.jsch.JSchException;
 import com.jcraft.jsch.Session;
 import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
 import org.junit.jupiter.api.Test;
 
 import static org.awaitility.Awaitility.await;
@@ -35,11 +37,14 @@ public class FileToFtpTest {
 
     @Test
     public void testFileToFtp() throws JSchException {
+
+        Config config = ConfigProvider.getConfig();
+
         JSch jsch = new JSch();
-        jsch.setKnownHosts(System.getProperty("user.home") + 
"/.ssh/known_hosts");
+        jsch.setKnownHosts(config.getValue("user.home", String.class) + 
"/.ssh/known_hosts");
 
-        Session session = jsch.getSession("ftpuser", 
System.getProperty("ftp.host"));
-        session.setPort(Integer.parseInt(System.getProperty("ftp.port")));
+        Session session = jsch.getSession("ftpuser", 
config.getValue("ftp.host", String.class));
+        session.setPort(Integer.parseInt(config.getValue("ftp.port", 
String.class)));
         session.setPassword("ftppassword");
         session.setConfig("StrictHostKeyChecking", "no");
         session.connect(5000);

Reply via email to