Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAMEL-16400: split unit and integration tests for camel-ftp #5339

Merged
merged 1 commit into from Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions components/camel-ftp/pom.xml
Expand Up @@ -39,6 +39,11 @@
<camel.surefire.forkCount>4</camel.surefire.forkCount>
<camel.surefire.forkTimeout>1800</camel.surefire.forkTimeout>
<camel.surefire.parallel>false</camel.surefire.parallel>

<!-- This one can run in parallel rather safely-->
<camel.failsafe.forkCount>${camel.surefire.forkCount}</camel.failsafe.forkCount>
<camel.failsafe.forkTimeout>${camel.surefire.forkTimeout}</camel.failsafe.forkTimeout>
<camel.failsafe.parallel>${camel.surefire.parallel}</camel.failsafe.parallel>
</properties>

<dependencies>
Expand Down Expand Up @@ -196,4 +201,19 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<!-- This one can run in parallel rather safely-->
<forkCount>${camel.failsafe.forkCount}</forkCount>
<parallel>${camel.failsafe.parallel}</parallel>
<forkedProcessTimeoutInSeconds>${camel.failsafe.forkTimeout}</forkedProcessTimeoutInSeconds>
</configuration>
</plugin>
</plugins>
</build>

</project>

This file was deleted.

Expand Up @@ -16,50 +16,56 @@
*/
package org.apache.camel.component.file.remote;

import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Producer;
import java.util.HashMap;
import java.util.Map;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.BeforeEach;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.commons.net.ftp.FTPFile;
import org.junit.jupiter.api.Test;

