diff --git a/file-bindy-ftp/pom.xml b/file-bindy-ftp/pom.xml index 7865f3a9..16bdac7e 100644 --- a/file-bindy-ftp/pom.xml +++ b/file-bindy-ftp/pom.xml @@ -17,7 +17,8 @@ limitations under the License. --> - + 4.0.0 camel-quarkus-examples-file-bindy-ftp @@ -36,6 +37,7 @@ ${quarkus.platform.group-id} quarkus-camel-bom + 0.0.16 UTF-8 UTF-8 11 @@ -130,6 +132,18 @@ testcontainers test + + io.quarkus.qe + quarkus-test-core + ${version.quarkus.ts} + test + + + io.quarkus.qe + quarkus-test-openshift + ${version.quarkus.ts} + test + @@ -223,7 +237,8 @@ CAMEL_PROPERTIES_STYLE - ${maven.multiModuleProjectDirectory}/license-properties-headerdefinition.xml + ${maven.multiModuleProjectDirectory}/license-properties-headerdefinition.xml + @@ -271,6 +286,18 @@ + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + @@ -331,22 +358,6 @@ native true - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - - diff --git a/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpCommonTest.java b/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpCommonTest.java new file mode 100644 index 00000000..e08cec8c --- /dev/null +++ b/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpCommonTest.java @@ -0,0 +1,45 @@ +package org.apache.camel.example; + +import java.util.concurrent.TimeUnit; + +import com.jcraft.jsch.*; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.junit.jupiter.api.Test; + +import static org.awaitility.Awaitility.await; + +public class FileToFtpCommonTest { + @Test + public void testFileToFtp() throws JSchException { + Config config = ConfigProvider.getConfig(); + + JSch jsch = new JSch(); + jsch.setKnownHosts(System.getProperty("user.home") + "/.ssh/known_hosts"); + + Session session = jsch.getSession("ftpuser", config.getValue("ftp.host", String.class)); + session.setPort(config.getValue("ftp.port", Integer.class)); + session.setPassword("ftppassword"); + session.setConfig("StrictHostKeyChecking", "no"); + session.connect(5000); + Channel sftp = null; + try { + sftp = session.openChannel("sftp"); + sftp.connect(5000); + + ChannelSftp channelSftp = (ChannelSftp) sftp; + + await().atMost(10L, TimeUnit.SECONDS).pollDelay(500, TimeUnit.MILLISECONDS).until(() -> { + try { + return channelSftp.ls("uploads/books/*.csv").size() >= 3; + } catch (Exception e) { + return false; + } + }); + } finally { + if (sftp != null) { + sftp.disconnect(); + } + } + } +} diff --git a/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpOpenShiftIT.java b/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpOpenShiftIT.java new file mode 100644 index 00000000..ab3ccbb4 --- /dev/null +++ b/file-bindy-ftp/src/test/java/org/apache/camel/example/FileToFtpOpenShiftIT.java @@ -0,0 +1,31 @@ +package org.apache.camel.example; + +import io.fabric8.kubernetes.client.LocalPortForward; +import io.fabric8.openshift.client.DefaultOpenShiftClient; +import io.fabric8.openshift.client.OpenShiftClient; +import io.quarkus.test.scenarios.OpenShiftDeploymentStrategy; +import io.quarkus.test.scenarios.OpenShiftScenario; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; + +import java.io.IOException; + +@OpenShiftScenario(deployment = OpenShiftDeploymentStrategy.UsingOpenShiftExtensionAndDockerBuildStrategy) +public class FileToFtpOpenShiftIT extends FileToFtpCommonTest { + private static LocalPortForward portForward; + + @BeforeAll + public static void setup() { + final OpenShiftClient ocpClient = new DefaultOpenShiftClient(); + System.setProperty("ftp.host", "localhost"); + System.setProperty("ftp.port", "2222"); + portForward = ocpClient.services().withName("ftp-server").portForward(2222, 2222); + } + + @AfterAll + public static void tearDown() throws IOException { + if (portForward != null) { + portForward.close(); + } + } +} 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 0278ccbd..671ecca3 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 @@ -16,55 +16,11 @@ */ package org.apache.camel.example; -import java.util.concurrent.TimeUnit; - -import com.jcraft.jsch.Channel; -import com.jcraft.jsch.ChannelSftp; -import com.jcraft.jsch.JSch; -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; @QuarkusTest @QuarkusTestResource(FtpTestResource.class) -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"); - - Session session = jsch.getSession("ftpuser", config.getValue("ftp.host", String.class)); - session.setPort(config.getValue("ftp.port", Integer.class)); - session.setPassword("ftppassword"); - session.setConfig("StrictHostKeyChecking", "no"); - session.connect(5000); - Channel sftp = null; - try { - sftp = session.openChannel("sftp"); - sftp.connect(5000); - - ChannelSftp channelSftp = (ChannelSftp) sftp; +public class FileToFtpTest extends FileToFtpCommonTest { - await().atMost(10L, TimeUnit.SECONDS).pollDelay(500, TimeUnit.MILLISECONDS).until(() -> { - try { - return channelSftp.ls("uploads/books/*.csv").size() >= 3; - } catch (Exception e) { - return false; - } - }); - } finally { - if (sftp != null) { - sftp.disconnect(); - } - } - } }