Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions file-bindy-ftp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>camel-quarkus-examples-file-bindy-ftp</artifactId>
Expand All @@ -36,6 +37,7 @@
<camel-quarkus.platform.group-id>${quarkus.platform.group-id}</camel-quarkus.platform.group-id>
<camel-quarkus.platform.artifact-id>quarkus-camel-bom</camel-quarkus.platform.artifact-id>

<version.quarkus.ts>0.0.16</version.quarkus.ts>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.target>11</maven.compiler.target>
Expand Down Expand Up @@ -130,6 +132,18 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus.qe</groupId>
<artifactId>quarkus-test-core</artifactId>
<version>${version.quarkus.ts}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus.qe</groupId>
<artifactId>quarkus-test-openshift</artifactId>
<version>${version.quarkus.ts}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -223,7 +237,8 @@
<Dockerfile.native>CAMEL_PROPERTIES_STYLE</Dockerfile.native>
</mapping>
<headerDefinitions>
<headerDefinition>${maven.multiModuleProjectDirectory}/license-properties-headerdefinition.xml</headerDefinition>
<headerDefinition>${maven.multiModuleProjectDirectory}/license-properties-headerdefinition.xml
</headerDefinition>
</headerDefinitions>
</configuration>
</plugin>
Expand Down Expand Up @@ -271,6 +286,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -331,22 +358,6 @@
<quarkus.package.type>native</quarkus.package.type>
<quarkus.native.container-build>true</quarkus.native.container-build>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
}