public class FromFtpClientSoTimeoutTest extends FtpServerTestSupport {
import static org.junit.jupiter.api.Assertions.assertEquals;

private String getFtpUrl() {
return "ftp://admin@localhost:{{ftp.server.port}}/timeout/?password=admin&ftpClient.soTimeout=5000";
}
/**
* Test re-creating operations
*
* @see {org.apache.camel.component.file.remote.RemoteFileConsumer#recoverableConnectIfNecessary}
*/
public class FromFtpClientSoTimeoutTest extends CamelTestSupport {

@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
prepareFtpServer();
int port = AvailablePortFinder.getNextAvailable();

private String getFtpUrl() {
return "ftp://admin@localhost:" + port + "/timeout/?soTimeout=5000";
}

@Test
public void testTimeout() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
public void test() throws Exception {
@SuppressWarnings("unchecked")
FtpEndpoint<FTPFile> ftpEndpoint = context.getEndpoint(getFtpUrl(), FtpEndpoint.class);

mock.assertIsSatisfied();
}
// set "ftp://admin@localhost:21/timeout/?ftpClient.soTimeout=10"
Map<String, Object> ftpClientParameters = new HashMap<>();
ftpClientParameters.put("soTimeout", "10");
ftpEndpoint.setFtpClientParameters(ftpClientParameters);

private void prepareFtpServer() throws Exception {
// prepares the FTP Server by creating a file on the server
Endpoint endpoint = context.getEndpoint(getFtpUrl());
Exchange exchange = endpoint.createExchange();
exchange.getIn().setBody("Hello World");
exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt");
Producer producer = endpoint.createProducer();
producer.start();
producer.process(exchange);
producer.stop();
// test RemoteFileConsumer#buildConsumer
assertEquals("10", ftpClientParameters.get("soTimeout"));
ftpEndpoint.createRemoteFileOperations();

// test RemoteFileConsumer#recoverableConnectIfNecessary
// recover by re-creating operations which should most likely be able to
// recover
assertEquals("10", ftpClientParameters.get("soTimeout"));
ftpEndpoint.createRemoteFileOperations();
}

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {

@Override
public void configure() throws Exception {
from(getFtpUrl()).to("mock:result");
}
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.Exchange;
import org.junit.jupiter.api.Test;
Expand All @@ -24,7 +24,7 @@
/**
*
*/
public class ConsumerTemplateFtpShutdownTest extends FtpServerTestSupport {
public class ConsumerTemplateFtpShutdownIT extends FtpServerTestSupport {

protected String getFtpUrl() {
return "ftp://admin@localhost:{{ftp.server.port}}/template?password=admin";
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import java.io.File;

Expand All @@ -28,7 +28,7 @@
/**
*
*/
public class FileToFtpTempFileNameTest extends FtpServerTestSupport {
public class FileToFtpTempFileNameIT extends FtpServerTestSupport {

@Test
public void testFileToFtp() throws Exception {
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.BindToRegistry;
import org.apache.camel.support.jsse.KeyManagersParameters;
Expand All @@ -24,7 +24,7 @@
import org.junit.jupiter.api.TestInstance;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersTest extends FileToFtpsExplicitSSLWithClientAuthTest {
public class FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersIT extends FileToFtpsExplicitSSLWithClientAuthIT {

@BindToRegistry("sslContextParameters")
public SSLContextParameters createSslContextParams() throws Exception {
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
Expand All @@ -23,7 +23,7 @@
/**
* Test the ftps component over SSL (explicit) with client authentication
*/
public class FileToFtpsExplicitSSLWithClientAuthTest extends FtpsServerExplicitSSLWithClientAuthTestSupport {
public class FileToFtpsExplicitSSLWithClientAuthIT extends FtpsServerExplicitSSLWithClientAuthTestSupport {

protected String getFtpUrl() {
return "ftps://admin@localhost:{{ftp.server.port}}"
Expand Down
Expand Up @@ -14,16 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.CamelContext;
import org.apache.camel.SSLContextParametersAware;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;

public class FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersTest
extends FileToFtpsExplicitSSLWithoutClientAuthTest {
public class FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersIT
extends FileToFtpsExplicitSSLWithoutClientAuthIT {

@Override
protected CamelContext createCamelContext() throws Exception {
Expand Down
Expand Up @@ -14,15 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.BindToRegistry;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;

public class FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersTest
extends FileToFtpsExplicitSSLWithoutClientAuthTest {
public class FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersIT
extends FileToFtpsExplicitSSLWithoutClientAuthIT {

@BindToRegistry("sslContextParameters")
public SSLContextParameters createSslContextParams() throws Exception {
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
Expand All @@ -25,7 +25,7 @@
* Test the ftps component over SSL (explicit) without client authentication
*/
@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsExplicitSSLWithoutClientAuthTest extends FtpsServerExplicitSSLWithoutClientAuthTestSupport {
public class FileToFtpsExplicitSSLWithoutClientAuthIT extends FtpsServerExplicitSSLWithoutClientAuthTestSupport {

protected String getFtpUrl() {
return "ftps://admin@localhost:{{ftp.server.port}}"
Expand Down
Expand Up @@ -14,15 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.BindToRegistry;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;

public class FileToFtpsExplicitTLSWithClientAuthAndSSLContextParametersTest extends FileToFtpsExplicitTLSWithClientAuthTest {
public class FileToFtpsExplicitTLSWithClientAuthAndSSLContextParametersIT extends FileToFtpsExplicitTLSWithClientAuthIT {

@BindToRegistry("sslContextParameters")
public SSLContextParameters createSslContextParams() throws Exception {
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
Expand All @@ -25,7 +25,7 @@
* Test the ftps component over TLS (explicit) with client authentication
*/
@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsExplicitTLSWithClientAuthTest extends FtpsServerExplicitTLSWithClientAuthTestSupport {
public class FileToFtpsExplicitTLSWithClientAuthIT extends FtpsServerExplicitTLSWithClientAuthTestSupport {

protected String getFtpUrl() {
return "ftps://admin@localhost:{{ftp.server.port}}"
Expand Down
Expand Up @@ -14,15 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.BindToRegistry;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;

public class FileToFtpsExplicitTLSWithoutClientAuthAndSSLContextParametersTest
extends FileToFtpsExplicitTLSWithoutClientAuthTest {
public class FileToFtpsExplicitTLSWithoutClientAuthAndSSLContextParametersIT
extends FileToFtpsExplicitTLSWithoutClientAuthIT {
@BindToRegistry("sslContextParameters")
public SSLContextParameters createSslContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.file.remote;
package org.apache.camel.component.file.remote.integration;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
Expand All @@ -25,7 +25,7 @@
* Test the ftps component over TLS (explicit) without client authentication
*/
@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsExplicitTLSWithoutClientAuthTest extends FtpsServerExplicitTLSWithoutClientAuthTestSupport {
public class FileToFtpsExplicitTLSWithoutClientAuthIT extends FtpsServerExplicitTLSWithoutClientAuthTestSupport {

protected String getFtpUrl() {
return "ftps://admin@localhost:{{ftp.server.port}}"
Expand Down