You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/12/08 15:48:56 UTC
[camel] branch master updated: CAMEL-15915: fix camel-ftp tests
(#4738)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 1821d39 CAMEL-15915: fix camel-ftp tests (#4738)
1821d39 is described below
commit 1821d3993b703b9fbf20d88c0709ee65d9957713
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Tue Dec 8 16:48:34 2020 +0100
CAMEL-15915: fix camel-ftp tests (#4738)
This includes
- migrating the camel-ftp to the new test-infra
- reworking the tests so that the lifecycle of embedded test FTPs is
handled by JUnit 5
- minor cleanups to ensure a clean test execution
---
components/camel-ftp/pom.xml | 18 ++
.../file/remote/BaseServerTestSupport.java | 22 ---
.../remote/ConsumerTemplateFtpShutdownTest.java | 2 +-
.../file/remote/FileToFtpTempFileNameTest.java | 4 +-
...LWithClientAuthAndSSLContextParametersTest.java | 4 +-
.../FileToFtpsExplicitSSLWithClientAuthTest.java | 6 +-
...lientAuthAndGlobalSSLContextParametersTest.java | 2 +-
...thoutClientAuthAndSSLContextParametersTest.java | 2 +-
...FileToFtpsExplicitSSLWithoutClientAuthTest.java | 8 +-
...SWithClientAuthAndSSLContextParametersTest.java | 2 +-
.../FileToFtpsExplicitTLSWithClientAuthTest.java | 8 +-
...thoutClientAuthAndSSLContextParametersTest.java | 2 +-
...FileToFtpsExplicitTLSWithoutClientAuthTest.java | 8 +-
...LWithClientAuthAndSSLContextParametersTest.java | 2 +-
.../FileToFtpsImplicitSSLWithClientAuthTest.java | 8 +-
...thoutClientAuthAndSSLContextParametersTest.java | 2 +-
...FileToFtpsImplicitSSLWithoutClientAuthTest.java | 8 +-
...SWithClientAuthAndSSLContextParametersTest.java | 2 +-
.../FileToFtpsImplicitTLSWithClientAuthTest.java | 8 +-
...thoutClientAuthAndSSLContextParametersTest.java | 2 +-
...FileToFtpsImplicitTLSWithoutClientAuthTest.java | 9 +-
...psWithCustomKeyAndTrustStorePropertiesTest.java | 8 +-
...leToFtpsWithCustomTrustStorePropertiesTest.java | 8 +-
.../FileToFtpsWithDefaultSettingsIPV6Test.java | 6 +-
.../remote/FileToFtpsWithDefaultSettingsTest.java | 8 +-
.../FileToFtpsWithFtpClientConfigRefTest.java | 8 +-
.../file/remote/FromFilePasswordBeanRefTest.java | 2 +-
.../remote/FromFilePasswordPropertyRefTest.java | 2 +-
.../remote/FromFilePercentSignInPasswordTest.java | 2 +-
...lePercentSignInPasswordUserInfoEncodedTest.java | 2 +-
.../FromFilePercentSignInPasswordUserInfoTest.java | 2 +-
...FromFileToFtpDefaultRootRenameStrategyTest.java | 6 +-
.../file/remote/FromFileToFtpDeleteTest.java | 4 +-
.../file/remote/FromFileToFtpNotStepwiseTest.java | 2 +-
.../component/file/remote/FromFileToFtpTest.java | 2 +-
.../file/remote/FromFileToFtpWithChmodTest.java | 2 +-
.../remote/FromFileTransferLoggingLevelTest.java | 2 +-
.../FromFileTransferLoggingLevelVerboseTest.java | 2 +-
.../file/remote/FromFtpActivePortRangeTest.java | 2 +-
.../file/remote/FromFtpAsyncProcessTest.java | 11 +-
.../file/remote/FromFtpClientConfigRefTest.java | 2 +-
.../file/remote/FromFtpClientDataTimeoutTest.java | 2 +-
.../file/remote/FromFtpClientSoTimeout2Test.java | 2 +-
.../file/remote/FromFtpClientSoTimeout3Test.java | 2 +-
.../file/remote/FromFtpClientSoTimeoutTest.java | 2 +-
.../FromFtpConsumerTemplateRollbackTest.java | 6 +-
.../file/remote/FromFtpConsumerTemplateTest.java | 6 +-
.../remote/FromFtpDeleteFileNotStepwiseTest.java | 2 +-
.../remote/FromFtpDeleteFileScottTigerTest.java | 2 +-
.../file/remote/FromFtpDeleteFileTest.java | 6 +-
...omFtpDirectoryToBinaryFilesNotStepwiseTest.java | 2 +-
.../remote/FromFtpDirectoryToBinaryFilesTest.java | 48 ++---
.../FromFtpDoNotDeleteFileIfProcessFailsTest.java | 6 +-
.../FromFtpExclusiveReadNoneStrategyTest.java | 8 +-
.../file/remote/FromFtpFilterNotStepwiseTest.java | 2 +-
.../component/file/remote/FromFtpFilterTest.java | 2 +-
.../FromFtpKeepLastModifiedNotStepwiseTest.java | 2 +-
.../file/remote/FromFtpKeepLastModifiedTest.java | 2 +-
...FileAbsoluteFolderRecursiveNotStepwiseTest.java | 2 +-
...FromFtpMoveFileAbsoluteFolderRecursiveTest.java | 8 +-
.../remote/FromFtpMoveFileNotStepwiseTest.java | 2 +-
.../FromFtpMoveFilePostfixNotStepwiseTest.java | 2 +-
.../file/remote/FromFtpMoveFilePostfixTest.java | 6 +-
.../FromFtpMoveFilePrefixNotStepwiseTest.java | 2 +-
.../file/remote/FromFtpMoveFilePrefixTest.java | 6 +-
.../FromFtpMoveFileRecursiveNotStepwiseTest.java | 2 +-
.../file/remote/FromFtpMoveFileRecursiveTest.java | 8 +-
.../component/file/remote/FromFtpMoveFileTest.java | 6 +-
...FileToHiddenFolderRecursiveNotStepwiseTest.java | 2 +-
...FromFtpMoveFileToHiddenFolderRecursiveTest.java | 8 +-
...tPathRelativeMoveToAbsoluteNotStepwiseTest.java | 2 +-
...tpNoEndpointPathRelativeMoveToAbsoluteTest.java | 8 +-
.../component/file/remote/FromFtpNoFilesTest.java | 6 +-
.../file/remote/FromFtpNoopAccountTest.java | 2 +-
.../remote/FromFtpNoopIdempotentFalseTest.java | 4 +-
.../component/file/remote/FromFtpNoopTest.java | 4 +-
.../file/remote/FromFtpNotDownloadTest.java | 2 +-
.../file/remote/FromFtpPassiveModeTest.java | 2 +-
.../file/remote/FromFtpPollFileOnlyTest.java | 4 +-
.../FromFtpPreMoveDeleteNotStepwiseTest.java | 2 +-
.../file/remote/FromFtpPreMoveDeleteTest.java | 6 +-
.../remote/FromFtpPreMoveFileExpressionTest.java | 6 +-
.../FromFtpPreMoveFilePostfixNotStepwiseTest.java | 2 +-
.../file/remote/FromFtpPreMoveFilePostfixTest.java | 6 +-
.../FromFtpPreMoveFilePrefixNotStepwiseTest.java | 2 +-
.../file/remote/FromFtpPreMoveFilePrefixTest.java | 6 +-
.../remote/FromFtpPreMoveNoopNotStepwiseTest.java | 2 +-
.../file/remote/FromFtpPreMoveNoopTest.java | 6 +-
.../FromFtpRecursiveNoopNotStepwiseTest.java | 2 +-
.../file/remote/FromFtpRecursiveNoopTest.java | 2 +-
.../FromFtpRecursiveNotStepwiseNoBasePathTest.java | 2 +-
.../file/remote/FromFtpRegexPatternTest.java | 4 +-
.../FromFtpRemoteFileFilterDirectoryTest.java | 2 +-
.../file/remote/FromFtpRemoteFileFilterTest.java | 2 +-
.../FromFtpRemoteFileSortByExpressionTest.java | 2 +-
...tpRemoteFileSortByIgnoreCaseExpressionTest.java | 4 +-
...romFtpRemoteFileSortByNestedExpressionTest.java | 2 +-
.../file/remote/FromFtpRemoteFileSorterTest.java | 2 +-
.../file/remote/FromFtpSedaDeleteFileTest.java | 14 +-
.../FromFtpServerLanguageCodeAndTimeoutTest.java | 2 +-
.../file/remote/FromFtpServerLanguageCodeTest.java | 2 +-
.../FromFtpSetNamesWithMultiDirectoriesTest.java | 6 +-
...tPathRelativeMoveToAbsoluteNotStepwiseTest.java | 2 +-
...leNoEndpointPathRelativeMoveToAbsoluteTest.java | 8 +-
...tPathRelativeMoveToRelativeNotStepwiseTest.java | 2 +-
...leNoEndpointPathRelativeMoveToRelativeTest.java | 8 +-
...impleRelativeMoveToAbsoluteNotStepwiseTest.java | 2 +-
.../FromFtpSimpleRelativeMoveToAbsoluteTest.java | 8 +-
...impleRelativeMoveToRelativeNotStepwiseTest.java | 2 +-
.../FromFtpSimpleRelativeMoveToRelativeTest.java | 8 +-
.../FromFtpSimulateNetworkIssueRecoverTest.java | 2 +-
.../FromFtpStartingDirAndFileNameClashTest.java | 2 +-
.../file/remote/FromFtpThirdPoolOkTest.java | 6 +-
.../FromFtpToAsciiFileNoBodyConversionTest.java | 2 +-
.../file/remote/FromFtpToAsciiFileTest.java | 2 +-
.../file/remote/FromFtpToBinaryFileTest.java | 3 +-
.../file/remote/FromFtpToBinaryFilesTest.java | 7 +-
.../remote/FromFtpToFileNoFileNameHeaderTest.java | 2 +-
.../component/file/remote/FromFtpToMockTest.java | 2 +-
.../file/remote/FromFtpTwoSlashesIssueTest.java | 4 +-
.../file/remote/FromFtpUseListFalseTest.java | 33 ++--
.../remote/FromQueueThenConsumeFtpToMockTest.java | 4 +-
.../component/file/remote/FtpAnonymousTest.java | 2 +-
.../file/remote/FtpBadLoginConnectionLeakTest.java | 2 +-
.../FtpBadLoginInProducerConnectionLeakTest.java | 2 +-
.../FtpBadLoginMockNoopConnectionLeakTest.java | 2 +-
.../file/remote/FtpBrowsableEndpointTest.java | 35 +++-
.../FtpChangedReadLockFastExistCheckTest.java | 2 +-
.../file/remote/FtpChangedReadLockTest.java | 6 +-
...tpChangedRootDirReadLockFastExistCheckTest.java | 2 +-
.../file/remote/FtpChangedRootDirReadLockTest.java | 6 +-
.../remote/FtpChangedZeroLengthReadLockTest.java | 6 +-
.../file/remote/FtpConnectTimeoutTest.java | 2 +-
.../file/remote/FtpConsumerAbsolutePathTest.java | 2 +-
.../file/remote/FtpConsumerAsyncStressTest.java | 5 +-
.../file/remote/FtpConsumerAutoCreateTest.java | 23 ++-
.../file/remote/FtpConsumerBodyAsStringTest.java | 2 +-
.../FtpConsumerDeleteNoWritePermissionTest.java | 4 +-
.../FtpConsumerDirectoriesNotMatchedTest.java | 2 +-
.../file/remote/FtpConsumerDisconnectTest.java | 2 +-
.../FtpConsumerDoneFileNameFixedStepwiseTest.java | 2 +-
.../remote/FtpConsumerDoneFileNameFixedTest.java | 4 +-
.../FtpConsumerDoneFileNameStepwiseTest.java | 2 +-
.../file/remote/FtpConsumerDoneFileNameTest.java | 4 +-
.../remote/FtpConsumerDualDoneFileNameTest.java | 2 +-
.../file/remote/FtpConsumerExcludeNameTest.java | 2 +-
.../file/remote/FtpConsumerFileSplitTest.java | 2 +-
.../remote/FtpConsumerIPV6BodyAsStringTest.java | 2 +-
.../FtpConsumerIdempotentKeyChangedIssueTest.java | 2 +-
.../remote/FtpConsumerIdempotentMemoryRefTest.java | 6 +-
.../file/remote/FtpConsumerIdempotentRefTest.java | 6 +-
.../file/remote/FtpConsumerIdempotentTest.java | 2 +-
.../file/remote/FtpConsumerIncludeNameTest.java | 2 +-
...nsumerLocalWorkDirectoryAsAbsolutePathTest.java | 2 +-
.../FtpConsumerLocalWorkDirectoryDirectTest.java | 2 +-
.../remote/FtpConsumerLocalWorkDirectoryTest.java | 2 +-
.../remote/FtpConsumerMaxMessagesPerPollTest.java | 17 +-
.../file/remote/FtpConsumerMoveExpressionTest.java | 4 +-
.../remote/FtpConsumerMultipleDirectoriesTest.java | 2 +-
.../FtpConsumerNotEagerMaxMessagesPerPollTest.java | 2 +-
.../FtpConsumerPostProcessingOnDisconnect.java | 22 +--
.../remote/FtpConsumerProcessStrategyTest.java | 7 +-
.../remote/FtpConsumerRelativeFileNameTest.java | 2 +-
.../file/remote/FtpConsumerReplyStringTest.java | 2 +-
.../file/remote/FtpConsumerResumeDownloadTest.java | 7 +-
.../file/remote/FtpConsumerSkipDotFilesTest.java | 2 +-
.../file/remote/FtpConsumerTemplateTest.java | 8 +-
.../FtpConsumerTemplateUseListFalseTest.java | 5 +-
...FtpConsumerThrowExceptionOnLoginFailedTest.java | 2 +-
.../FtpConsumerUsingFTPClientConfigTest.java | 2 +-
.../file/remote/FtpConsumerWithCharsetTest.java | 4 +-
.../remote/FtpConsumerWithNoFileOptionTest.java | 2 +-
.../file/remote/FtpEndpointURISanitizedTest.java | 2 +-
.../component/file/remote/FtpLoginNoRetryTest.java | 7 +-
.../camel/component/file/remote/FtpLoginTest.java | 6 +-
.../FtpNoReconnectAttemptUnknownHostTest.java | 2 +-
.../FtpPollEnrichBridgeErrorHandlerTest.java | 6 +-
...llEnrichConsumeWithDisconnectAndDeleteTest.java | 10 +-
.../remote/FtpPollingConsumerIdleMessageTest.java | 4 +-
.../file/remote/FtpPollingConsumerTest.java | 4 +-
...pProducerAllowNullBodyFileAlreadyExistTest.java | 6 +-
.../file/remote/FtpProducerAllowNullBodyTest.java | 6 +-
.../file/remote/FtpProducerBuildDirectoryTest.java | 4 +-
.../FtpProducerBuildPartOfDirectoryTest.java | 4 +-
.../file/remote/FtpProducerConcurrentTest.java | 4 +-
.../remote/FtpProducerConnectErrorsHeaderTest.java | 2 +-
.../FtpProducerDisconnectOnBatchCompleteTest.java | 2 +-
.../file/remote/FtpProducerDisconnectTest.java | 2 +-
.../file/remote/FtpProducerDoneFileNameTest.java | 18 +-
.../file/remote/FtpProducerExpressionTest.java | 18 +-
...FtpProducerFileExistAppendNoFileBeforeTest.java | 4 +-
.../remote/FtpProducerFileExistAppendTest.java | 4 +-
.../file/remote/FtpProducerFileExistFailTest.java | 4 +-
.../remote/FtpProducerFileExistIgnoreTest.java | 4 +-
...pProducerFileExistOverrideNoFileBeforeTest.java | 4 +-
...rrideNotEagerDeleteTargetFileTwoUploadTest.java | 2 +-
.../remote/FtpProducerFileExistOverrideTest.java | 4 +-
.../FtpProducerFileExistOverrideTwoUploadTest.java | 6 +-
.../remote/FtpProducerFileFastExistFailTest.java | 2 +-
.../remote/FtpProducerFileWithCharsetTest.java | 4 +-
.../FtpProducerFileWithPathNoStepwiseTest.java | 4 +-
...ileWithPathPathSeparatorAutoNoStepwiseTest.java | 4 +-
...ileWithPathPathSeparatorUnixNoStepwiseTest.java | 4 +-
...WithPathPathSeparatorWindowsNoStepwiseTest.java | 4 +-
.../file/remote/FtpProducerFileWithPathTest.java | 4 +-
.../FtpProducerJailStartingDirectoryTest.java | 2 +-
.../file/remote/FtpProducerMoveExistingTest.java | 90 +++++----
.../remote/FtpProducerMultipleSiteCommandTest.java | 4 +-
.../file/remote/FtpProducerRawPasswordTest.java | 4 +-
...tpProducerRecipientListParallelTimeoutTest.java | 2 +-
.../file/remote/FtpProducerRecipientListTest.java | 8 +-
.../file/remote/FtpProducerReplyStringTest.java | 2 +-
.../remote/FtpProducerRootFileExistFailTest.java | 4 +-
.../file/remote/FtpProducerSendNoopFalseTest.java | 4 +-
.../file/remote/FtpProducerSiteCommandTest.java | 4 +-
.../remote/FtpProducerTempFileExistIssueTest.java | 12 +-
.../file/remote/FtpProducerTempPrefixTest.java | 4 +-
.../remote/FtpProducerToDMoveExistingTest.java | 6 +-
.../FtpReconnectAttemptServerStoppedTest.java | 9 +-
.../remote/FtpReconnectAttemptUnknownHostTest.java | 2 +-
.../file/remote/FtpRecursiveDepth2Test.java | 14 +-
.../file/remote/FtpRecursiveDepth3Test.java | 14 +-
.../file/remote/FtpRecursiveDepthTest.java | 16 +-
.../file/remote/FtpServerTestSupport.java | 132 +-------------
.../remote/FtpShutdownCompleteAllTasksTest.java | 4 +-
.../FtpShutdownCompleteCurrentTaskOnlyTest.java | 4 +-
.../file/remote/FtpSimpleConsumeAbsoluteTest.java | 8 +-
...ectoryParseWithAbsoluteDepthNoStepwiseTest.java | 8 +-
.../FtpSimpleConsumeStreamingPartialReadTest.java | 8 +-
...FtpSimpleConsumeStreamingStepwiseFalseTest.java | 8 +-
...impleConsumeStreamingWithMultipleFilesTest.java | 8 +-
.../file/remote/FtpStreamingMoveTest.java | 8 +-
.../FtpThrowExceptionOnConnectionFailedTest.java | 4 +-
...ServerExplicitSSLWithClientAuthTestSupport.java | 32 +---
...verExplicitSSLWithoutClientAuthTestSupport.java | 32 +---
...ServerExplicitTLSWithClientAuthTestSupport.java | 32 +---
...verExplicitTLSWithoutClientAuthTestSupport.java | 32 +---
...ServerImplicitSSLWithClientAuthTestSupport.java | 33 +---
...verImplicitSSLWithoutClientAuthTestSupport.java | 33 +---
...ServerImplicitTLSWithClientAuthTestSupport.java | 33 +---
...verImplicitTLSWithoutClientAuthTestSupport.java | 32 +---
.../file/remote/FtpsServerTestSupport.java | 105 +----------
.../component/file/remote/PaddyRouteTest.java | 2 +-
.../RecipientListErrorHandlingIssueTest.java | 2 +-
.../RemoteFileProduceOverruleOnlyOnceTest.java | 4 +-
...llEnrichConsumeWithDisconnectAndDeleteTest.java | 14 +-
.../remote/ToFtpTempFileTargetFileExistTest.java | 6 +-
.../FtpEmbeddedService.java} | 162 +++++++++--------
.../file/remote/services/FtpsEmbeddedService.java | 102 +++++++++++
.../file/remote/services/SftpEmbeddedService.java | 202 +++++++++++++++++++++
...FromSftpRecursiveNotStepwiseNoBasePathTest.java | 28 +--
.../file/remote/sftp/SftpChangedReadLockTest.java | 15 +-
.../component/file/remote/sftp/SftpChmodTest.java | 12 +-
.../file/remote/sftp/SftpConsumeTemplateTest.java | 11 +-
.../remote/sftp/SftpConsumerAutoCreateTest.java | 35 ++--
.../remote/sftp/SftpConsumerDisconnectTest.java | 37 ++--
.../sftp/SftpConsumerProcessStrategyTest.java | 10 +-
.../remote/sftp/SftpConsumerWithCharsetTest.java | 11 +-
.../file/remote/sftp/SftpECKeyFileConsumeTest.java | 13 +-
.../remote/sftp/SftpFromSedaDeleteFileTest.java | 7 +-
.../file/remote/sftp/SftpKeyConsumeTest.java | 10 +-
.../file/remote/sftp/SftpKeyFileConsumeTest.java | 13 +-
.../remote/sftp/SftpKeyPairDSAConsumeTest.java | 13 +-
.../remote/sftp/SftpKeyPairRSAConsumeTest.java | 13 +-
.../sftp/SftpKeyUriConsumeFromClasspathTest.java | 10 +-
.../file/remote/sftp/SftpKeyUriConsumeTest.java | 12 +-
.../file/remote/sftp/SftpProduceTempFileTest.java | 16 +-
.../SftpProducerFileWithPathNoStepwiseTest.java | 10 +-
.../remote/sftp/SftpProducerFileWithPathTest.java | 32 +---
.../remote/sftp/SftpProducerMoveExistingTest.java | 77 ++++----
.../remote/sftp/SftpProducerWithCharsetTest.java | 10 +-
.../file/remote/sftp/SftpServerTestSupport.java | 146 +--------------
.../file/remote/sftp/SftpSetCipherTest.java | 12 +-
.../file/remote/sftp/SftpSetOperationsTest.java | 10 +-
.../sftp/SftpSimpleConsumeNoStartingDirTest.java | 8 +-
.../sftp/SftpSimpleConsumeNotStepwiseTest.java | 4 +-
.../SftpSimpleConsumeRecursiveNotStepwiseTest.java | 2 +-
.../sftp/SftpSimpleConsumeRecursiveTest.java | 16 +-
.../SftpSimpleConsumeStreamingPartialReadTest.java | 12 +-
.../sftp/SftpSimpleConsumeStreamingTest.java | 10 +-
...impleConsumeStreamingWithMultipleFilesTest.java | 12 +-
.../file/remote/sftp/SftpSimpleConsumeTest.java | 10 +-
.../sftp/SftpSimpleConsumeThroughProxyTest.java | 33 ++--
.../remote/sftp/SftpSimpleIPV6ConsumeTest.java | 10 +-
.../sftp/SftpSimpleProduceDisconnectTest.java | 20 +-
.../sftp/SftpSimpleProduceNotStepwiseTest.java | 28 +--
.../file/remote/sftp/SftpSimpleProduceTest.java | 29 ++-
.../sftp/SftpSimpleProduceThroughProxyTest.java | 88 +++------
.../file/remote/sftp/SftpUseListFalseTest.java | 10 +-
test-infra/camel-test-infra-ftp/pom.xml | 55 ++++++
.../src/main/resources/META-INF/MANIFEST.MF | 0
.../camel/test/infra/ftp/common/FtpProperties.java | 14 +-
.../test/infra/ftp/services/FtpRemoteService.java | 20 +-
.../camel/test/infra/ftp/services/FtpService.java | 19 +-
.../test/infra/ftp/services/FtpServiceFactory.java | 23 ++-
test-infra/pom.xml | 1 +
296 files changed, 1481 insertions(+), 1760 deletions(-)
diff --git a/components/camel-ftp/pom.xml b/components/camel-ftp/pom.xml
index 6b6d5e2..b01aae4 100644
--- a/components/camel-ftp/pom.xml
+++ b/components/camel-ftp/pom.xml
@@ -166,6 +166,24 @@
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
+
+
+ <!-- test infra -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-ftp</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/BaseServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/BaseServerTestSupport.java
index 7702b89..de706a7 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/BaseServerTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/BaseServerTestSupport.java
@@ -16,30 +16,8 @@
*/
package org.apache.camel.component.file.remote;
-import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.BeforeEach;
public class BaseServerTestSupport extends CamelTestSupport {
-
protected static final String LS = System.lineSeparator();
-
- protected int port;
-
- private boolean portInitialized;
-
- @BeforeEach
- public void initPort() throws Exception {
- if (!portInitialized) {
- // call only once per test method (Some tests can call this method
- // manually in setUp method,
- // which is called before this if setUp method is overridden)
- port = AvailablePortFinder.getNextAvailable();
- portInitialized = true;
- }
- }
-
- protected int getPort() {
- return port;
- }
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/ConsumerTemplateFtpShutdownTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/ConsumerTemplateFtpShutdownTest.java
index 397365c..c55afef 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/ConsumerTemplateFtpShutdownTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/ConsumerTemplateFtpShutdownTest.java
@@ -27,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class ConsumerTemplateFtpShutdownTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/template?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/template?password=admin";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpTempFileNameTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpTempFileNameTest.java
index ef2631e..7cbab98 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpTempFileNameTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpTempFileNameTest.java
@@ -38,7 +38,7 @@ public class FileToFtpTempFileNameTest extends FtpServerTestSupport {
assertTrue(notify.matchesWaitTime());
- File file = new File(FTP_ROOT_DIR + "/out/sub/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/out/sub/hello.txt");
assertTrue(file.exists(), "File should exists " + file);
}
@@ -48,7 +48,7 @@ public class FileToFtpTempFileNameTest extends FtpServerTestSupport {
@Override
public void configure() throws Exception {
from("file://target/in?recursive=true")
- .to("ftp://admin:admin@localhost:" + getPort()
+ .to("ftp://admin:admin@localhost:{{ftp.server.port}}"
+ "/out/?fileName=${file:name}&tempFileName=${file:onlyname}.part&stepwise=false");
}
};
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersTest.java
index 44843de..4fd3a43 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersTest.java
@@ -21,7 +21,9 @@ 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;
+import org.junit.jupiter.api.TestInstance;
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersTest extends FileToFtpsExplicitSSLWithClientAuthTest {
@BindToRegistry("sslContextParameters")
@@ -47,7 +49,7 @@ public class FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersTest exte
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:" + service.getPort()
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=false&sslContextParameters=#sslContextParameters&delete=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithClientAuthTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithClientAuthTest.java
index 8ed5037..e58d0b5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithClientAuthTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithClientAuthTest.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
public class FileToFtpsExplicitSSLWithClientAuthTest extends FtpsServerExplicitSSLWithClientAuthTestSupport {
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&securityProtocol=SSLv3&implicit=false&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
+ "&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true";
@@ -34,10 +34,6 @@ public class FileToFtpsExplicitSSLWithClientAuthTest extends FtpsServerExplicitS
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersTest.java
index 8228f43..b8224bc 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParametersTest.java
@@ -46,7 +46,7 @@ public class FileToFtpsExplicitSSLWithoutClientAuthAndGlobalSSLContextParameters
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=false&delete=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersTest.java
index 233c89e..ea8071a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersTest.java
@@ -42,7 +42,7 @@ public class FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersTest
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=false&sslContextParameters=#sslContextParameters&delete=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthTest.java
index 65d4749..77940d8 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitSSLWithoutClientAuthTest.java
@@ -19,24 +19,22 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* 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 {
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true"
+ "&securityProtocol=SSLv3&implicit=false";
}
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithClientAuthAndSSLContextParametersTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithClientAuthAndSSLContextParametersTest.java
index 338d78d..515264b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithClientAuthAndSSLContextParametersTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithClientAuthAndSSLContextParametersTest.java
@@ -47,7 +47,7 @@ public class FileToFtpsExplicitTLSWithClientAuthAndSSLContextParametersTest exte
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=false&sslContextParameters=#sslContextParameters&delete=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithClientAuthTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithClientAuthTest.java
index cd4aafd..3b183c3 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithClientAuthTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithClientAuthTest.java
@@ -19,14 +19,16 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* 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 {
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&securityProtocol=TLSv1.2&implicit=false&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
+ "&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true";
@@ -34,10 +36,6 @@ public class FileToFtpsExplicitTLSWithClientAuthTest extends FtpsServerExplicitT
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithoutClientAuthAndSSLContextParametersTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithoutClientAuthAndSSLContextParametersTest.java
index 368adf4..854a839 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithoutClientAuthAndSSLContextParametersTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithoutClientAuthAndSSLContextParametersTest.java
@@ -41,7 +41,7 @@ public class FileToFtpsExplicitTLSWithoutClientAuthAndSSLContextParametersTest
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=false&sslContextParameters=#sslContextParameters&delete=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithoutClientAuthTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithoutClientAuthTest.java
index 5834906..ca4675f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithoutClientAuthTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsExplicitTLSWithoutClientAuthTest.java
@@ -19,24 +19,22 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* 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 {
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&securityProtocol=TLSv1.2&implicit=false&delete=true";
}
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithClientAuthAndSSLContextParametersTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithClientAuthAndSSLContextParametersTest.java
index 413eb53..014e720 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithClientAuthAndSSLContextParametersTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithClientAuthAndSSLContextParametersTest.java
@@ -46,7 +46,7 @@ public class FileToFtpsImplicitSSLWithClientAuthAndSSLContextParametersTest exte
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=true&sslContextParameters=#sslContextParameters&delete=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithClientAuthTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithClientAuthTest.java
index 67c584f..085d427 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithClientAuthTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithClientAuthTest.java
@@ -19,14 +19,16 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (implicit) with client authentication
*/
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsImplicitSSLWithClientAuthTest extends FtpsServerImplicitSSLWithClientAuthTestSupport {
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&securityProtocol=SSLv3&implicit=true&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
+ "&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true";
@@ -34,10 +36,6 @@ public class FileToFtpsImplicitSSLWithClientAuthTest extends FtpsServerImplicitS
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersTest.java
index f81e37e..8f8f663 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersTest.java
@@ -41,7 +41,7 @@ public class FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersTest
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=true&sslContextParameters=#sslContextParameters&delete=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithoutClientAuthTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithoutClientAuthTest.java
index 741b50e..ad382d6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithoutClientAuthTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitSSLWithoutClientAuthTest.java
@@ -19,24 +19,22 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (implicit) without client authentication
*/
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsImplicitSSLWithoutClientAuthTest extends FtpsServerImplicitSSLWithoutClientAuthTestSupport {
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&securityProtocol=SSLv3&implicit=true&delete=true";
}
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithClientAuthAndSSLContextParametersTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithClientAuthAndSSLContextParametersTest.java
index 7f1d7ad..c2d49cb 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithClientAuthAndSSLContextParametersTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithClientAuthAndSSLContextParametersTest.java
@@ -46,7 +46,7 @@ public class FileToFtpsImplicitTLSWithClientAuthAndSSLContextParametersTest exte
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=true&sslContextParameters=#sslContextParameters&delete=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithClientAuthTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithClientAuthTest.java
index 6216cc5..ea97d79 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithClientAuthTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithClientAuthTest.java
@@ -19,14 +19,16 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over TLS (implicit) with client authentication
*/
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsImplicitTLSWithClientAuthTest extends FtpsServerImplicitTLSWithClientAuthTestSupport {
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&securityProtocol=TLSv1.2&implicit=true&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
+ "&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true";
@@ -34,10 +36,6 @@ public class FileToFtpsImplicitTLSWithClientAuthTest extends FtpsServerImplicitT
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithoutClientAuthAndSSLContextParametersTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithoutClientAuthAndSSLContextParametersTest.java
index 7863c14..c799433 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithoutClientAuthAndSSLContextParametersTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithoutClientAuthAndSSLContextParametersTest.java
@@ -41,7 +41,7 @@ public class FileToFtpsImplicitTLSWithoutClientAuthAndSSLContextParametersTest
@Override
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&implicit=true&sslContextParameters=#sslContextParameters&delete=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithoutClientAuthTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithoutClientAuthTest.java
index 971d209..adbe10f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithoutClientAuthTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsImplicitTLSWithoutClientAuthTest.java
@@ -19,25 +19,22 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over TLS (implicit) without client authentication
*/
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsImplicitTLSWithoutClientAuthTest extends FtpsServerImplicitTLSWithoutClientAuthTestSupport {
protected String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&securityProtocol=TLSv1.2&implicit=true&delete=true";
}
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
-
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithCustomKeyAndTrustStorePropertiesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithCustomKeyAndTrustStorePropertiesTest.java
index 7402592..3cbd96a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithCustomKeyAndTrustStorePropertiesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithCustomKeyAndTrustStorePropertiesTest.java
@@ -19,14 +19,16 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (explicit) and without client authentication
*/
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsWithCustomKeyAndTrustStorePropertiesTest extends FtpsServerExplicitSSLWithClientAuthTestSupport {
private String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&securityProtocol=SSLv3&implicit=false&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
+ "&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password"
@@ -36,10 +38,6 @@ public class FileToFtpsWithCustomKeyAndTrustStorePropertiesTest extends FtpsServ
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithCustomTrustStorePropertiesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithCustomTrustStorePropertiesTest.java
index 09179c9..af4ee4d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithCustomTrustStorePropertiesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithCustomTrustStorePropertiesTest.java
@@ -19,14 +19,16 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (explicit) and without client authentication
*/
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsWithCustomTrustStorePropertiesTest extends FtpsServerExplicitSSLWithoutClientAuthTestSupport {
private String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
+ "&securityProtocol=SSLv3&implicit=false&ftpClient.trustStore.file=./src/test/resources/server.jks&ftpClient.trustStore.type=JKS"
+ "&ftpClient.trustStore.algorithm=SunX509&ftpClient.trustStore.password=password&delete=true";
@@ -34,10 +36,6 @@ public class FileToFtpsWithCustomTrustStorePropertiesTest extends FtpsServerExpl
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java
index f7e35b2..0c5ed81 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java
@@ -28,16 +28,12 @@ import org.junit.jupiter.api.Test;
public class FileToFtpsWithDefaultSettingsIPV6Test extends FtpsServerExplicitTLSWithoutClientAuthTestSupport {
private String getFtpUrl() {
- return "ftps://admin@[::1]:" + getPort()
+ return "ftps://admin@[::1]:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true";
}
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsTest.java
index 16b3ebc..b1855a8 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsTest.java
@@ -19,23 +19,21 @@ package org.apache.camel.component.file.remote;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over TLS (explicit) and without client authentication
*/
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsWithDefaultSettingsTest extends FtpsServerExplicitTLSWithoutClientAuthTestSupport {
private String getFtpUrl() {
- return "ftps://admin@localhost:" + getPort()
+ return "ftps://admin@localhost:{{ftp.server.port}}"
+ "/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true";
}
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithFtpClientConfigRefTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithFtpClientConfigRefTest.java
index f07eef9..a2690ac 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithFtpClientConfigRefTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithFtpClientConfigRefTest.java
@@ -21,10 +21,12 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.commons.net.ftp.FTPSClient;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
/**
* Test the ftps component over SSL (explicit) and without client authentication
*/
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.FtpsEmbeddedService#hasRequiredAlgorithms")
public class FileToFtpsWithFtpClientConfigRefTest extends FtpsServerExplicitSSLWithoutClientAuthTestSupport {
@BindToRegistry("ftpsClient")
@@ -34,17 +36,13 @@ public class FileToFtpsWithFtpClientConfigRefTest extends FtpsServerExplicitSSLW
private FTPSClient client1 = new FTPSClient("SSLv3");
private String getFtpUrl(boolean in) {
- return "ftps://admin@localhost:" + getPort() + "/tmp2/camel?password=admin&initialDelay=2000&ftpClient=#ftpsClient"
+ return "ftps://admin@localhost:{{ftp.server.port}}/tmp2/camel?password=admin&initialDelay=2000&ftpClient=#ftpsClient"
+ (in ? "In" : "")
+ "&disableSecureDataChannelDefaults=true&delete=true";
}
@Test
public void testFromFileToFtp() throws Exception {
- // some platforms cannot test SSL
- if (!canTest) {
- return;
- }
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePasswordBeanRefTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePasswordBeanRefTest.java
index 97ef6e3..bcfd0c2 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePasswordBeanRefTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePasswordBeanRefTest.java
@@ -27,7 +27,7 @@ public class FromFilePasswordBeanRefTest extends FtpServerTestSupport {
private String somename = "t%st";
protected String getFtpUrl() {
- return "ftp://localhost:" + getPort() + "/tmp3/camel?username=us@r&password=#bean:myPass&initialDelay=3000";
+ return "ftp://localhost:{{ftp.server.port}}/tmp3/camel?username=us@r&password=#bean:myPass&initialDelay=3000";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePasswordPropertyRefTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePasswordPropertyRefTest.java
index 58101be..07f0952 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePasswordPropertyRefTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePasswordPropertyRefTest.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
public class FromFilePasswordPropertyRefTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://localhost:" + getPort() + "/tmp3/camel?username=us@r&password=#property:myPass&initialDelay=3000";
+ return "ftp://localhost:{{ftp.server.port}}/tmp3/camel?username=us@r&password=#property:myPass&initialDelay=3000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordTest.java
index a465912..e749dba 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FromFilePercentSignInPasswordTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://localhost:" + getPort() + "/tmp3/camel?username=us@r&password=t%25st&initialDelay=3000";
+ return "ftp://localhost:{{ftp.server.port}}/tmp3/camel?username=us@r&password=t%25st&initialDelay=3000";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoEncodedTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoEncodedTest.java
index 0801087..3103b9a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoEncodedTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoEncodedTest.java
@@ -20,7 +20,7 @@ public class FromFilePercentSignInPasswordUserInfoEncodedTest extends FromFilePe
@Override
protected String getFtpUrl() {
- return "ftp://us%40r:t%25st@localhost:" + getPort() + "/tmp3/camel?initialDelay=3000";
+ return "ftp://us%40r:t%25st@localhost:{{ftp.server.port}}/tmp3/camel?initialDelay=3000";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoTest.java
index bec5ea1..dc3895a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoTest.java
@@ -23,7 +23,7 @@ public class FromFilePercentSignInPasswordUserInfoTest extends FromFilePercentSi
// the user info is not encoded, but we should be forgiving and allow
// the user to use
// the user name and password out of the box as is
- return "ftp://us@r:t%st@localhost:" + getPort() + "/tmp3/camel?initialDelay=3000";
+ return "ftp://us@r:t%st@localhost:{{ftp.server.port}}/tmp3/camel?initialDelay=3000";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDefaultRootRenameStrategyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDefaultRootRenameStrategyTest.java
index a11c898..989ad18 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDefaultRootRenameStrategyTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDefaultRootRenameStrategyTest.java
@@ -43,7 +43,7 @@ public class FromFileToFtpDefaultRootRenameStrategyTest extends FtpServerTestSup
* strategy
*/
private String getFtpPollingUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "?password=admin&delete=true&binary=true&delay=1000&initialDelay=1500&readLock=rename";
}
@@ -51,12 +51,12 @@ public class FromFileToFtpDefaultRootRenameStrategyTest extends FtpServerTestSup
* we use this URL to write out our binary test file to begin with
*/
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&binary=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&binary=true";
}
@Test
public void testFromFileToFtp() throws Exception {
- File expectedOnFtpServer = new File(FTP_ROOT_DIR + "/logo.jpeg");
+ File expectedOnFtpServer = new File(service.getFtpRootDir() + "/logo.jpeg");
// the poller won't start for 1.5 seconds, so we check to make sure the
// file
// is there first check 1 - is the file there (default root location)
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDeleteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDeleteTest.java
index 0e2cb1a..c42ee9e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDeleteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpDeleteTest.java
@@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFileToFtpDeleteTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin";
}
@Test
@@ -50,7 +50,7 @@ public class FromFileToFtpDeleteTest extends FtpServerTestSupport {
assertFalse(file.exists(), "File should be deleted");
// file should exists on ftp server
- file = new File(FTP_ROOT_DIR + "/hello.txt");
+ file = new File(service.getFtpRootDir() + "/hello.txt");
assertTrue(file.exists(), "File should exist on ftp server");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpNotStepwiseTest.java
index ce77297..3ddc751 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpNotStepwiseTest.java
@@ -20,7 +20,7 @@ public class FromFileToFtpNotStepwiseTest extends FromFileToFtpTest {
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp2/camel?password=admin&initialDelay=3000&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp2/camel?password=admin&initialDelay=3000&stepwise=false";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpTest.java
index 63a506c..71ab8e5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FromFileToFtpTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp2/camel?password=admin&initialDelay=3000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp2/camel?password=admin&initialDelay=3000";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpWithChmodTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpWithChmodTest.java
index 7d327e9..46779ae 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpWithChmodTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpWithChmodTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FromFileToFtpWithChmodTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp2/camel?password=admin&initialDelay=3000&chmod=777";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp2/camel?password=admin&initialDelay=3000&chmod=777";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileTransferLoggingLevelTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileTransferLoggingLevelTest.java
index 3b7ec52..68165ce 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileTransferLoggingLevelTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileTransferLoggingLevelTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FromFileTransferLoggingLevelTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp2/camel?password=admin&transferLoggingLevel=INFO";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp2/camel?password=admin&transferLoggingLevel=INFO";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileTransferLoggingLevelVerboseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileTransferLoggingLevelVerboseTest.java
index 12def81..b4f0ff8 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileTransferLoggingLevelVerboseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileTransferLoggingLevelVerboseTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FromFileTransferLoggingLevelVerboseTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/tmp3/camel?password=admin&transferLoggingLevel=INFO&transferLoggingVerbose=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpActivePortRangeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpActivePortRangeTest.java
index 783b09f..5501584 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpActivePortRangeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpActivePortRangeTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpActivePortRangeTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/portrange/?password=admin&activePortRange=10000-19999";
+ return "ftp://admin@localhost:{{ftp.server.port}}/portrange/?password=admin&activePortRange=10000-19999";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpAsyncProcessTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpAsyncProcessTest.java
index 4cc010f..7735827 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpAsyncProcessTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpAsyncProcessTest.java
@@ -34,13 +34,14 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
public class FromFtpAsyncProcessTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/async/?password=admin&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/async/?password=admin&delete=true";
}
@Test
public void testFtpAsyncProcess() throws Exception {
- template.sendBodyAndHeader("file:" + FTP_ROOT_DIR + "/async", "Hello World", Exchange.FILE_NAME, "hello.txt");
- template.sendBodyAndHeader("file:" + FTP_ROOT_DIR + "/async", "Bye World", Exchange.FILE_NAME, "bye.txt");
+ template.sendBodyAndHeader("file:" + service.getFtpRootDir() + "/async", "Hello World", Exchange.FILE_NAME,
+ "hello.txt");
+ template.sendBodyAndHeader("file:" + service.getFtpRootDir() + "/async", "Bye World", Exchange.FILE_NAME, "bye.txt");
getMockEndpoint("mock:result").expectedMessageCount(2);
getMockEndpoint("mock:result").expectedHeaderReceived("foo", 123);
@@ -57,10 +58,10 @@ public class FromFtpAsyncProcessTest extends FtpServerTestSupport {
// give time for files to be deleted on ftp server
Thread.sleep(1000);
- File hello = new File(FTP_ROOT_DIR + "/async/hello.txt");
+ File hello = new File(service.getFtpRootDir() + "/async/hello.txt");
assertFalse(hello.exists(), "File should not exist " + hello);
- File bye = new File(FTP_ROOT_DIR + "/async/bye.txt");
+ File bye = new File(service.getFtpRootDir() + "/async/bye.txt");
assertFalse(bye.exists(), "File should not exist " + bye);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java
index 66f642d..62eed9d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientConfigRefTest.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpClientConfigRefTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/timeout/?password=admin&ftpClientConfig=#myConfig";
+ return "ftp://admin@localhost:{{ftp.server.port}}/timeout/?password=admin&ftpClientConfig=#myConfig";
}
@BindToRegistry("myConfig")
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
index 7fbc57f..137e9ee 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientDataTimeoutTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpClientDataTimeoutTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/timeout/?password=admin&ftpClient.dataTimeout=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/timeout/?password=admin&ftpClient.dataTimeout=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeout2Test.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeout2Test.java
index b70291f..baf64f5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeout2Test.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeout2Test.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpClientSoTimeout2Test extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/timeout/?password=admin&soTimeout=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/timeout/?password=admin&soTimeout=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeout3Test.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeout3Test.java
index 1c9509e..6e59ab7 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeout3Test.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeout3Test.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
public class FromFtpClientSoTimeout3Test extends CamelTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/timeout/?soTimeout=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/timeout/?soTimeout=5000";
}
private String getPort() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeoutTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeoutTest.java
index 14e62be..9112faa 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeoutTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpClientSoTimeoutTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpClientSoTimeoutTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/timeout/?password=admin&ftpClient.soTimeout=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/timeout/?password=admin&ftpClient.soTimeout=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpConsumerTemplateRollbackTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpConsumerTemplateRollbackTest.java
index 1609522..9b88515 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpConsumerTemplateRollbackTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpConsumerTemplateRollbackTest.java
@@ -33,13 +33,13 @@ import static org.junit.jupiter.api.Assertions.fail;
public class FromFtpConsumerTemplateRollbackTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/deletefile?password=admin&binary=false&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/deletefile?password=admin&binary=false&delete=true";
}
protected String getFtpUrlInvalid() {
// use invalid starting directory and do not allow creating it so we
// force the poll to fail
- return "ftp://admin@localhost:" + getPort() + "/unknown?password=admin&binary=false&delete=true&autoCreate=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/unknown?password=admin&binary=false&delete=true&autoCreate=false";
}
@Override
@@ -74,7 +74,7 @@ public class FromFtpConsumerTemplateRollbackTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/deletefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/deletefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpConsumerTemplateTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpConsumerTemplateTest.java
index e3ad42c..bfcef76 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpConsumerTemplateTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpConsumerTemplateTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpConsumerTemplateTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/deletefile?password=admin&binary=false&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/deletefile?password=admin&binary=false&delete=true";
}
@Override
@@ -47,7 +47,7 @@ public class FromFtpConsumerTemplateTest extends FtpServerTestSupport {
assertEquals("Hello World this file will be deleted", body);
// assert the file is deleted
- File file = new File(FTP_ROOT_DIR + "/deletefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/deletefile/hello.txt");
assertFalse(file.exists(), "The file should have been deleted");
}
@@ -65,7 +65,7 @@ public class FromFtpConsumerTemplateTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/deletefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/deletefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileNotStepwiseTest.java
index a2afcc9..406ba69 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileNotStepwiseTest.java
@@ -23,6 +23,6 @@ public class FromFtpDeleteFileNotStepwiseTest extends FromFtpDeleteFileTest {
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/deletefile?password=admin&binary=false&delete=true&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/deletefile?password=admin&binary=false&delete=true&stepwise=false";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
index ecb4c09..64015c6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
@@ -23,7 +23,7 @@ public class FromFtpDeleteFileScottTigerTest extends FromFtpDeleteFileTest {
@Override
protected String getFtpUrl() {
- return "ftp://scott:tiger@localhost:" + getPort() + "/deletefile?binary=false&delete=true";
+ return "ftp://scott:tiger@localhost:{{ftp.server.port}}/deletefile?binary=false&delete=true";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java
index a1d4d42..b10472d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java
@@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpDeleteFileTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/deletefile?password=admin&binary=false&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/deletefile?password=admin&binary=false&delete=true";
}
@Override
@@ -56,7 +56,7 @@ public class FromFtpDeleteFileTest extends FtpServerTestSupport {
Thread.sleep(500);
// assert the file is deleted
- File file = new File(FTP_ROOT_DIR + "/deletefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/deletefile/hello.txt");
assertFalse(file.exists(), "The file should have been deleted");
}
@@ -74,7 +74,7 @@ public class FromFtpDeleteFileTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/deletefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/deletefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesNotStepwiseTest.java
index b9c1b12..7cf3a58 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesNotStepwiseTest.java
@@ -23,7 +23,7 @@ package org.apache.camel.component.file.remote;
public class FromFtpDirectoryToBinaryFilesNotStepwiseTest extends FromFtpDirectoryToBinaryFilesTest {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/incoming/?password=admin"
+ return "ftp://admin@localhost:{{ftp.server.port}}/incoming/?password=admin"
+ "&binary=true&useFixedDelay=false&recursive=false&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesTest.java
index a77e1e4..db65110 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDirectoryToBinaryFilesTest.java
@@ -22,6 +22,9 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.converter.IOConverter;
+import org.apache.camel.util.FileUtil;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -33,29 +36,37 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* path. Based on CAMEL-834.
*/
public class FromFtpDirectoryToBinaryFilesTest extends FtpServerTestSupport {
- private File logoFile;
- private long logoFileSize;
- private File logo1File;
- private long logo1FileSize;
+ private static File logoFile;
+ private static long logoFileSize;
+ private static File logo1File;
+ private static long logo1FileSize;
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/incoming/?password=admin"
+ return "ftp://admin@localhost:{{ftp.server.port}}/incoming/?password=admin"
+ "&binary=true&useFixedDelay=false&recursive=false&delay=5000";
}
- @Override
- @BeforeEach
- public void setUp() throws Exception {
- super.setUp();
-
+ @BeforeAll
+ public static void gatherFileInfo() {
logoFile = IOConverter.toFile("src/test/data/ftpbinarytest/logo.jpeg");
logoFileSize = logoFile.length();
logo1File = IOConverter.toFile("src/test/data/ftpbinarytest/logo1.jpeg");
logo1FileSize = logo1File.length();
+ }
- prepareFtpServer();
+ @BeforeEach
+ public void prepareFtpServer() throws Exception {
+ // prepares the FTP Server by creating a file on the server that we want
+ // to unit
+ // test that we can pool and store as a local file
+ template.sendBodyAndHeader(getFtpUrl(), logoFile, Exchange.FILE_NAME, "logo.jpeg");
+ template.sendBodyAndHeader(getFtpUrl(), logo1File, Exchange.FILE_NAME, "logo1.jpeg");
+ }
+ @AfterEach
+ public void cleanup() {
+ FileUtil.removeDir(new File("target/ftptest/"));
}
@Test
@@ -66,27 +77,20 @@ public class FromFtpDirectoryToBinaryFilesTest extends FtpServerTestSupport {
Exchange ex = resultEndpoint.getExchanges().get(0);
byte[] bytes = ex.getIn().getBody(byte[].class);
- assertTrue(bytes.length > 10000, "Logo size wrong: " + bytes.length);
+ assertTrue(bytes.length > 10000, "Logo size is only: " + bytes.length
+ + " but should have been bigger than 10000");
// assert the file
- File logo1DestFile = new File("target/ftptest/logo1.jpeg");
+ File logo1DestFile = new File("target/ftptest/", "logo1.jpeg");
assertTrue(logo1DestFile.exists(), "The binary file should exists");
assertEquals(logo1FileSize, logo1DestFile.length(), "File size for logo1.jpg does not match");
// assert the file
- File logoDestFile = new File("target/ftptest/logo.jpeg");
+ File logoDestFile = new File("target/ftptest", "logo.jpeg");
assertTrue(logoDestFile.exists(), " The binary file should exists");
assertEquals(logoFileSize, logoDestFile.length(), "File size for logo1.jpg does not match");
}
- private void prepareFtpServer() throws Exception {
- // prepares the FTP Server by creating a file on the server that we want
- // to unit
- // test that we can pool and store as a local file
- template.sendBodyAndHeader(getFtpUrl(), logoFile, Exchange.FILE_NAME, "logo.jpeg");
- template.sendBodyAndHeader(getFtpUrl(), logo1File, Exchange.FILE_NAME, "logo1.jpeg");
- }
-
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDoNotDeleteFileIfProcessFailsTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDoNotDeleteFileIfProcessFailsTest.java
index 3616430..5f1c2f6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDoNotDeleteFileIfProcessFailsTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDoNotDeleteFileIfProcessFailsTest.java
@@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpDoNotDeleteFileIfProcessFailsTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/deletefile/?password=admin&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/deletefile/?password=admin&delete=true";
}
@Override
@@ -54,7 +54,7 @@ public class FromFtpDoNotDeleteFileIfProcessFailsTest extends FtpServerTestSuppo
Thread.sleep(200);
// assert the file is deleted
- File file = new File(FTP_ROOT_DIR + "/deletefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/deletefile/hello.txt");
assertTrue(file.exists(), "The file should NOT have been deleted");
}
@@ -72,7 +72,7 @@ public class FromFtpDoNotDeleteFileIfProcessFailsTest extends FtpServerTestSuppo
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/deletefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/deletefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java
index 1a0a034..9b19759 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadNoneStrategyTest.java
@@ -42,7 +42,7 @@ public class FromFtpExclusiveReadNoneStrategyTest extends FtpServerTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(FromFtpExclusiveReadNoneStrategyTest.class);
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/slowfile?password=admin" + "&readLock=none&delay=500";
+ return "ftp://admin@localhost:{{ftp.server.port}}/slowfile?password=admin" + "&readLock=none&delay=500";
}
// Cannot test on windows due file system works differently with file locks
@@ -59,8 +59,8 @@ public class FromFtpExclusiveReadNoneStrategyTest extends FtpServerTestSupport {
});
context.start();
- deleteDirectory(FTP_ROOT_DIR);
- createDirectory(FTP_ROOT_DIR + "/slowfile");
+ deleteDirectory(service.getFtpRootDir());
+ createDirectory(service.getFtpRootDir() + "/slowfile");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -84,7 +84,7 @@ public class FromFtpExclusiveReadNoneStrategyTest extends FtpServerTestSupport {
@Override
public void process(Exchange exchange) throws Exception {
LOG.info("Creating a slow file ...");
- File file = new File(FTP_ROOT_DIR + "/slowfile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/slowfile/hello.txt");
FileOutputStream fos = new FileOutputStream(file);
FileLock lock = fos.getChannel().lock();
fos.write("Hello World".getBytes());
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterNotStepwiseTest.java
index 884efb5..bf5030a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterNotStepwiseTest.java
@@ -23,6 +23,6 @@ public class FromFtpFilterNotStepwiseTest extends FromFtpFilterTest {
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/filter?password=admin&binary=false&filter=#myFilter&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/filter?password=admin&binary=false&filter=#myFilter&stepwise=false";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java
index 0f6e5f6..4082b60 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpFilterTest.java
@@ -32,7 +32,7 @@ public class FromFtpFilterTest extends FtpServerTestSupport {
private MyFileFilter filter = new MyFileFilter<>();
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/filter?password=admin&binary=false&filter=#myFilter";
+ return "ftp://admin@localhost:{{ftp.server.port}}/filter?password=admin&binary=false&filter=#myFilter";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedNotStepwiseTest.java
index 75096ca..24f1409 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpKeepLastModifiedNotStepwiseTest extends FromFtpKeepLastModif
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/keep?password=admin&binary=false&noop=true&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/keep?password=admin&binary=false&noop=true&stepwise=false";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedTest.java
index f1bae05..889c040 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedTest.java
@@ -33,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertNotSame;
public class FromFtpKeepLastModifiedTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/keep?password=admin&binary=false&noop=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/keep?password=admin&binary=false&noop=true";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveNotStepwiseTest.java
index 9acfff1..ad36f8a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpMoveFileAbsoluteFolderRecursiveNotStepwiseTest extends FromF
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&recursive=true&binary=false"
+ "&move=/.done/${file:name}.old&initialDelay=2500&delay=5000&stepwise=false";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveTest.java
index eeea70e..8c287ee 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileAbsoluteFolderRecursiveTest.java
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpMoveFileAbsoluteFolderRecursiveTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&recursive=true&binary=false"
+ "&move=/.done/${file:name}.old&initialDelay=2500&delay=5000";
}
@@ -43,9 +43,9 @@ public class FromFtpMoveFileAbsoluteFolderRecursiveTest extends FtpServerTestSup
public void testPollFileAndShouldBeMoved() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/hello.txt.old");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/bye/bye.txt.old");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/goodday/goodday.txt.old");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/hello.txt.old");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/bye/bye.txt.old");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/goodday/goodday.txt.old");
mock.assertIsSatisfied();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileNotStepwiseTest.java
index 9e7b9a1..7bfe4a9 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpMoveFileNotStepwiseTest extends FromFtpMoveFileTest {
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false"
+ "&move=done/sub2/${file:name}.old&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixNotStepwiseTest.java
index b632070..d62742e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpMoveFilePostfixNotStepwiseTest extends FromFtpMoveFilePostfi
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false"
+ "&move=${file:name}.old&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java
index aea7173..067f852 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpMoveFilePostfixTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false"
+ "&move=${file:name}.old&delay=5000";
}
@@ -50,7 +50,7 @@ public class FromFtpMoveFilePostfixTest extends FtpServerTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Hello World this file will be moved");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/hello.txt.old");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/hello.txt.old");
mock.assertIsSatisfied();
}
@@ -69,7 +69,7 @@ public class FromFtpMoveFilePostfixTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/movefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixNotStepwiseTest.java
index 03bc0f5..f1990a0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpMoveFilePrefixNotStepwiseTest extends FromFtpMoveFilePrefixT
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false&delay=5000"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false&delay=5000"
+ "&move=done/${file:name}&stepwise=false";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java
index 9b7e5fc..437a6f5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpMoveFilePrefixTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false&delay=5000"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false&delay=5000"
+ "&move=done/${file:name}";
}
@@ -50,7 +50,7 @@ public class FromFtpMoveFilePrefixTest extends FtpServerTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Hello World this file will be moved");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/done/hello.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/done/hello.txt");
mock.assertIsSatisfied();
}
@@ -69,7 +69,7 @@ public class FromFtpMoveFilePrefixTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/movefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileRecursiveNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileRecursiveNotStepwiseTest.java
index f1eb300..fe719f9 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileRecursiveNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileRecursiveNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpMoveFileRecursiveNotStepwiseTest extends FromFtpMoveFileRecu
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&recursive=true&binary=false"
+ "&move=.done/${file:name}.old&initialDelay=2500&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileRecursiveTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileRecursiveTest.java
index da51def..46da5fb 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileRecursiveTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileRecursiveTest.java
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpMoveFileRecursiveTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&recursive=true&binary=false"
+ "&move=.done/${file:name}.old&initialDelay=2500&delay=5000";
}
@@ -43,9 +43,9 @@ public class FromFtpMoveFileRecursiveTest extends FtpServerTestSupport {
public void testPollFileAndShouldBeMoved() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/.done/hello.txt.old");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/.done/bye/bye.txt.old");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/.done/goodday/goodday.txt.old");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/.done/hello.txt.old");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/.done/bye/bye.txt.old");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/.done/goodday/goodday.txt.old");
mock.assertIsSatisfied();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java
index 33fccc0..2b3611e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpMoveFileTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false"
+ "&move=done/sub2/${file:name}.old&delay=5000";
}
@@ -50,7 +50,7 @@ public class FromFtpMoveFileTest extends FtpServerTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Hello World this file will be moved");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/done/sub2/hello.txt.old");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/done/sub2/hello.txt.old");
mock.assertIsSatisfied();
}
@@ -69,7 +69,7 @@ public class FromFtpMoveFileTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/movefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileToHiddenFolderRecursiveNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileToHiddenFolderRecursiveNotStepwiseTest.java
index cad848c..586d017 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileToHiddenFolderRecursiveNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileToHiddenFolderRecursiveNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpMoveFileToHiddenFolderRecursiveNotStepwiseTest extends FromF
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&recursive=true&binary=false"
+ "&move=${file:parent}/.done/${file:onlyname}&initialDelay=3000&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileToHiddenFolderRecursiveTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileToHiddenFolderRecursiveTest.java
index f9e1426..94de726 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileToHiddenFolderRecursiveTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileToHiddenFolderRecursiveTest.java
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpMoveFileToHiddenFolderRecursiveTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&recursive=true&binary=false"
+ "&move=${file:parent}/.done/${file:onlyname}&initialDelay=3000&delay=5000";
}
@@ -43,9 +43,9 @@ public class FromFtpMoveFileToHiddenFolderRecursiveTest extends FtpServerTestSup
public void testPollFileAndShouldBeMoved() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/hello.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/bye/.done/bye.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/goodday/.done/goodday.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/hello.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/bye/.done/bye.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/goodday/.done/goodday.txt");
mock.assertIsSatisfied();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest.java
index 3623d9b..241892e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest.java
@@ -21,7 +21,7 @@ public class FromFtpNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&recursive=true&binary=false"
+ "&move=/.done/${file:name}&initialDelay=2500&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteTest.java
index e10250f..97ba4d6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoEndpointPathRelativeMoveToAbsoluteTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpNoEndpointPathRelativeMoveToAbsoluteTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&recursive=true&binary=false"
+ "&move=/.done/${file:name}&initialDelay=2500&delay=5000";
}
@@ -40,9 +40,9 @@ public class FromFtpNoEndpointPathRelativeMoveToAbsoluteTest extends FtpServerTe
public void testPollFileAndShouldBeMoved() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/hello.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/sub/bye.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/sub/sub2/goodday.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/hello.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/sub/bye.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/sub/sub2/goodday.txt");
mock.assertIsSatisfied();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java
index 0cc43b5..8ae379a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java
@@ -29,13 +29,13 @@ import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
public class FromFtpNoFilesTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/slowfile?password=admin&binary=false&readLock=rename&delay=2000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/slowfile?password=admin&binary=false&readLock=rename&delay=2000";
}
@Test
public void testPoolIn3SecondsButNoFiles() throws Exception {
- deleteDirectory(FTP_ROOT_DIR);
- createDirectory(FTP_ROOT_DIR + "slowfile");
+ deleteDirectory(service.getFtpRootDir());
+ createDirectory(service.getFtpRootDir() + "slowfile");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(0);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopAccountTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopAccountTest.java
index 7ff8e8f..20a20bf 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopAccountTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopAccountTest.java
@@ -23,7 +23,7 @@ public class FromFtpNoopAccountTest extends FromFtpNoopTest {
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/noop?password=admin&account=me&binary=false&noop=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/noop?password=admin&account=me&binary=false&noop=true";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopIdempotentFalseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopIdempotentFalseTest.java
index ccf8f8a..4d2ddae 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopIdempotentFalseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopIdempotentFalseTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpNoopIdempotentFalseTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/noop?password=admin&binary=false&noop=true&idempotent=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/noop?password=admin&binary=false&noop=true&idempotent=false";
}
@Override
@@ -53,7 +53,7 @@ public class FromFtpNoopIdempotentFalseTest extends FtpServerTestSupport {
mock.assertIsSatisfied();
// assert the file is still there
- File file = new File(FTP_ROOT_DIR + "/noop/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/noop/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java
index b9f422b..69d921d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoopTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpNoopTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/noop?password=admin&binary=false&noop=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/noop?password=admin&binary=false&noop=true";
}
@Override
@@ -54,7 +54,7 @@ public class FromFtpNoopTest extends FtpServerTestSupport {
mock.assertIsSatisfied();
// assert the file is still there
- File file = new File(FTP_ROOT_DIR + "/noop/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/noop/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNotDownloadTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNotDownloadTest.java
index 3806eff..eff4715 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNotDownloadTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNotDownloadTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
public class FromFtpNotDownloadTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/download?password=admin&noop=true&download=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/download?password=admin&noop=true&download=false";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPassiveModeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPassiveModeTest.java
index 1441de7..9d0f9cf 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPassiveModeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPassiveModeTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpPassiveModeTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/passive/?password=admin&passiveMode=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/passive/?password=admin&passiveMode=true";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPollFileOnlyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPollFileOnlyTest.java
index 7ec915d..1342a0d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPollFileOnlyTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPollFileOnlyTest.java
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpPollFileOnlyTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/fileonly/?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/fileonly/?password=admin";
}
@Override
@@ -53,7 +53,7 @@ public class FromFtpPollFileOnlyTest extends FtpServerTestSupport {
// to unit
// test that we can pool and store as a local file
Endpoint endpoint
- = context.getEndpoint("ftp://admin@localhost:" + getPort() + "/fileonly/?password=admin&binary=false");
+ = context.getEndpoint("ftp://admin@localhost:{{ftp.server.port}}/fileonly/?password=admin&binary=false");
Exchange exchange = endpoint.createExchange();
exchange.getIn().setBody("Hello World from FTPServer");
exchange.getIn().setHeader(Exchange.FILE_NAME, "report.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveDeleteNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveDeleteNotStepwiseTest.java
index 1d503be..e321a45 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveDeleteNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveDeleteNotStepwiseTest.java
@@ -23,6 +23,6 @@ public class FromFtpPreMoveDeleteNotStepwiseTest extends FromFtpPreMoveDeleteTes
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&preMove=work&delete=true&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&preMove=work&delete=true&stepwise=false";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveDeleteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveDeleteTest.java
index 61edca8..2fd1543 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveDeleteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveDeleteTest.java
@@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpPreMoveDeleteTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&preMove=work&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&preMove=work&delete=true";
}
@Override
@@ -56,7 +56,7 @@ public class FromFtpPreMoveDeleteTest extends FtpServerTestSupport {
// and file should be deleted
Thread.sleep(1000);
- File file = new File(FTP_ROOT_DIR + "/movefile/work/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/work/hello.txt");
assertFalse(file.exists(), "The file should have been deleted");
}
@@ -81,7 +81,7 @@ public class FromFtpPreMoveDeleteTest extends FtpServerTestSupport {
from(getFtpUrl()).process(new Processor() {
public void process(Exchange exchange) throws Exception {
// assert the file is pre moved
- File file = new File(FTP_ROOT_DIR + "/movefile/work/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/work/hello.txt");
assertTrue(file.exists(), "The file should have been moved");
}
}).to("mock:result");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java
index 1043d43..696845a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFileExpressionTest.java
@@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpPreMoveFileExpressionTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false&delay=5000"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false&delay=5000"
+ "&preMove=../inprogress/${file:name.noext}.bak";
}
@@ -69,7 +69,7 @@ public class FromFtpPreMoveFileExpressionTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/movefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
@@ -80,7 +80,7 @@ public class FromFtpPreMoveFileExpressionTest extends FtpServerTestSupport {
from(getFtpUrl()).process(new Processor() {
public void process(Exchange exchange) throws Exception {
// assert the file is pre moved
- File file = new File(FTP_ROOT_DIR + "/inprogress/hello.bak");
+ File file = new File(service.getFtpRootDir() + "/inprogress/hello.bak");
assertTrue(file.exists(), "The file should have been moved");
}
}).to("mock:result");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixNotStepwiseTest.java
index 2215750..40a7c4f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpPreMoveFilePostfixNotStepwiseTest extends FromFtpPreMoveFile
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false"
+ "&preMove=${file:name}.old&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java
index 5cfea02..2412b8a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePostfixTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpPreMoveFilePostfixTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false" + "&preMove=${file:name}.old";
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false&preMove=${file:name}.old";
}
@Override
@@ -53,7 +53,7 @@ public class FromFtpPreMoveFilePostfixTest extends FtpServerTestSupport {
mock.assertIsSatisfied();
// assert the file is moved
- File file = new File(FTP_ROOT_DIR + "/movefile/hello.txt.old");
+ File file = new File(service.getFtpRootDir() + "/movefile/hello.txt.old");
assertTrue(file.exists(), "The file should have been moved");
}
@@ -71,7 +71,7 @@ public class FromFtpPreMoveFilePostfixTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/movefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixNotStepwiseTest.java
index 5efdf0d..9d0bad1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpPreMoveFilePrefixNotStepwiseTest extends FromFtpPreMoveFileP
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false&delay=5000"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false&delay=5000"
+ "&preMove=done/${file:name}&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java
index 2254ff2..f4555c9 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveFilePrefixTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpPreMoveFilePrefixTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&binary=false&delay=5000"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&binary=false&delay=5000"
+ "&preMove=done/${file:name}";
}
@@ -54,7 +54,7 @@ public class FromFtpPreMoveFilePrefixTest extends FtpServerTestSupport {
mock.assertIsSatisfied();
// assert the file is moved
- File file = new File(FTP_ROOT_DIR + "/movefile/done/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/done/hello.txt");
assertTrue(file.exists(), "The file should have been moved");
}
@@ -72,7 +72,7 @@ public class FromFtpPreMoveFilePrefixTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/movefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveNoopNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveNoopNotStepwiseTest.java
index 130096e..557d543 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveNoopNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveNoopNotStepwiseTest.java
@@ -23,7 +23,7 @@ public class FromFtpPreMoveNoopNotStepwiseTest extends FromFtpPreMoveNoopTest {
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&preMove=work&noop=true&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&preMove=work&noop=true&stepwise=false";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveNoopTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveNoopTest.java
index dd395b0..1d20624 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveNoopTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpPreMoveNoopTest.java
@@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpPreMoveNoopTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&preMove=work&noop=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&preMove=work&noop=true";
}
@Override
@@ -55,7 +55,7 @@ public class FromFtpPreMoveNoopTest extends FtpServerTestSupport {
// and file should be kept there
Thread.sleep(1000);
- File file = new File(FTP_ROOT_DIR + "/movefile/work/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/work/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
@@ -80,7 +80,7 @@ public class FromFtpPreMoveNoopTest extends FtpServerTestSupport {
from(getFtpUrl()).process(new Processor() {
public void process(Exchange exchange) throws Exception {
// assert the file is pre moved
- File file = new File(FTP_ROOT_DIR + "/movefile/work/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/movefile/work/hello.txt");
assertTrue(file.exists(), "The file should have been moved");
}
}).to("mock:result");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNoopNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNoopNotStepwiseTest.java
index c2b7e6e..3cdccbb 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNoopNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNoopNotStepwiseTest.java
@@ -20,7 +20,7 @@ public class FromFtpRecursiveNoopNotStepwiseTest extends FromFtpRecursiveNoopTes
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/noop?password=admin&binary=false&initialDelay=3000"
+ return "ftp://admin@localhost:{{ftp.server.port}}/noop?password=admin&binary=false&initialDelay=3000"
+ "&recursive=true&noop=true&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNoopTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNoopTest.java
index 9758130..208888b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNoopTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNoopTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpRecursiveNoopTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/noop?password=admin&binary=false&initialDelay=3000"
+ return "ftp://admin@localhost:{{ftp.server.port}}/noop?password=admin&binary=false&initialDelay=3000"
+ "&recursive=true&noop=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNotStepwiseNoBasePathTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNotStepwiseNoBasePathTest.java
index 710d26f..d274b7e 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNotStepwiseNoBasePathTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRecursiveNotStepwiseNoBasePathTest.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpRecursiveNotStepwiseNoBasePathTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&initialDelay=3000&stepwise=false" + "&recursive=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&initialDelay=3000&stepwise=false&recursive=true";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java
index a71fe60..f4bbfcf 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRegexPatternTest.java
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpRegexPatternTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/regexp?password=admin&include=report.*";
+ return "ftp://admin@localhost:{{ftp.server.port}}/regexp?password=admin&include=report.*";
}
@Override
@@ -50,7 +50,7 @@ public class FromFtpRegexPatternTest extends FtpServerTestSupport {
// prepares the FTP Server by creating files on the server that we want
// to unit
// test that we can pool and store as a local file
- String ftpUrl = "ftp://admin@localhost:" + getPort() + "/regexp/?password=admin";
+ String ftpUrl = "ftp://admin@localhost:{{ftp.server.port}}/regexp/?password=admin";
template.sendBodyAndHeader(ftpUrl, "Hello World", Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeader(ftpUrl, "Reports", Exchange.FILE_NAME, "report1.txt");
template.sendBodyAndHeader(ftpUrl, "Bye World", Exchange.FILE_NAME, "bye.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterDirectoryTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterDirectoryTest.java
index 5c6171f..c9838d0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterDirectoryTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterDirectoryTest.java
@@ -35,7 +35,7 @@ public class FromFtpRemoteFileFilterDirectoryTest extends FtpServerTestSupport {
private MyFileFilter filter = new MyFileFilter<>();
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/filefilter?password=admin&recursive=true&filter=#myFilter";
+ return "ftp://admin@localhost:{{ftp.server.port}}/filefilter?password=admin&recursive=true&filter=#myFilter";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java
index 34acc6f..bb84cc9 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileFilterTest.java
@@ -35,7 +35,7 @@ public class FromFtpRemoteFileFilterTest extends FtpServerTestSupport {
private MyFileFilter filter = new MyFileFilter<>();
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/filefilter?password=admin&filter=#myFilter";
+ return "ftp://admin@localhost:{{ftp.server.port}}/filefilter?password=admin&filter=#myFilter";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java
index 471dfac..97604e4 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByExpressionTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpRemoteFileSortByExpressionTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/sortby?password=admin&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/sortby?password=admin&delay=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java
index eaad39c..3654d83 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByIgnoreCaseExpressionTest.java
@@ -20,14 +20,16 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
/**
* Unit test to verify remotefile sortby option.
*/
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class FromFtpRemoteFileSortByIgnoreCaseExpressionTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/sortbyignore?password=admin&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/sortbyignore?password=admin&delay=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByNestedExpressionTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByNestedExpressionTest.java
index f9e39f2..9cd93c2 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByNestedExpressionTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSortByNestedExpressionTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpRemoteFileSortByNestedExpressionTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/sortbynested?password=admin&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/sortbynested?password=admin&delay=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSorterTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSorterTest.java
index fe43431..4d63984 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSorterTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpRemoteFileSorterTest.java
@@ -33,7 +33,7 @@ public class FromFtpRemoteFileSorterTest extends FtpServerTestSupport {
private MyRemoteFileSorter sorter = new MyRemoteFileSorter();
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/sorter?password=admin&sorter=#mySorter";
+ return "ftp://admin@localhost:{{ftp.server.port}}/sorter?password=admin&sorter=#mySorter";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSedaDeleteFileTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSedaDeleteFileTest.java
index 9a1924a..d7ea0b0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSedaDeleteFileTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSedaDeleteFileTest.java
@@ -35,14 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpSedaDeleteFileTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/deletefile?password=admin&binary=false&delete=true";
- }
-
- @Override
- @BeforeEach
- public void setUp() throws Exception {
- super.setUp();
- prepareFtpServer();
+ return "ftp://admin@localhost:{{ftp.server.port}}/deletefile?password=admin&binary=false&delete=true";
}
@Test
@@ -56,10 +49,11 @@ public class FromFtpSedaDeleteFileTest extends FtpServerTestSupport {
Thread.sleep(500);
// assert the file is deleted
- File file = new File(FTP_ROOT_DIR + "/deletefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/deletefile/hello.txt");
assertFalse(file.exists(), "The file should have been deleted");
}
+ @BeforeEach
private void prepareFtpServer() throws Exception {
// prepares the FTP Server by creating a file on the server that we want
// to unit
@@ -74,7 +68,7 @@ public class FromFtpSedaDeleteFileTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/deletefile/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/deletefile/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java
index 0ce9ebc..ca52a28 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeAndTimeoutTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpServerLanguageCodeAndTimeoutTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/codetimeout/?password=admin&ftpClientConfig.serverLanguageCode=fr&ftpClient.dataTimeout=4000";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java
index c90aa5e..1db5a00 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpServerLanguageCodeTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpServerLanguageCodeTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/code/?password=admin&ftpClientConfig.serverLanguageCode=fr";
+ return "ftp://admin@localhost:{{ftp.server.port}}/code/?password=admin&ftpClientConfig.serverLanguageCode=fr";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSetNamesWithMultiDirectoriesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSetNamesWithMultiDirectoriesTest.java
index 5a7119a..b4411a0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSetNamesWithMultiDirectoriesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSetNamesWithMultiDirectoriesTest.java
@@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpSetNamesWithMultiDirectoriesTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/incoming?password=admin&binary=true&recursive=true&initialDelay=0&delay=100";
}
@@ -81,7 +81,7 @@ public class FromFtpSetNamesWithMultiDirectoriesTest extends FtpServerTestSuppor
// prepares the FTP Server by creating a file on the server that we want
// to unit
// test that we can pool and store as a local file
- String ftpUrl = "ftp://admin@localhost:" + getPort() + "/incoming/data1/?password=admin&binary=true";
+ String ftpUrl = "ftp://admin@localhost:{{ftp.server.port}}/incoming/data1/?password=admin&binary=true";
Endpoint endpoint = context.getEndpoint(ftpUrl);
Exchange exchange = endpoint.createExchange();
exchange.getIn().setBody(IOConverter.toFile("src/test/data/ftpbinarytest/logo1.jpeg"));
@@ -91,7 +91,7 @@ public class FromFtpSetNamesWithMultiDirectoriesTest extends FtpServerTestSuppor
producer.process(exchange);
producer.stop();
- ftpUrl = "ftp://admin@localhost:" + getPort() + "/incoming/data2/?password=admin&binary=true";
+ ftpUrl = "ftp://admin@localhost:{{ftp.server.port}}/incoming/data2/?password=admin&binary=true";
endpoint = context.getEndpoint(ftpUrl);
exchange = endpoint.createExchange();
exchange.getIn().setBody(IOConverter.toFile("src/test/data/ftpbinarytest/logo2.png"));
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest.java
index 4b5546c..2bd39c2 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest.java
@@ -21,7 +21,7 @@ public class FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteNotStepwiseTest
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&recursive=true&binary=false"
+ "&move=/.done&initialDelay=2500&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest.java
index 97b6e30..1073057 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&recursive=true&binary=false"
+ "&move=/.done&initialDelay=2500&delay=5000";
}
@@ -40,9 +40,9 @@ public class FromFtpSimpleNoEndpointPathRelativeMoveToAbsoluteTest extends FtpSe
public void testPollFileAndShouldBeMoved() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/hello.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/bye.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/goodday.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/hello.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/bye.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/goodday.txt");
mock.assertIsSatisfied();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeNotStepwiseTest.java
index f485163..cb7f5b5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeNotStepwiseTest.java
@@ -21,7 +21,7 @@ public class FromFtpSimpleNoEndpointPathRelativeMoveToRelativeNotStepwiseTest
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&recursive=true&binary=false"
+ "&move=.done&initialDelay=2500&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest.java
index 17fcd81..dfe7456 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&recursive=true&binary=false"
+ "&move=.done&initialDelay=2500&delay=5000";
}
@@ -40,9 +40,9 @@ public class FromFtpSimpleNoEndpointPathRelativeMoveToRelativeTest extends FtpSe
public void testPollFileAndShouldBeMoved() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
- mock.expectedFileExists(FTP_ROOT_DIR + "/.done/hello.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/sub/.done/bye.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/sub/sub2/.done/goodday.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/.done/hello.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/sub/.done/bye.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/sub/sub2/.done/goodday.txt");
mock.assertIsSatisfied();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteNotStepwiseTest.java
index 76dd047..6f8bb98 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteNotStepwiseTest.java
@@ -20,7 +20,7 @@ public class FromFtpSimpleRelativeMoveToAbsoluteNotStepwiseTest extends FromFtpS
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&recursive=true&binary=false"
+ "&move=/movefile/.done&initialDelay=2500&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteTest.java
index 861826a..53d0b49 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToAbsoluteTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpSimpleRelativeMoveToAbsoluteTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&recursive=true&binary=false"
+ "&move=/movefile/.done&initialDelay=2500&delay=5000";
}
@@ -40,9 +40,9 @@ public class FromFtpSimpleRelativeMoveToAbsoluteTest extends FtpServerTestSuppor
public void testPollFileAndShouldBeMoved() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/.done/hello.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/.done/bye.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/.done/goodday.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/.done/hello.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/.done/bye.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/.done/goodday.txt");
mock.assertIsSatisfied();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeNotStepwiseTest.java
index c1be3c4..ea60c03 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeNotStepwiseTest.java
@@ -20,7 +20,7 @@ public class FromFtpSimpleRelativeMoveToRelativeNotStepwiseTest extends FromFtpS
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&recursive=true&binary=false"
+ "&move=.done&initialDelay=2500&delay=5000&stepwise=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeTest.java
index 7c1c573..47c634a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimpleRelativeMoveToRelativeTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpSimpleRelativeMoveToRelativeTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/movefile?password=admin&recursive=true&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/movefile?password=admin&recursive=true&binary=false"
+ "&move=.done&initialDelay=2500&delay=5000";
}
@@ -40,9 +40,9 @@ public class FromFtpSimpleRelativeMoveToRelativeTest extends FtpServerTestSuppor
public void testPollFileAndShouldBeMoved() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("Hello", "Bye", "Goodday");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/.done/hello.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/sub/.done/bye.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/movefile/sub/sub2/.done/goodday.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/.done/hello.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/sub/.done/bye.txt");
+ mock.expectedFileExists(service.getFtpRootDir() + "/movefile/sub/sub2/.done/goodday.txt");
mock.assertIsSatisfied();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimulateNetworkIssueRecoverTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimulateNetworkIssueRecoverTest.java
index 5e3971f..7ccf9a2 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimulateNetworkIssueRecoverTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpSimulateNetworkIssueRecoverTest.java
@@ -38,7 +38,7 @@ public class FromFtpSimulateNetworkIssueRecoverTest extends FtpServerTestSupport
private MyPollStrategy strategy = new MyPollStrategy();
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/recover?password=admin&pollStrategy=#myPoll";
+ return "ftp://admin@localhost:{{ftp.server.port}}/recover?password=admin&pollStrategy=#myPoll";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpStartingDirAndFileNameClashTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpStartingDirAndFileNameClashTest.java
index a2468a6..c338a28 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpStartingDirAndFileNameClashTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpStartingDirAndFileNameClashTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpStartingDirAndFileNameClashTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/hello/?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/hello/?password=admin";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpThirdPoolOkTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpThirdPoolOkTest.java
index 0dc26a9..a3bb0fa 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpThirdPoolOkTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpThirdPoolOkTest.java
@@ -35,7 +35,7 @@ public class FromFtpThirdPoolOkTest extends FtpServerTestSupport {
private String body = "Hello World this file will be deleted";
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/thirdpool?password=admin&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/thirdpool?password=admin&delete=true";
}
@Override
@@ -61,7 +61,7 @@ public class FromFtpThirdPoolOkTest extends FtpServerTestSupport {
assertEquals(3, counter);
// assert the file is deleted
- File file = new File(FTP_ROOT_DIR + "/thirdpool/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/thirdpool/hello.txt");
assertFalse(file.exists(), "The file should have been deleted");
}
@@ -78,7 +78,7 @@ public class FromFtpThirdPoolOkTest extends FtpServerTestSupport {
counter++;
if (counter < 3) {
// file should exists
- File file = new File(FTP_ROOT_DIR + "/thirdpool/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/thirdpool/hello.txt");
assertTrue(file.exists(), "The file should NOT have been deleted");
throw new IllegalArgumentException("Forced by unittest");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileNoBodyConversionTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileNoBodyConversionTest.java
index ae984e6..dc19db5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileNoBodyConversionTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileNoBodyConversionTest.java
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpToAsciiFileNoBodyConversionTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp5/camel?password=admin&binary=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp5/camel?password=admin&binary=false";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java
index 444f2ee..e62ef7b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToAsciiFileTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpToAsciiFileTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp3/camel?password=admin&binary=false&fileExist=Override";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp3/camel?password=admin&binary=false&fileExist=Override";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFileTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFileTest.java
index 962b5bd..917cd83 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFileTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFileTest.java
@@ -36,7 +36,8 @@ public class FromFtpToBinaryFileTest extends FtpServerTestSupport {
// must user "consumer." prefix on the parameters to the file component
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp4/camel?password=admin&binary=true" + "&delay=5000&recursive=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp4/camel?password=admin&binary=true"
+ + "&delay=5000&recursive=false";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFilesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFilesTest.java
index c0616e0..4af6e47 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFilesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToBinaryFilesTest.java
@@ -36,7 +36,7 @@ public class FromFtpToBinaryFilesTest extends FtpServerTestSupport {
// must user "consumer." prefix on the parameters to the file component
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/incoming?password=admin&binary=true" + "&delay=2000&recursive=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/incoming?password=admin&binary=true" + "&delay=2000&recursive=true";
}
@Override
@@ -71,7 +71,8 @@ public class FromFtpToBinaryFilesTest extends FtpServerTestSupport {
// to unit
// test that we can pool and store as a local file
String ftpUrl
- = "ftp://admin@localhost:" + getPort() + "/incoming?password=admin&binary=true" + "&delay=2000&recursive=false";
+ = "ftp://admin@localhost:{{ftp.server.port}}/incoming?password=admin&binary=true"
+ + "&delay=2000&recursive=false";
Endpoint endpoint = context.getEndpoint(ftpUrl);
Exchange exchange = endpoint.createExchange();
exchange.getIn().setBody(IOConverter.toFile("src/test/data/ftpbinarytest/logo.jpeg"));
@@ -81,7 +82,7 @@ public class FromFtpToBinaryFilesTest extends FtpServerTestSupport {
producer.process(exchange);
producer.stop();
- ftpUrl = "ftp://admin@localhost:" + getPort() + "/incoming/a?password=admin&binary=true"
+ ftpUrl = "ftp://admin@localhost:{{ftp.server.port}}/incoming/a?password=admin&binary=true"
+ "&delay=2000&recursive=false";
endpoint = context.getEndpoint(ftpUrl);
exchange = endpoint.createExchange();
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToFileNoFileNameHeaderTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToFileNoFileNameHeaderTest.java
index 8490997..3761804 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToFileNoFileNameHeaderTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToFileNoFileNameHeaderTest.java
@@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test;
public class FromFtpToFileNoFileNameHeaderTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp3/camel?password=admin&binary=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp3/camel?password=admin&binary=false";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToMockTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToMockTest.java
index 4948a77..7191ad5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToMockTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpToMockTest.java
@@ -24,7 +24,7 @@ public class FromFtpToMockTest extends FtpServerTestSupport {
protected String expectedBody = "Hello there!";
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp/camel?password=admin&recursive=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp/camel?password=admin&recursive=true";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpTwoSlashesIssueTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpTwoSlashesIssueTest.java
index ccc2234..52072c6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpTwoSlashesIssueTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpTwoSlashesIssueTest.java
@@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FromFtpTwoSlashesIssueTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "//?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}//?password=admin";
}
@Override
@@ -66,7 +66,7 @@ public class FromFtpTwoSlashesIssueTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpUseListFalseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpUseListFalseTest.java
index 2bb68c1..3a3be81 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpUseListFalseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpUseListFalseTest.java
@@ -30,15 +30,24 @@ import org.junit.jupiter.api.Test;
public class FromFtpUseListFalseTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/nolist/?password=admin"
+ return "ftp://admin@localhost:{{ftp.server.port}}/nolist/?password=admin"
+ "&stepwise=false&useList=false&ignoreFileNotFoundOrPermissionError=true&fileName=report.txt&delete=true";
}
- @Override
@BeforeEach
- public void setUp() throws Exception {
- super.setUp();
- prepareFtpServer();
+ private void prepareFtpServer() throws Exception {
+ // prepares the FTP Server by creating a file on the server that we want
+ // to unit
+ // test that we can pool and store as a local file
+ Endpoint endpoint
+ = context.getEndpoint("ftp://admin@localhost:{{ftp.server.port}}/nolist/?password=admin&binary=false");
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody("Hello World from FTPServer");
+ exchange.getIn().setHeader(Exchange.FILE_NAME, "report.txt");
+ Producer producer = endpoint.createProducer();
+ producer.start();
+ producer.process(exchange);
+ producer.stop();
}
@Test
@@ -53,20 +62,6 @@ public class FromFtpUseListFalseTest extends FtpServerTestSupport {
mock.assertIsSatisfied();
}
- private void prepareFtpServer() throws Exception {
- // prepares the FTP Server by creating a file on the server that we want
- // to unit
- // test that we can pool and store as a local file
- Endpoint endpoint = context.getEndpoint("ftp://admin@localhost:" + getPort() + "/nolist/?password=admin&binary=false");
- Exchange exchange = endpoint.createExchange();
- exchange.getIn().setBody("Hello World from FTPServer");
- exchange.getIn().setHeader(Exchange.FILE_NAME, "report.txt");
- Producer producer = endpoint.createProducer();
- producer.start();
- producer.process(exchange);
- producer.stop();
- }
-
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java
index 9466d4c..a2ca13d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromQueueThenConsumeFtpToMockTest.java
@@ -36,12 +36,12 @@ public class FromQueueThenConsumeFtpToMockTest extends FtpServerTestSupport {
// second time before we stop the consumer
// this is because we only want to run a single poll and get the file
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/getme?password=admin&binary=false&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/getme?password=admin&binary=false&delay=5000";
}
// END SNIPPET: e1
private String getStoreUrl() {
- return "ftp://admin@localhost:" + getPort() + "/getme?password=admin&binary=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/getme?password=admin&binary=false";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpAnonymousTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpAnonymousTest.java
index d70931d..6572e85 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpAnonymousTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpAnonymousTest.java
@@ -29,7 +29,7 @@ public class FtpAnonymousTest extends FtpServerTestSupport {
private String getFtpUrl(String user, String password) {
StringBuilder url = new StringBuilder("ftp://");
url.append(user == null ? "" : user + "@");
- url.append("localhost:" + getPort() + "/");
+ url.append("localhost:{{ftp.server.port}}/");
url.append(password == null ? "" : "?password=" + password);
return url.toString();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginConnectionLeakTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginConnectionLeakTest.java
index 753f3e4..c2511ad 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginConnectionLeakTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginConnectionLeakTest.java
@@ -44,7 +44,7 @@ public class FtpBadLoginConnectionLeakTest extends FtpServerTestSupport {
private SocketFactory sf = new AuditingSocketFactory();
private String getFtpUrl() {
- return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber"
+ return "ftp://dummy@localhost:{{ftp.server.port}}/badlogin?password=cantremeber"
+ "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginInProducerConnectionLeakTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginInProducerConnectionLeakTest.java
index ca23dcc..07bec36 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginInProducerConnectionLeakTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginInProducerConnectionLeakTest.java
@@ -42,7 +42,7 @@ public class FtpBadLoginInProducerConnectionLeakTest extends FtpServerTestSuppor
private SocketFactory sf = new AuditingSocketFactory();
private String getFtpUrl() {
- return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber&maximumReconnectAttempts=3"
+ return "ftp://dummy@localhost:{{ftp.server.port}}/badlogin?password=cantremeber&maximumReconnectAttempts=3"
+ "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginMockNoopConnectionLeakTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginMockNoopConnectionLeakTest.java
index 254a02b..325c8fa 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginMockNoopConnectionLeakTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBadLoginMockNoopConnectionLeakTest.java
@@ -53,7 +53,7 @@ public class FtpBadLoginMockNoopConnectionLeakTest extends FtpServerTestSupport
private SocketFactory sf = new AuditingSocketFactory();
private String getFtpUrl() {
- return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber&maximumReconnectAttempts=3"
+ return "ftp://dummy@localhost:{{ftp.server.port}}/badlogin?password=cantremeber&maximumReconnectAttempts=3"
+ "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBrowsableEndpointTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBrowsableEndpointTest.java
index e68a548..6ed31e3 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBrowsableEndpointTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpBrowsableEndpointTest.java
@@ -22,24 +22,39 @@ import java.util.List;
import org.apache.camel.Exchange;
import org.apache.camel.spi.BrowsableEndpoint;
import org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository;
+import org.apache.camel.util.FileUtil;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
import static org.apache.camel.test.junit5.TestSupport.createDirectory;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class FtpBrowsableEndpointTest extends FtpServerTestSupport {
+ private File browseDir;
+
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/browse?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/browse?password=admin";
+ }
+
+ @BeforeEach
+ public void createDir() {
+ browseDir = new File(service.getFtpRootDir(), "browse");
+ createDirectory(service.getFtpRootDir() + File.pathSeparator + "browse");
+ }
+
+ @AfterEach
+ public void cleanupDir() {
+ FileUtil.removeDir(new File(service.getFtpRootDir(), "browse"));
}
@Test
public void testBrowsableNoFiles() throws Exception {
- // make sure starting directory exists
- createDirectory(FTP_ROOT_DIR + "/browse");
-
BrowsableEndpoint browse = context.getEndpoint(getFtpUrl(), BrowsableEndpoint.class);
assertNotNull(browse);
@@ -68,7 +83,7 @@ public class FtpBrowsableEndpointTest extends FtpServerTestSupport {
assertEquals(0, repo.getCacheSize());
// and the file is still there
- File file = new File(FTP_ROOT_DIR + "/browse/a.txt");
+ File file = new File(browseDir, "a.txt");
assertTrue(file.exists(), "File should exist " + file);
}
@@ -94,9 +109,9 @@ public class FtpBrowsableEndpointTest extends FtpServerTestSupport {
assertEquals(0, repo.getCacheSize());
// and the files is still there
- File fileA = new File(FTP_ROOT_DIR + "/browse/a.txt");
+ File fileA = new File(browseDir, "a.txt");
assertTrue(fileA.exists(), "File should exist " + fileA);
- File fileB = new File(FTP_ROOT_DIR + "/browse/b.txt");
+ File fileB = new File(browseDir, "/b.txt");
assertTrue(fileB.exists(), "File should exist " + fileB);
}
@@ -124,11 +139,11 @@ public class FtpBrowsableEndpointTest extends FtpServerTestSupport {
assertEquals(0, repo.getCacheSize());
// and the files is still there
- File fileA = new File(FTP_ROOT_DIR + "/browse/a.txt");
+ File fileA = new File(browseDir, "/a.txt");
assertTrue(fileA.exists(), "File should exist " + fileA);
- File fileB = new File(FTP_ROOT_DIR + "/browse/foo/b.txt");
+ File fileB = new File(browseDir, "/foo/b.txt");
assertTrue(fileB.exists(), "File should exist " + fileB);
- File fileC = new File(FTP_ROOT_DIR + "/browse/bar/c.txt");
+ File fileC = new File(browseDir, "/bar/c.txt");
assertTrue(fileC.exists(), "File should exist " + fileC);
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockFastExistCheckTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockFastExistCheckTest.java
index 8b987af..991ee43 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockFastExistCheckTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockFastExistCheckTest.java
@@ -23,7 +23,7 @@ public class FtpChangedReadLockFastExistCheckTest extends FtpChangedReadLockTest
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/changed?password=admin&readLock=changed&readLockCheckInterval=1000&delete=true&fastExistsCheck=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTest.java
index c79b1d0..ea64f40 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedReadLockTest.java
@@ -36,7 +36,7 @@ public class FtpChangedReadLockTest extends FtpServerTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(FtpChangedReadLockTest.class);
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/changed?password=admin&readLock=changed&readLockCheckInterval=1000&delete=true";
}
@@ -61,8 +61,8 @@ public class FtpChangedReadLockTest extends FtpServerTestSupport {
private void writeSlowFile() throws Exception {
LOG.debug("Writing slow file...");
- createDirectory(FTP_ROOT_DIR + "/changed");
- FileOutputStream fos = new FileOutputStream(FTP_ROOT_DIR + "/changed/slowfile.dat", true);
+ createDirectory(service.getFtpRootDir() + "/changed");
+ FileOutputStream fos = new FileOutputStream(service.getFtpRootDir() + "/changed/slowfile.dat", true);
for (int i = 0; i < 20; i++) {
fos.write(("Line " + i + LS).getBytes());
LOG.debug("Writing line " + i);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedRootDirReadLockFastExistCheckTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedRootDirReadLockFastExistCheckTest.java
index ddb645a..dea8229 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedRootDirReadLockFastExistCheckTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedRootDirReadLockFastExistCheckTest.java
@@ -23,7 +23,7 @@ public class FtpChangedRootDirReadLockFastExistCheckTest extends FtpChangedRootD
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/?password=admin&readLock=changed&readLockCheckInterval=1000&delete=true&fastExistsCheck=true";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedRootDirReadLockTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedRootDirReadLockTest.java
index 0df39cb..d4a9284 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedRootDirReadLockTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedRootDirReadLockTest.java
@@ -36,7 +36,7 @@ public class FtpChangedRootDirReadLockTest extends FtpServerTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(FtpChangedRootDirReadLockTest.class);
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/?password=admin&readLock=changed&readLockCheckInterval=1000&delete=true";
}
@@ -61,8 +61,8 @@ public class FtpChangedRootDirReadLockTest extends FtpServerTestSupport {
private void writeSlowFile() throws Exception {
LOG.debug("Writing slow file...");
- createDirectory(FTP_ROOT_DIR + "/");
- FileOutputStream fos = new FileOutputStream(FTP_ROOT_DIR + "/slowfile.dat", true);
+ createDirectory(service.getFtpRootDir() + "/");
+ FileOutputStream fos = new FileOutputStream(service.getFtpRootDir() + "/slowfile.dat", true);
for (int i = 0; i < 20; i++) {
fos.write(("Line " + i + LS).getBytes());
LOG.debug("Writing line " + i);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedZeroLengthReadLockTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedZeroLengthReadLockTest.java
index d877446..cb741c2 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedZeroLengthReadLockTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpChangedZeroLengthReadLockTest.java
@@ -30,7 +30,7 @@ import static org.apache.camel.test.junit5.TestSupport.createDirectory;
public class FtpChangedZeroLengthReadLockTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/changed?password=admin&readLock=changed&readLockCheckInterval=1000&readLockMinLength=0&delete=true";
}
@@ -46,8 +46,8 @@ public class FtpChangedZeroLengthReadLockTest extends FtpServerTestSupport {
}
private void writeZeroFile() throws Exception {
- createDirectory(FTP_ROOT_DIR + "/changed");
- FileOutputStream fos = new FileOutputStream(FTP_ROOT_DIR + "/changed/zerofile.dat", true);
+ createDirectory(service.getFtpRootDir() + "/changed");
+ FileOutputStream fos = new FileOutputStream(service.getFtpRootDir() + "/changed/zerofile.dat", true);
fos.flush();
fos.close();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConnectTimeoutTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConnectTimeoutTest.java
index 39d58af..46b1863 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConnectTimeoutTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConnectTimeoutTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FtpConnectTimeoutTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/timeout/?password=admin&connectTimeout=2000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/timeout/?password=admin&connectTimeout=2000";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAbsolutePathTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAbsolutePathTest.java
index bc64986..2302c06 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAbsolutePathTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAbsolutePathTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
public class FtpConsumerAbsolutePathTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "///foo?password=admin&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}///foo?password=admin&delay=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAsyncStressTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAsyncStressTest.java
index 1af7c16..5e74774 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAsyncStressTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAsyncStressTest.java
@@ -30,7 +30,7 @@ public class FtpConsumerAsyncStressTest extends FtpServerTestSupport {
private int files = 100;
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/filestress/?password=admin&maxMessagesPerPoll=25";
+ return "ftp://admin@localhost:{{ftp.server.port}}/filestress/?password=admin&maxMessagesPerPoll=25";
}
@Override
@@ -38,7 +38,8 @@ public class FtpConsumerAsyncStressTest extends FtpServerTestSupport {
public void setUp() throws Exception {
super.setUp();
for (int i = 0; i < files; i++) {
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR + "/filestress", "Hello World", Exchange.FILE_NAME, i + ".txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir() + "/filestress", "Hello World", Exchange.FILE_NAME,
+ i + ".txt");
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAutoCreateTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAutoCreateTest.java
index 2b84c26..2275ed7 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAutoCreateTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerAutoCreateTest.java
@@ -19,35 +19,38 @@ package org.apache.camel.component.file.remote;
import java.io.File;
import org.apache.camel.component.file.GenericFileOperationFailedException;
-import org.junit.jupiter.api.BeforeEach;
+import org.apache.camel.util.FileUtil;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class FtpConsumerAutoCreateTest extends FtpServerTestSupport {
+ private static final String TEST_DIR = "target/res/home/foo/bar/baz/xxx";
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "///foo/bar/baz/xxx?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}///foo/bar/baz/xxx?password=admin";
}
- @Override
- @BeforeEach
- public void setUp() throws Exception {
- super.setUp();
+ @AfterEach
+ public void cleanupDir() {
+ FileUtil.removeDir(new File(TEST_DIR));
}
@Test
- public void testAutoCreate() throws Exception {
+ public void testAutoCreate() {
FtpEndpoint<?> endpoint = (FtpEndpoint<?>) this.getMandatoryEndpoint(getFtpUrl() + "&autoCreate=true");
endpoint.start();
endpoint.getExchanges();
- assertTrue(new File("target/res/home/foo/bar/baz/xxx").exists());
+ assertTrue(new File(TEST_DIR).exists());
// producer should create necessary subdirs
sendFile(getFtpUrl(), "Hello World", "sub1/sub2/hello.txt");
- assertTrue(new File("target/res/home/foo/bar/baz/xxx/sub1/sub2").exists());
+ assertTrue(new File(TEST_DIR, "sub1/sub2").exists());
// to see if another connect causes problems with autoCreate=true
endpoint.stop();
@@ -56,7 +59,7 @@ public class FtpConsumerAutoCreateTest extends FtpServerTestSupport {
}
@Test
- public void testNoAutoCreate() throws Exception {
+ public void testNoAutoCreate() {
FtpEndpoint<?> endpoint = (FtpEndpoint<?>) this.getMandatoryEndpoint(getFtpUrl() + "&autoCreate=false");
endpoint.start();
try {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerBodyAsStringTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerBodyAsStringTest.java
index 655215e..378c3e1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerBodyAsStringTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerBodyAsStringTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class FtpConsumerBodyAsStringTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp4/camel?password=admin&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tmp4/camel?password=admin&delay=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDeleteNoWritePermissionTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDeleteNoWritePermissionTest.java
index d7cfd90..d8b821a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDeleteNoWritePermissionTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDeleteNoWritePermissionTest.java
@@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class FtpConsumerDeleteNoWritePermissionTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://dummy@localhost:" + getPort() + "/deletenoperm?password=foo" + "&delete=true&delay=5000";
+ return "ftp://dummy@localhost:{{ftp.server.port}}/deletenoperm?password=foo" + "&delete=true&delay=5000";
}
@Override
@@ -60,7 +60,7 @@ public class FtpConsumerDeleteNoWritePermissionTest extends FtpServerTestSupport
// prepares the FTP Server by creating files on the server that we want
// to unit
// test that we can pool and store as a local file
- String ftpUrl = "ftp://admin@localhost:" + getPort() + "/deletenoperm/?password=admin";
+ String ftpUrl = "ftp://admin@localhost:{{ftp.server.port}}/deletenoperm/?password=admin";
template.sendBodyAndHeader(ftpUrl, "Hello World", Exchange.FILE_NAME, "hello.txt");
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDirectoriesNotMatchedTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDirectoriesNotMatchedTest.java
index cff9254..14fc2bb 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDirectoriesNotMatchedTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDirectoriesNotMatchedTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerDirectoriesNotMatchedTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/dirnotmatched/?password=admin" + "&recursive=true&include=^.*txt$";
+ return "ftp://admin@localhost:{{ftp.server.port}}/dirnotmatched/?password=admin" + "&recursive=true&include=^.*txt$";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java
index 04e0b49..be847a4 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java
@@ -27,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpConsumerDisconnectTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin&disconnect=true&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/done?password=admin&disconnect=true&delay=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedStepwiseTest.java
index 31d9278..ef54a03 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedStepwiseTest.java
@@ -20,7 +20,7 @@ public class FtpConsumerDoneFileNameFixedStepwiseTest extends FtpConsumerDoneFil
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin&initialDelay=0&delay=100&stepwise=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/done?password=admin&initialDelay=0&delay=100&stepwise=true";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedTest.java
index 93dcb9f..f4b1e08 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedTest.java
@@ -27,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
public class FtpConsumerDoneFileNameFixedTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin&initialDelay=0&delay=100&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/done?password=admin&initialDelay=0&delay=100&stepwise=false";
}
@Test
@@ -55,7 +55,7 @@ public class FtpConsumerDoneFileNameFixedTest extends FtpServerTestSupport {
Thread.sleep(1000);
// done file should be deleted now
- File file = new File(FTP_ROOT_DIR + "done/fin.dat");
+ File file = new File(service.getFtpRootDir() + "done/fin.dat");
assertFalse(file.exists(), "Done file should be deleted: " + file);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameStepwiseTest.java
index 5b656af..13c55aa 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameStepwiseTest.java
@@ -20,7 +20,7 @@ public class FtpConsumerDoneFileNameStepwiseTest extends FtpConsumerDoneFileName
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin&initialDelay=0&delay=100&stepwise=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/done?password=admin&initialDelay=0&delay=100&stepwise=true";
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameTest.java
index 5cf27af..117f953 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameTest.java
@@ -27,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
public class FtpConsumerDoneFileNameTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin&initialDelay=0&delay=100&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/done?password=admin&initialDelay=0&delay=100&stepwise=false";
}
@Test
@@ -55,7 +55,7 @@ public class FtpConsumerDoneFileNameTest extends FtpServerTestSupport {
Thread.sleep(1000);
// done file should be deleted now
- File file = new File(FTP_ROOT_DIR + "done/hello.dat");
+ File file = new File(service.getFtpRootDir() + "done/hello.dat");
assertFalse(file.exists(), "Done file should be deleted: " + file);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDualDoneFileNameTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDualDoneFileNameTest.java
index 28ccc51..55f6626 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDualDoneFileNameTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDualDoneFileNameTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerDualDoneFileNameTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin&initialDelay=0&delay=100&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/done?password=admin&initialDelay=0&delay=100&stepwise=false";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java
index a5a245c..7c083ef 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerExcludeNameTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/excludename?password=admin" + "&exclude=secret.*|.*xml";
+ return "ftp://admin@localhost:{{ftp.server.port}}/excludename?password=admin" + "&exclude=secret.*|.*xml";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerFileSplitTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerFileSplitTest.java
index f3627a4..b61507a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerFileSplitTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerFileSplitTest.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerFileSplitTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/incoming/?password=admin&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/incoming/?password=admin&delete=true";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java
index 95bafe2..cc3bbc3 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java
@@ -33,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class FtpConsumerIPV6BodyAsStringTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@[::1]:" + getPort() + "/tmp4/camel?password=admin&delay=5000";
+ return "ftp://admin@[::1]:{{ftp.server.port}}/tmp4/camel?password=admin&delay=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentKeyChangedIssueTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentKeyChangedIssueTest.java
index a336938..b5a0ad5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentKeyChangedIssueTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentKeyChangedIssueTest.java
@@ -29,7 +29,7 @@ public class FtpConsumerIdempotentKeyChangedIssueTest extends FtpServerTestSuppo
private Endpoint endpoint;
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/idempotent?password=admin&readLock=changed"
+ return "ftp://admin@localhost:{{ftp.server.port}}/idempotent?password=admin&readLock=changed"
+ "&idempotentKey=${file:onlyname}-${file:size}-${date:file:yyyyMMddHHmmss}";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentMemoryRefTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentMemoryRefTest.java
index 455ec757b..ba19f76 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentMemoryRefTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentMemoryRefTest.java
@@ -33,11 +33,11 @@ public class FtpConsumerIdempotentMemoryRefTest extends FtpServerTestSupport {
private MemoryIdempotentRepository repo;
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
- + "/idempotent?password=admin&binary=false&idempotent=true&idempotentRepository=#myRepo&idempotentKey=${file:onlyname}&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/idempotent?password=admin&binary=false&idempotent=true"
+ + "&idempotentRepository=#myConsumerIdemRepo&idempotentKey=${file:onlyname}&delete=true";
}
- @BindToRegistry("myRepo")
+ @BindToRegistry("myConsumerIdemRepo")
public MemoryIdempotentRepository addRepo() throws Exception {
repo = new MemoryIdempotentRepository();
repo.setCacheSize(5);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java
index 6f7b1dc..b3eb2c3 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentRefTest.java
@@ -32,12 +32,12 @@ public class FtpConsumerIdempotentRefTest extends FtpServerTestSupport {
private static boolean invoked;
- @BindToRegistry("myRepo")
+ @BindToRegistry("myIdempotentRepo")
private MyIdempotentRepository myIdempotentRepo = new MyIdempotentRepository();
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
- + "/idempotent?password=admin&binary=false&idempotent=true&idempotentRepository=#myRepo&delete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ + "/idempotent?password=admin&binary=false&idempotent=true&idempotentRepository=#myIdempotentRepo&delete=true";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentTest.java
index 55b54c7..80d3ab2 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentTest.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerIdempotentTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/idempotent?password=admin&binary=false&idempotent=true&delete=true&delay=1000";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIncludeNameTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIncludeNameTest.java
index f86f4db..36b1a2a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIncludeNameTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIncludeNameTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerIncludeNameTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/includename?password=admin" + "&include=report.*&exclude=.*xml";
+ return "ftp://admin@localhost:{{ftp.server.port}}/includename?password=admin" + "&include=report.*&exclude=.*xml";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryAsAbsolutePathTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryAsAbsolutePathTest.java
index 7a1cda6..cff0cfa0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryAsAbsolutePathTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryAsAbsolutePathTest.java
@@ -41,7 +41,7 @@ public class FtpConsumerLocalWorkDirectoryAsAbsolutePathTest extends FtpServerTe
protected String getFtpUrl() {
base = new File("target/lwd").getAbsolutePath();
- return "ftp://admin@localhost:" + getPort() + "/lwd/?password=admin&delay=5000&noop=true&localWorkDirectory=" + base;
+ return "ftp://admin@localhost:{{ftp.server.port}}/lwd/?password=admin&delay=5000&noop=true&localWorkDirectory=" + base;
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryDirectTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryDirectTest.java
index bea3849..4e2be62 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryDirectTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryDirectTest.java
@@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpConsumerLocalWorkDirectoryDirectTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/lwd/?password=admin&delay=5000&localWorkDirectory=target/lwd&noop=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/lwd/?password=admin&delay=5000&localWorkDirectory=target/lwd&noop=true";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryTest.java
index bf879e4..a2ae4c1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerLocalWorkDirectoryTest.java
@@ -39,7 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpConsumerLocalWorkDirectoryTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/lwd/?password=admin&localWorkDirectory=target/lwd&noop=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/lwd/?password=admin&localWorkDirectory=target/lwd&noop=true";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMaxMessagesPerPollTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMaxMessagesPerPollTest.java
index 916b84e..3b2ecb3 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMaxMessagesPerPollTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMaxMessagesPerPollTest.java
@@ -25,15 +25,14 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerMaxMessagesPerPollTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
- + "/poll/?password=admin&delay=6000&delete=true&sortBy=file:name&maxMessagesPerPoll=2";
+ return "ftp://admin@localhost:{{ftp.server.port}}/poll/?password=admin&delay=6000&delete=true&sortBy=file:name&maxMessagesPerPoll=2";
}
- @Override
@BeforeEach
- public void setUp() throws Exception {
- super.setUp();
- prepareFtpServer();
+ void prepareFtpServer() throws Exception {
+ sendFile(getFtpUrl(), "Bye World", "bye.txt");
+ sendFile(getFtpUrl(), "Hello World", "hello.txt");
+ sendFile(getFtpUrl(), "Godday World", "godday.txt");
}
@Test
@@ -55,12 +54,6 @@ public class FtpConsumerMaxMessagesPerPollTest extends FtpServerTestSupport {
assertMockEndpointsSatisfied();
}
- private void prepareFtpServer() throws Exception {
- sendFile(getFtpUrl(), "Bye World", "bye.txt");
- sendFile(getFtpUrl(), "Hello World", "hello.txt");
- sendFile(getFtpUrl(), "Godday World", "godday.txt");
- }
-
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMoveExpressionTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMoveExpressionTest.java
index 925f7ef..34e09bc 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMoveExpressionTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMoveExpressionTest.java
@@ -38,7 +38,7 @@ public class FtpConsumerMoveExpressionTest extends FtpServerTestSupport {
private MyGuidGenerator guid = new MyGuidGenerator();
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/filelanguage?password=admin&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/filelanguage?password=admin&delay=5000";
}
@Override
@@ -61,7 +61,7 @@ public class FtpConsumerMoveExpressionTest extends FtpServerTestSupport {
Thread.sleep(1000);
String now = new SimpleDateFormat("yyyyMMdd").format(new Date());
- File file = new File(FTP_ROOT_DIR + "/filelanguage/backup/" + now + "/123-report2.bak");
+ File file = new File(service.getFtpRootDir() + "/filelanguage/backup/" + now + "/123-report2.bak");
assertTrue(file.exists(), "File should have been renamed");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMultipleDirectoriesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMultipleDirectoriesTest.java
index 9da16b4..f5744a4 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMultipleDirectoriesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerMultipleDirectoriesTest.java
@@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class FtpConsumerMultipleDirectoriesTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/multidir/?password=admin&recursive=true&delay=5000&sortBy=file:path";
+ return "ftp://admin@localhost:{{ftp.server.port}}/multidir/?password=admin&recursive=true&delay=5000&sortBy=file:path";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerNotEagerMaxMessagesPerPollTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerNotEagerMaxMessagesPerPollTest.java
index 495064b..85b8622 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerNotEagerMaxMessagesPerPollTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerNotEagerMaxMessagesPerPollTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerNotEagerMaxMessagesPerPollTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/poll/?password=admin&delay=6000&delete=true"
+ return "ftp://admin@localhost:{{ftp.server.port}}/poll/?password=admin&delay=6000&delete=true"
+ "&sortBy=file:name&maxMessagesPerPoll=2&eagerMaxMessagesPerPoll=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerPostProcessingOnDisconnect.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerPostProcessingOnDisconnect.java
index 59e2c64..13ca5a5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerPostProcessingOnDisconnect.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerPostProcessingOnDisconnect.java
@@ -38,10 +38,6 @@ public class FtpConsumerPostProcessingOnDisconnect extends FtpServerTestSupport
@Test
public void testConsumeDelete() throws Exception {
- if (!canTest()) {
- return;
- }
-
// prepare sample file to be consumed by FTP consumer
createSampleFile(SAMPLE_FILE_NAME_1);
@@ -57,18 +53,14 @@ public class FtpConsumerPostProcessingOnDisconnect extends FtpServerTestSupport
// File is deleted
Thread.sleep(250);
- File deletedFile = new File(FTP_ROOT_DIR + "/" + SAMPLE_FILE_NAME_1);
+ File deletedFile = new File(service.getFtpRootDir() + "/" + SAMPLE_FILE_NAME_1);
assertFalse(deletedFile.exists(), "File should have been deleted: " + deletedFile);
}
@Test
public void testConsumeMove() throws Exception {
- if (!canTest()) {
- return;
- }
-
// moved file after its processed
- String movedFile = FTP_ROOT_DIR + "/.camel/" + SAMPLE_FILE_NAME_2;
+ String movedFile = service.getFtpRootDir() + "/.camel/" + SAMPLE_FILE_NAME_2;
// prepare sample file to be consumed by FTP consumer
createSampleFile(SAMPLE_FILE_NAME_2);
@@ -91,19 +83,19 @@ public class FtpConsumerPostProcessingOnDisconnect extends FtpServerTestSupport
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("ftp://admin@localhost:" + getPort() + "?password=admin&delete=true").routeId("foo").noAutoStartup()
+ from("ftp://admin@localhost:{{ftp.server.port}}?password=admin&delete=true").routeId("foo").noAutoStartup()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- disconnectAllSessions(); // disconnect all Sessions on FTP server
+ service.disconnectAllSessions(); // disconnect all Sessions on FTP server
}
}).to("mock:result");
- from("ftp://admin@localhost:" + getPort() + "?password=admin&noop=false&move=.camel").routeId("bar")
+ from("ftp://admin@localhost:{{ftp.server.port}}?password=admin&noop=false&move=.camel").routeId("bar")
.noAutoStartup()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- disconnectAllSessions(); // disconnect all Sessions on FTP server
+ service.disconnectAllSessions(); // disconnect all Sessions on FTP server
}
}).to("mock:result");
}
@@ -111,7 +103,7 @@ public class FtpConsumerPostProcessingOnDisconnect extends FtpServerTestSupport
}
private void createSampleFile(String fileName) throws IOException {
- File file = new File(FTP_ROOT_DIR + "/" + fileName);
+ File file = new File(service.getFtpRootDir() + "/" + fileName);
FileUtils.write(file, SAMPLE_FILE_PAYLOAD, SAMPLE_FILE_CHARSET);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerProcessStrategyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerProcessStrategyTest.java
index 90eca20..3114d10 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerProcessStrategyTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerProcessStrategyTest.java
@@ -34,15 +34,12 @@ public class FtpConsumerProcessStrategyTest extends FtpServerTestSupport {
private MyStrategy myStrategy = new MyStrategy();
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?password=admin&processStrategy=#myStrategy";
+ return "ftp://admin@localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ + "?password=admin&processStrategy=#myStrategy";
}
@Test
public void testFtpConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
sendFile(getFtpUrl(), "Hello World", "hello.txt");
String out = consumer.receiveBody(getFtpUrl(), 5000, String.class);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerRelativeFileNameTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerRelativeFileNameTest.java
index 57374ec..f6a98e4 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerRelativeFileNameTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerRelativeFileNameTest.java
@@ -27,7 +27,7 @@ import static org.apache.camel.test.junit5.TestSupport.assertDirectoryEquals;
public class FtpConsumerRelativeFileNameTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/target/filename-consumer?password=admin&recursive=true&sortBy=file:name";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerReplyStringTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerReplyStringTest.java
index 6c26e97..4f8f915 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerReplyStringTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerReplyStringTest.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerReplyStringTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/reply?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/reply?password=admin";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerResumeDownloadTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerResumeDownloadTest.java
index 7454f57..73f53a5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerResumeDownloadTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerResumeDownloadTest.java
@@ -35,8 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpConsumerResumeDownloadTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
- + "/myserver/?password=admin&localWorkDirectory=target/lwd&resumeDownload=true&binary=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/myserver/?password=admin&localWorkDirectory=target/lwd&resumeDownload=true&binary=true";
}
@Override
@@ -48,8 +47,8 @@ public class FtpConsumerResumeDownloadTest extends FtpServerTestSupport {
super.setUp();
// create file on FTP server to download
- createDirectory(FTP_ROOT_DIR + "/myserver");
- File temp = new File(FTP_ROOT_DIR + "/myserver", "hello.txt");
+ createDirectory(service.getFtpRootDir() + "/myserver");
+ File temp = new File(service.getFtpRootDir() + "/myserver", "hello.txt");
temp.createNewFile();
FileOutputStream fos = new FileOutputStream(temp);
fos.write("Hello\nWorld\nI was here".getBytes());
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerSkipDotFilesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerSkipDotFilesTest.java
index 3aa065e..cd4d209 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerSkipDotFilesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerSkipDotFilesTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerSkipDotFilesTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/dotfiles?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/dotfiles?password=admin";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.java
index 8e94ffa..1269e4d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.java
@@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpConsumerTemplateTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/template?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/template?password=admin";
}
@Override
@@ -65,7 +65,7 @@ public class FtpConsumerTemplateTest extends FtpServerTestSupport {
// file should still exists
Thread.sleep(500);
- File file = new File(FTP_ROOT_DIR + "/template/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/template/hello.txt");
assertTrue(file.exists(), "The file should exist: " + file);
}
@@ -96,7 +96,7 @@ public class FtpConsumerTemplateTest extends FtpServerTestSupport {
// file should still exists
Thread.sleep(500);
- File file = new File(FTP_ROOT_DIR + "/template/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/template/hello.txt");
assertTrue(file.exists(), "The file should exist: " + file);
}
@@ -111,7 +111,7 @@ public class FtpConsumerTemplateTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/template/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/template/hello.txt");
assertTrue(file.exists(), "The file should exist: " + file);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateUseListFalseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateUseListFalseTest.java
index 870fcec..1ed7b85 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateUseListFalseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateUseListFalseTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
public class FtpConsumerTemplateUseListFalseTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/nolist/?password=admin"
+ return "ftp://admin@localhost:{{ftp.server.port}}/nolist/?password=admin"
+ "&stepwise=false&useList=false&ignoreFileNotFoundOrPermissionError=true&delete=true";
}
@@ -60,7 +60,8 @@ public class FtpConsumerTemplateUseListFalseTest extends FtpServerTestSupport {
// prepares the FTP Server by creating a file on the server that we want
// to unit
// test that we can pool and store as a local file
- Endpoint endpoint = context.getEndpoint("ftp://admin@localhost:" + getPort() + "/nolist/?password=admin&binary=false");
+ Endpoint endpoint
+ = context.getEndpoint("ftp://admin@localhost:{{ftp.server.port}}/nolist/?password=admin&binary=false");
Exchange exchange = endpoint.createExchange();
exchange.getIn().setBody("Hello World from FTPServer");
exchange.getIn().setHeader(Exchange.FILE_NAME, "report.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerThrowExceptionOnLoginFailedTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerThrowExceptionOnLoginFailedTest.java
index e9f30fd..dde60f9 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerThrowExceptionOnLoginFailedTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerThrowExceptionOnLoginFailedTest.java
@@ -43,7 +43,7 @@ public class FtpConsumerThrowExceptionOnLoginFailedTest extends FtpServerTestSup
private MyPoll poll = new MyPoll();
private String getFtpUrl() {
- return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremember"
+ return "ftp://dummy@localhost:{{ftp.server.port}}/badlogin?password=cantremember"
+ "&throwExceptionOnConnectFailed=true&maximumReconnectAttempts=0&pollStrategy=#myPoll&autoCreate=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerUsingFTPClientConfigTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerUsingFTPClientConfigTest.java
index 259754d..1e06bf6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerUsingFTPClientConfigTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerUsingFTPClientConfigTest.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test;
public class FtpConsumerUsingFTPClientConfigTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/clientconfig?password=admin&ftpClientConfig=#myConfig";
+ return "ftp://admin@localhost:{{ftp.server.port}}/clientconfig?password=admin&ftpClientConfig=#myConfig";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithCharsetTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithCharsetTest.java
index 4f6fc6c..5a774e1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithCharsetTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithCharsetTest.java
@@ -43,7 +43,7 @@ public class FtpConsumerWithCharsetTest extends FtpServerTestSupport {
private final String payload = "\u00e6\u00f8\u00e5 \u00a9";
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload?password=admin&charset=iso-8859-1";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload?password=admin&charset=iso-8859-1";
}
@Override
@@ -66,7 +66,7 @@ public class FtpConsumerWithCharsetTest extends FtpServerTestSupport {
prepareFtpServer();
// Check that the payload exists in upload and is in iso charset.ß
- File file = new File(FTP_ROOT_DIR + "/upload/iso.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/iso.txt");
assertTrue(file.exists(), "The uploaded file should exists");
// Lets also test byte wise
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithNoFileOptionTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithNoFileOptionTest.java
index 85dc6f2..ff78f4a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithNoFileOptionTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerWithNoFileOptionTest.java
@@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class FtpConsumerWithNoFileOptionTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&delay=5000";
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpEndpointURISanitizedTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpEndpointURISanitizedTest.java
index 0735e21..b8f6293 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpEndpointURISanitizedTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpEndpointURISanitizedTest.java
@@ -33,7 +33,7 @@ public class FtpEndpointURISanitizedTest extends FtpServerTestSupport {
private String password = "secret";
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/////foo?password=" + password + "&delay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/////foo?password=" + password + "&delay=5000";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginNoRetryTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginNoRetryTest.java
index 55be859..178f757 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginNoRetryTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginNoRetryTest.java
@@ -44,13 +44,14 @@ public class FtpLoginNoRetryTest extends FtpServerTestSupport {
}
// assert file NOT created
- File file = new File(FTP_ROOT_DIR + "login/report.txt");
+ File file = new File(service.getFtpRootDir() + "login/report.txt");
assertFalse(file.exists(), "The file should NOT exists");
}
private void uploadFile(String username, String password) throws Exception {
- Endpoint endpoint = context.getEndpoint("ftp://" + username + "@localhost:" + getPort() + "/login?password=" + password
- + "&maximumReconnectAttempts=0");
+ Endpoint endpoint
+ = context.getEndpoint("ftp://" + username + "@localhost:{{ftp.server.port}}/login?password=" + password
+ + "&maximumReconnectAttempts=0");
Exchange exchange = endpoint.createExchange();
exchange.getIn().setBody("Hello World from FTPServer");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginTest.java
index caecaf1..5b91bf6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpLoginTest.java
@@ -45,7 +45,7 @@ public class FtpLoginTest extends FtpServerTestSupport {
}
// assert file NOT created
- File file = new File(FTP_ROOT_DIR + "/login/report.txt");
+ File file = new File(service.getFtpRootDir() + "/login/report.txt");
assertFalse(file.exists(), "The file should NOT exists");
}
@@ -54,13 +54,13 @@ public class FtpLoginTest extends FtpServerTestSupport {
uploadFile("scott", "tiger");
// assert file created
- File file = new File(FTP_ROOT_DIR + "/login/report.txt");
+ File file = new File(service.getFtpRootDir() + "/login/report.txt");
assertTrue(file.exists(), "The file should exists");
}
private void uploadFile(String username, String password) throws Exception {
Endpoint endpoint
- = context.getEndpoint("ftp://" + username + "@localhost:" + getPort() + "/login?password=" + password);
+ = context.getEndpoint("ftp://" + username + "@localhost:{{ftp.server.port}}/login?password=" + password);
Exchange exchange = endpoint.createExchange();
exchange.getIn().setBody("Hello World from FTPServer");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpNoReconnectAttemptUnknownHostTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpNoReconnectAttemptUnknownHostTest.java
index b67ec60..aa34695 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpNoReconnectAttemptUnknownHostTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpNoReconnectAttemptUnknownHostTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FtpNoReconnectAttemptUnknownHostTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@doesnotexisthost:" + getPort() + "/reconnect?maximumReconnectAttempts=0&password=admin";
+ return "ftp://admin@doesnotexisthost:{{ftp.server.port}}/reconnect?maximumReconnectAttempts=0&password=admin";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollEnrichBridgeErrorHandlerTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollEnrichBridgeErrorHandlerTest.java
index 88eeaa0..d15c670 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollEnrichBridgeErrorHandlerTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollEnrichBridgeErrorHandlerTest.java
@@ -20,12 +20,16 @@ import org.apache.camel.AggregationStrategy;
import org.apache.camel.Exchange;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.remote.services.FtpEmbeddedService;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import static org.apache.camel.support.ExchangeHelper.copyResultsPreservePattern;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class FtpPollEnrichBridgeErrorHandlerTest extends BaseServerTestSupport {
+ @RegisterExtension
+ static FtpEmbeddedService service = new FtpEmbeddedService();
// we want to poll enrich from FTP and therefore want to fail fast if
// something is wrong
@@ -34,7 +38,7 @@ public class FtpPollEnrichBridgeErrorHandlerTest extends BaseServerTestSupport {
// and turn of auto create as that will pre-login to check if the directory
// exists
// and in case of connection error then throw that as an exception
- private String uri = "ftp://admin@localhost:" + getPort() + "/unknown/?password=admin"
+ private String uri = "ftp://admin@localhost:" + service.getPort() + "/unknown/?password=admin"
+ "&maximumReconnectAttempts=0&autoCreate=false&throwExceptionOnConnectFailed=true&bridgeErrorHandler=true";
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollEnrichConsumeWithDisconnectAndDeleteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollEnrichConsumeWithDisconnectAndDeleteTest.java
index 5074e38..fa822af 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollEnrichConsumeWithDisconnectAndDeleteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollEnrichConsumeWithDisconnectAndDeleteTest.java
@@ -34,14 +34,10 @@ public class FtpPollEnrichConsumeWithDisconnectAndDeleteTest extends FtpServerTe
@Test
public void testFtpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR + "/poll", expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir() + "/poll", expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -64,7 +60,7 @@ public class FtpPollEnrichConsumeWithDisconnectAndDeleteTest extends FtpServerTe
// to
// be
// deleted
- File file = new File(FTP_ROOT_DIR + "/poll/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/poll/hello.txt");
fileExists = file.exists();
if (fileExists) {
@@ -81,7 +77,7 @@ public class FtpPollEnrichConsumeWithDisconnectAndDeleteTest extends FtpServerTe
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("vm:trigger").pollEnrich("ftp://admin@localhost:" + getPort() + "/poll?password=admin&delete=true")
+ from("vm:trigger").pollEnrich("ftp://admin@localhost:{{ftp.server.port}}/poll?password=admin&delete=true")
.routeId("foo").to("mock:result");
}
};
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java
index 09c06b8..9aa6aa7 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerIdleMessageTest.java
@@ -43,7 +43,7 @@ public class FtpPollingConsumerIdleMessageTest extends FtpServerTestSupport {
@BeforeEach
public void setup() throws Exception {
- new File(FTP_ROOT_DIR + "/polling").mkdirs();
+ new File(service.getFtpRootDir() + "/polling").mkdirs();
}
@Override
@@ -51,7 +51,7 @@ public class FtpPollingConsumerIdleMessageTest extends FtpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("ftp://admin@localhost:" + getPort() + "/polling?password=admin&delay=50"
+ from("ftp://admin@localhost:{{ftp.server.port}}/polling?password=admin&delay=50"
+ "&sendEmptyMessageWhenIdle=true").to("mock:result");
}
};
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerTest.java
index d880840..14aeb24 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpPollingConsumerTest.java
@@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpPollingConsumerTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/polling?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/polling?password=admin";
}
@Test
@@ -56,7 +56,7 @@ public class FtpPollingConsumerTest extends FtpServerTestSupport {
// file
Thread.sleep(1000);
- File file = new File(FTP_ROOT_DIR + "/polling/bye.txt");
+ File file = new File(service.getFtpRootDir() + "/polling/bye.txt");
assertTrue(file.exists(), "File should exist " + file);
consumer.stop();
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerAllowNullBodyFileAlreadyExistTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerAllowNullBodyFileAlreadyExistTest.java
index 2cef06a..f6cc067 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerAllowNullBodyFileAlreadyExistTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerAllowNullBodyFileAlreadyExistTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
public class FtpProducerAllowNullBodyFileAlreadyExistTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/allow?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/allow?password=admin";
}
@Override
@@ -39,7 +39,7 @@ public class FtpProducerAllowNullBodyFileAlreadyExistTest extends FtpServerTestS
public void testFileExistAppendAllowNullBody() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:appendTypeAppendResult");
mock.expectedMessageCount(1);
- mock.expectedFileExists(FTP_ROOT_DIR + "/allow/hello.txt", "Hello world");
+ mock.expectedFileExists(service.getFtpRootDir() + "/allow/hello.txt", "Hello world");
template.sendBody("direct:appendTypeAppend", null);
@@ -50,7 +50,7 @@ public class FtpProducerAllowNullBodyFileAlreadyExistTest extends FtpServerTestS
public void testFileExistOverrideAllowNullBody() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:appendTypeOverrideResult");
mock.expectedMessageCount(1);
- mock.expectedFileExists(FTP_ROOT_DIR + "/allow/hello.txt", "");
+ mock.expectedFileExists(service.getFtpRootDir() + "/allow/hello.txt", "");
template.sendBody("direct:appendTypeOverride", null);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerAllowNullBodyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerAllowNullBodyTest.java
index 8e96765..151c371 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerAllowNullBodyTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerAllowNullBodyTest.java
@@ -31,14 +31,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerAllowNullBodyTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/allownull?password=admin&fileName=allowNullBody.txt";
+ return "ftp://admin@localhost:{{ftp.server.port}}/allownull?password=admin&fileName=allowNullBody.txt";
}
@Test
public void testAllowNullBodyTrue() throws Exception {
template.sendBody(getFtpUrl() + "&allowNullBody=true", null);
- assertFileExists(FTP_ROOT_DIR + "/allownull/allowNullBody.txt");
+ assertFileExists(service.getFtpRootDir() + "/allownull/allowNullBody.txt");
}
@Test
@@ -50,7 +50,7 @@ public class FtpProducerAllowNullBodyTest extends FtpServerTestSupport {
= assertIsInstanceOf(GenericFileOperationFailedException.class, ex.getCause());
assertTrue(cause.getMessage().endsWith("allowNullBody.txt"));
- assertFalse(new File(FTP_ROOT_DIR + "/allownull/allowNullBody.txt").exists(),
+ assertFalse(new File(service.getFtpRootDir() + "/allownull/allowNullBody.txt").exists(),
"allowNullBody set to false with null body should not create a new file");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildDirectoryTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildDirectoryTest.java
index 9f4697e..b171308 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildDirectoryTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildDirectoryTest.java
@@ -30,14 +30,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerBuildDirectoryTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload/user/claus?binary=false&password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload/user/claus?binary=false&password=admin";
}
@Test
public void testProduceAndBuildFullRemotFolderTest() throws Exception {
sendFile(getFtpUrl(), "Hello World", "claus.txt");
- File file = new File(FTP_ROOT_DIR + "/upload/user/claus/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/user/claus/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildPartOfDirectoryTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildPartOfDirectoryTest.java
index 657df79..d4a3231 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildPartOfDirectoryTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerBuildPartOfDirectoryTest.java
@@ -30,14 +30,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerBuildPartOfDirectoryTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload/user/claus?binary=false&password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload/user/claus?binary=false&password=admin";
}
@Test
public void testProduceAndBuildPartOfRemotFolderTest() throws Exception {
sendFile(getFtpUrl(), "Bye World", "claus.txt");
- File file = new File(FTP_ROOT_DIR + "/upload/user/claus/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/user/claus/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Bye World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerConcurrentTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerConcurrentTest.java
index 4f37e9a..275ff44 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerConcurrentTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerConcurrentTest.java
@@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test;
public class FtpProducerConcurrentTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/concurrent?binary=false&password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/concurrent?binary=false&password=admin";
}
@Test
@@ -49,7 +49,7 @@ public class FtpProducerConcurrentTest extends FtpServerTestSupport {
ExecutorService executor = Executors.newFixedThreadPool(poolSize);
for (int i = 0; i < files; i++) {
- getMockEndpoint("mock:result").expectedFileExists(FTP_ROOT_DIR + "/concurrent/" + i + ".txt");
+ getMockEndpoint("mock:result").expectedFileExists(service.getFtpRootDir() + "/concurrent/" + i + ".txt");
final int index = i;
executor.submit(new Callable<Object>() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerConnectErrorsHeaderTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerConnectErrorsHeaderTest.java
index 162cf5f..24aca80 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerConnectErrorsHeaderTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerConnectErrorsHeaderTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FtpProducerConnectErrorsHeaderTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://xxx@localhost:" + getPort() + "/tmp4/camel?password=xxx&delay=5000";
+ return "ftp://xxx@localhost:{{ftp.server.port}}/tmp4/camel?password=xxx&delay=5000";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectOnBatchCompleteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectOnBatchCompleteTest.java
index 1361ba5..5391fae 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectOnBatchCompleteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectOnBatchCompleteTest.java
@@ -40,7 +40,7 @@ public class FtpProducerDisconnectOnBatchCompleteTest extends FtpServerTestSuppo
}
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin&disconnectOnBatchComplete=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/done?password=admin&disconnectOnBatchComplete=true";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectTest.java
index 761ed61..1244568 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDisconnectTest.java
@@ -37,7 +37,7 @@ public class FtpProducerDisconnectTest extends FtpServerTestSupport {
}
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin&disconnect=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/done?password=admin&disconnect=true";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDoneFileNameTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDoneFileNameTest.java
index 878ef6e..cbb0bfe 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDoneFileNameTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerDoneFileNameTest.java
@@ -31,17 +31,17 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerDoneFileNameTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/done?password=admin";
}
@Test
public void testProducerConstantDoneFileName() throws Exception {
template.sendBodyAndHeader(getFtpUrl() + "&doneFileName=done", "Hello World", Exchange.FILE_NAME, "hello.txt");
- File file = new File(FTP_ROOT_DIR + "/done/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/done/hello.txt");
assertEquals(true, file.exists(), "File should exists");
- File done = new File(FTP_ROOT_DIR + "/done/done");
+ File done = new File(service.getFtpRootDir() + "/done/done");
assertEquals(true, done.exists(), "Done file should exists");
}
@@ -50,10 +50,10 @@ public class FtpProducerDoneFileNameTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&doneFileName=done-${file:name}", "Hello World", Exchange.FILE_NAME,
"hello.txt");
- File file = new File(FTP_ROOT_DIR + "/done/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/done/hello.txt");
assertEquals(true, file.exists(), "File should exists");
- File done = new File(FTP_ROOT_DIR + "/done/done-hello.txt");
+ File done = new File(service.getFtpRootDir() + "/done/done-hello.txt");
assertEquals(true, done.exists(), "Done file should exists");
}
@@ -62,10 +62,10 @@ public class FtpProducerDoneFileNameTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&doneFileName=${file:name}.done", "Hello World", Exchange.FILE_NAME,
"hello.txt");
- File file = new File(FTP_ROOT_DIR + "/done/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/done/hello.txt");
assertEquals(true, file.exists(), "File should exists");
- File done = new File(FTP_ROOT_DIR + "/done/hello.txt.done");
+ File done = new File(service.getFtpRootDir() + "/done/hello.txt.done");
assertEquals(true, done.exists(), "Done file should exists");
}
@@ -74,10 +74,10 @@ public class FtpProducerDoneFileNameTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&doneFileName=${file:name.noext}.done", "Hello World", Exchange.FILE_NAME,
"hello.txt");
- File file = new File(FTP_ROOT_DIR + "/done/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/done/hello.txt");
assertEquals(true, file.exists(), "File should exists");
- File done = new File(FTP_ROOT_DIR + "/done/hello.done");
+ File done = new File(service.getFtpRootDir() + "/done/hello.done");
assertEquals(true, done.exists(), "Done file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerExpressionTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerExpressionTest.java
index 95a82db..b11c7df 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerExpressionTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerExpressionTest.java
@@ -36,7 +36,7 @@ public class FtpProducerExpressionTest extends FtpServerTestSupport {
private MyGuidGenerator guid = new MyGuidGenerator();
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/filelanguage?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/filelanguage?password=admin";
}
@Override
@@ -50,14 +50,14 @@ public class FtpProducerExpressionTest extends FtpServerTestSupport {
public void testProduceBeanByExpression() throws Exception {
template.sendBody(getFtpUrl() + "&fileName=${bean:myguidgenerator}.bak", "Hello World");
- assertFileExists(FTP_ROOT_DIR + "/filelanguage/123.bak");
+ assertFileExists(service.getFtpRootDir() + "/filelanguage/123.bak");
}
@Test
public void testProduceBeanByHeader() throws Exception {
sendFile(getFtpUrl(), "Hello World", "${bean:myguidgenerator}.bak");
- assertFileExists(FTP_ROOT_DIR + "/filelanguage/123.bak");
+ assertFileExists(service.getFtpRootDir() + "/filelanguage/123.bak");
}
@Test
@@ -65,7 +65,7 @@ public class FtpProducerExpressionTest extends FtpServerTestSupport {
sendFile(getFtpUrl(), "Hello World", "myfile-${date:now:yyyyMMdd}.txt");
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
- assertFileExists(FTP_ROOT_DIR + "/filelanguage/myfile-" + date + ".txt");
+ assertFileExists(service.getFtpRootDir() + "/filelanguage/myfile-" + date + ".txt");
}
@Test
@@ -73,27 +73,27 @@ public class FtpProducerExpressionTest extends FtpServerTestSupport {
template.sendBody(getFtpUrl() + "&fileName=myfile-${date:now:yyyyMMdd}.txt", "Hello World");
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
- assertFileExists(FTP_ROOT_DIR + "/filelanguage/myfile-" + date + ".txt");
+ assertFileExists(service.getFtpRootDir() + "/filelanguage/myfile-" + date + ".txt");
}
@Test
public void testProducerComplexByExpression() throws Exception {
// need one extra subdirectory (=foo) to be able to start with .. in the
// fileName option
- String url = "ftp://admin@localhost:" + getPort() + "/filelanguage/foo?password=admin&jailStartingDirectory=false";
+ String url = "ftp://admin@localhost:{{ftp.server.port}}/filelanguage/foo?password=admin&jailStartingDirectory=false";
String expression = "../filelanguageinbox/myfile-${bean:myguidgenerator.guid}-${date:now:yyyyMMdd}.txt";
template.sendBody(url + "&fileName=" + expression, "Hello World");
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
- assertFileExists(FTP_ROOT_DIR + "/filelanguage/filelanguageinbox/myfile-123-" + date + ".txt");
+ assertFileExists(service.getFtpRootDir() + "/filelanguage/filelanguageinbox/myfile-123-" + date + ".txt");
}
@Test
public void testProducerSimpleWithHeaderByExpression() throws Exception {
template.sendBodyAndHeader(getFtpUrl() + "&fileName=myfile-${header.foo}.txt", "Hello World", "foo", "abc");
- assertFileExists(FTP_ROOT_DIR + "/filelanguage/myfile-abc.txt");
+ assertFileExists(service.getFtpRootDir() + "/filelanguage/myfile-abc.txt");
}
@Test
@@ -105,7 +105,7 @@ public class FtpProducerExpressionTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&fileName=mybirthday-${date:header.birthday:yyyyMMdd}.txt", "Hello World",
"birthday", date);
- assertFileExists(FTP_ROOT_DIR + "/filelanguage/mybirthday-19740420.txt");
+ assertFileExists(service.getFtpRootDir() + "/filelanguage/mybirthday-19740420.txt");
}
public class MyGuidGenerator {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistAppendNoFileBeforeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistAppendNoFileBeforeTest.java
index cc1e369..439cb4a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistAppendNoFileBeforeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistAppendNoFileBeforeTest.java
@@ -27,7 +27,7 @@ import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
public class FtpProducerFileExistAppendNoFileBeforeTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/exist?password=admin&delay=2000&noop=true&fileExist=Append";
+ return "ftp://admin@localhost:{{ftp.server.port}}/exist?password=admin&delay=2000&noop=true&fileExist=Append";
}
@Override
@@ -41,7 +41,7 @@ public class FtpProducerFileExistAppendNoFileBeforeTest extends FtpServerTestSup
public void testAppend() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Bye World");
- mock.expectedFileExists(FTP_ROOT_DIR + "/exist/hello.txt", "Bye World");
+ mock.expectedFileExists(service.getFtpRootDir() + "/exist/hello.txt", "Bye World");
template.sendBodyAndHeader(getFtpUrl(), "Bye World", Exchange.FILE_NAME, "hello.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistAppendTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistAppendTest.java
index 91a44fa..008e8bd 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistAppendTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistAppendTest.java
@@ -28,7 +28,7 @@ public class FtpProducerFileExistAppendTest extends FtpServerTestSupport {
private static final boolean ON_WINDOWS = System.getProperty("os.name").startsWith("Windows");
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/exist?password=admin&delay=2000&noop=true&fileExist=Append";
+ return "ftp://admin@localhost:{{ftp.server.port}}/exist?password=admin&delay=2000&noop=true&fileExist=Append";
}
@Override
@@ -48,7 +48,7 @@ public class FtpProducerFileExistAppendTest extends FtpServerTestSupport {
expectBody = "Hello World\r\nBye World";
}
mock.expectedBodiesReceived(expectBody);
- mock.expectedFileExists(FTP_ROOT_DIR + "/exist/hello.txt", expectBody);
+ mock.expectedFileExists(service.getFtpRootDir() + "/exist/hello.txt", expectBody);
template.sendBodyAndHeader(getFtpUrl(), "Bye World", Exchange.FILE_NAME, "hello.txt");
assertMockEndpointsSatisfied();
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistFailTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistFailTest.java
index 695fde3..9a0f2ee 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistFailTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistFailTest.java
@@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
public class FtpProducerFileExistFailTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/exist?password=admin&delay=2000&noop=true&fileExist=Fail";
+ return "ftp://admin@localhost:{{ftp.server.port}}/exist?password=admin&delay=2000&noop=true&fileExist=Fail";
}
@Override
@@ -48,7 +48,7 @@ public class FtpProducerFileExistFailTest extends FtpServerTestSupport {
public void testFail() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
- mock.expectedFileExists(FTP_ROOT_DIR + "/exist/hello.txt", "Hello World");
+ mock.expectedFileExists(service.getFtpRootDir() + "/exist/hello.txt", "Hello World");
String uri = getFtpUrl();
Exception ex = assertThrows(CamelExecutionException.class,
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistIgnoreTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistIgnoreTest.java
index 970a448..943f065 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistIgnoreTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistIgnoreTest.java
@@ -27,7 +27,7 @@ import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
public class FtpProducerFileExistIgnoreTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/exist?password=admin&delay=2000&noop=true&fileExist=Ignore";
+ return "ftp://admin@localhost:{{ftp.server.port}}/exist?password=admin&delay=2000&noop=true&fileExist=Ignore";
}
@Override
@@ -43,7 +43,7 @@ public class FtpProducerFileExistIgnoreTest extends FtpServerTestSupport {
public void testIgnore() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
- mock.expectedFileExists(FTP_ROOT_DIR + "/exist/hello.txt", "Hello World");
+ mock.expectedFileExists(service.getFtpRootDir() + "/exist/hello.txt", "Hello World");
template.sendBodyAndHeader(getFtpUrl(), "Bye World", Exchange.FILE_NAME, "hello.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNoFileBeforeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNoFileBeforeTest.java
index baed683..e136754 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNoFileBeforeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNoFileBeforeTest.java
@@ -27,7 +27,7 @@ import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
public class FtpProducerFileExistOverrideNoFileBeforeTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/exist?password=admin&delay=2000&noop=true&fileExist=Override";
+ return "ftp://admin@localhost:{{ftp.server.port}}/exist?password=admin&delay=2000&noop=true&fileExist=Override";
}
@Override
@@ -41,7 +41,7 @@ public class FtpProducerFileExistOverrideNoFileBeforeTest extends FtpServerTestS
public void testOverride() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Bye World");
- mock.expectedFileExists(FTP_ROOT_DIR + "/exist/hello.txt", "Bye World");
+ mock.expectedFileExists(service.getFtpRootDir() + "/exist/hello.txt", "Bye World");
template.sendBodyAndHeader(getFtpUrl(), "Bye World", Exchange.FILE_NAME, "hello.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest.java
index 554ec44..8e67533 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest.java
@@ -21,7 +21,7 @@ public class FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/exist?password=admin&tempPrefix=upload-&fileExist=Override&disconnect=true&eagerDeleteTargetFile=false";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java
index 5593fa4..f3e2b67 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
public class FtpProducerFileExistOverrideTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/exist?password=admin&delay=2000&noop=true&fileExist=Override";
+ return "ftp://admin@localhost:{{ftp.server.port}}/exist?password=admin&delay=2000&noop=true&fileExist=Override";
}
@Override
@@ -39,7 +39,7 @@ public class FtpProducerFileExistOverrideTest extends FtpServerTestSupport {
public void testOverride() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Bye World");
- mock.expectedFileExists(FTP_ROOT_DIR + "/exist/hello.txt", "Bye World");
+ mock.expectedFileExists(service.getFtpRootDir() + "/exist/hello.txt", "Bye World");
template.sendBodyAndHeader(getFtpUrl(), "Bye World", Exchange.FILE_NAME, "hello.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTwoUploadTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTwoUploadTest.java
index 9ddadc2..8cbe3d5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTwoUploadTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTwoUploadTest.java
@@ -27,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerFileExistOverrideTwoUploadTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/exist?password=admin&tempPrefix=upload-&fileExist=Override&disconnect=true";
}
@@ -36,7 +36,7 @@ public class FtpProducerFileExistOverrideTwoUploadTest extends FtpServerTestSupp
template.sendBodyAndHeader(getFtpUrl(), "Hello World", Exchange.FILE_NAME, "hello.txt");
// the 1st file should be stored
- File file = new File(FTP_ROOT_DIR + "/exist/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/exist/hello.txt");
assertTrue(file.exists());
String body = context.getTypeConverter().convertTo(String.class, file);
@@ -48,7 +48,7 @@ public class FtpProducerFileExistOverrideTwoUploadTest extends FtpServerTestSupp
template.sendBodyAndHeader(getFtpUrl(), "Bye World", Exchange.FILE_NAME, "hello.txt");
// the 2nd file should also exists as we stored with override
- file = new File(FTP_ROOT_DIR + "/exist/hello.txt");
+ file = new File(service.getFtpRootDir() + "/exist/hello.txt");
assertTrue(file.exists());
body = context.getTypeConverter().convertTo(String.class, file);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileFastExistFailTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileFastExistFailTest.java
index d21ed00..9488d89 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileFastExistFailTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileFastExistFailTest.java
@@ -20,7 +20,7 @@ public class FtpProducerFileFastExistFailTest extends FtpProducerFileExistFailTe
@Override
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/exist?fastExistsCheck=true&password=admin&delay=2000&noop=true&fileExist=Fail";
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithCharsetTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithCharsetTest.java
index 957db84..7385132 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithCharsetTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithCharsetTest.java
@@ -39,7 +39,7 @@ public class FtpProducerFileWithCharsetTest extends FtpServerTestSupport {
private String payload = "\u00e6\u00f8\u00e5 \u00a9";
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload?charset=iso-8859-1&password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload?charset=iso-8859-1&password=admin";
}
@Override
@@ -64,7 +64,7 @@ public class FtpProducerFileWithCharsetTest extends FtpServerTestSupport {
public void testProducerWithCharset() throws Exception {
sendFile(getFtpUrl(), payload, "charset/iso.txt");
- File file = new File(FTP_ROOT_DIR + "/upload/charset/iso.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/charset/iso.txt");
assertTrue(file.exists(), "The uploaded file should exists");
String fileContent = new String(IOConverter.toByteArray(file), "iso-8859-1");
assertEquals(fileContent, payload);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathNoStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathNoStepwiseTest.java
index 67e5946..98c984a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathNoStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathNoStepwiseTest.java
@@ -27,14 +27,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerFileWithPathNoStepwiseTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload?password=admin&stepwise=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload?password=admin&stepwise=false";
}
@Test
public void testProducerFileWithPathNoStepwise() throws Exception {
sendFile(getFtpUrl(), "Hello World", "hello/claus.txt");
- File file = new File(FTP_ROOT_DIR + "/upload/hello/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/hello/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorAutoNoStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorAutoNoStepwiseTest.java
index ade42d8..756a933 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorAutoNoStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorAutoNoStepwiseTest.java
@@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerFileWithPathPathSeparatorAutoNoStepwiseTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload?password=admin&stepwise=false&separator=Auto";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload?password=admin&stepwise=false&separator=Auto";
}
@Test
@@ -43,7 +43,7 @@ public class FtpProducerFileWithPathPathSeparatorAutoNoStepwiseTest extends FtpS
});
assertNotNull(out);
- File file = new File(FTP_ROOT_DIR + "/upload/hello/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/hello/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorUnixNoStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorUnixNoStepwiseTest.java
index ae1315a..ba8c551 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorUnixNoStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorUnixNoStepwiseTest.java
@@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerFileWithPathPathSeparatorUnixNoStepwiseTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload?password=admin&stepwise=false&separator=UNIX";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload?password=admin&stepwise=false&separator=UNIX";
}
@Test
@@ -43,7 +43,7 @@ public class FtpProducerFileWithPathPathSeparatorUnixNoStepwiseTest extends FtpS
});
assertNotNull(out);
- File file = new File(FTP_ROOT_DIR + "/upload/hello/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/hello/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorWindowsNoStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorWindowsNoStepwiseTest.java
index 20ea6af..c1bdc20 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorWindowsNoStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathPathSeparatorWindowsNoStepwiseTest.java
@@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerFileWithPathPathSeparatorWindowsNoStepwiseTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload?password=admin&stepwise=false&separator=Windows";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload?password=admin&stepwise=false&separator=Windows";
}
@Test
@@ -43,7 +43,7 @@ public class FtpProducerFileWithPathPathSeparatorWindowsNoStepwiseTest extends F
});
assertNotNull(out);
- File file = new File(FTP_ROOT_DIR + "/upload/hello/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/hello/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathTest.java
index bf30bab..205ed74 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileWithPathTest.java
@@ -27,14 +27,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerFileWithPathTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload?password=admin";
}
@Test
public void testProducerFileWithPath() throws Exception {
sendFile(getFtpUrl(), "Hello World", "hello/claus.txt");
- File file = new File(FTP_ROOT_DIR + "/upload/hello/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/hello/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerJailStartingDirectoryTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerJailStartingDirectoryTest.java
index 1dd1706..5c839b1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerJailStartingDirectoryTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerJailStartingDirectoryTest.java
@@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.fail;
public class FtpProducerJailStartingDirectoryTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload/jail?binary=false&password=admin&tempPrefix=.uploading";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload/jail?binary=false&password=admin&tempPrefix=.uploading";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMoveExistingTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMoveExistingTest.java
index ef4abed..0275732 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMoveExistingTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMoveExistingTest.java
@@ -25,7 +25,10 @@ import java.util.Random;
import org.apache.camel.CamelExecutionException;
import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFileOperationFailedException;
+import org.apache.camel.util.FileUtil;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
import static org.apache.camel.test.junit5.TestSupport.assertFileExists;
import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists;
@@ -34,13 +37,16 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-/**
- *
- */
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
-
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/move?password=admin&fileExist=Move";
+ return "ftp://admin@localhost:{{ftp.server.port}}/move?password=admin&fileExist=Move";
+ }
+
+ @AfterEach
+ public void cleanupDir() {
+ File moveToDir = new File(service.getFtpRootDir(), "/move");
+ FileUtil.removeDir(moveToDir);
}
@Test
@@ -48,8 +54,8 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&moveExisting=${file:parent}/renamed-${file:onlyname}", "Hello World",
Exchange.FILE_NAME, "hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
- assertFileNotExists(FTP_ROOT_DIR + "/move/renamed-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
+ assertFileNotExists(service.getFtpRootDir() + "/move/renamed-hello.txt");
}
@Test
@@ -59,13 +65,14 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&moveExisting=${file:parent}/renamed-${file:onlyname}", "Bye World",
Exchange.FILE_NAME, "hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
- assertFileExists(FTP_ROOT_DIR + "/move/renamed-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/renamed-hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/renamed-hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/renamed-hello.txt")));
}
@Test
@@ -79,13 +86,14 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
"Bye World", Exchange.FILE_NAME,
"hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
- assertFileExists(FTP_ROOT_DIR + "/move/renamed-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/renamed-hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/renamed-hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/renamed-hello.txt")));
}
@Test
@@ -97,11 +105,11 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&tempFileName=${file:onlyname}.temp&moveExisting=" + subdirPrefix
+ "-${date:now:yyyyMMddHHmmssSSS}/",
"Bye World", Exchange.FILE_NAME, "hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
- File folder = new File(FTP_ROOT_DIR + "/move");
+ File folder = new File(service.getFtpRootDir() + "/move");
String[] directories = folder.list(new FilenameFilter() {
@Override
public boolean accept(File current, String name) {
@@ -110,7 +118,7 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
}
});
assertEquals(1, directories.length);
- File movedFilePath = new File(FTP_ROOT_DIR + "/move/" + directories[0] + "/hello.txt");
+ File movedFilePath = new File(service.getFtpRootDir() + "/move/" + directories[0] + "/hello.txt");
assertTrue(movedFilePath.exists());
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, movedFilePath));
@@ -125,11 +133,11 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&tempFileName=${file:onlyname}.temp&moveExisting=${file:parent}/"
+ subdirPrefix + "-${date:now:yyyyMMddHHmmssSSS}/${file:onlyname}",
"Bye World", Exchange.FILE_NAME, "hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
- File folder = new File(FTP_ROOT_DIR + "/move");
+ File folder = new File(service.getFtpRootDir() + "/move");
String[] directories = folder.list(new FilenameFilter() {
@Override
public boolean accept(File current, String name) {
@@ -138,7 +146,7 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
}
});
assertEquals(1, directories.length);
- File movedFilePath = new File(FTP_ROOT_DIR + "/move/" + directories[0] + "/hello.txt");
+ File movedFilePath = new File(service.getFtpRootDir() + "/move/" + directories[0] + "/hello.txt");
assertTrue(movedFilePath.exists());
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, movedFilePath));
@@ -151,13 +159,14 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&tempFileName=${file:onlyname}.temp&moveExisting=archive", "Bye World",
Exchange.FILE_NAME, "hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
- assertFileExists(FTP_ROOT_DIR + "/move/archive/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/archive/hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/archive/hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/archive/hello.txt")));
}
@Test
@@ -165,14 +174,15 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
template.sendBodyAndHeader(getFtpUrl() + "&moveExisting=backup", "Hello World", Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeader(getFtpUrl() + "&moveExisting=backup", "Bye World", Exchange.FILE_NAME, "hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
// would move into sub directory and keep existing name as is
- assertFileExists(FTP_ROOT_DIR + "/move/backup/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/backup/hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/backup/hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/backup/hello.txt")));
}
@Test
@@ -192,14 +202,15 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
Exchange.FILE_NAME, "hello.txt");
// we could write the new file so the old context should be there
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
// and the renamed file should be overridden
- assertFileExists(FTP_ROOT_DIR + "/move/renamed-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/renamed-hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/renamed-hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/renamed-hello.txt")));
}
@Test
@@ -224,14 +235,15 @@ public class FtpProducerMoveExistingTest extends FtpServerTestSupport {
// we could not write the new file so the previous context should be
// there
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
// and the renamed file should be untouched
- assertFileExists(FTP_ROOT_DIR + "/move/renamed-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/renamed-hello.txt");
assertEquals("Old file",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/renamed-hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/renamed-hello.txt")));
}
private String generateRandomString(int targetStringLength) {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMultipleSiteCommandTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMultipleSiteCommandTest.java
index e93c0d3..0e07c7a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMultipleSiteCommandTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerMultipleSiteCommandTest.java
@@ -31,14 +31,14 @@ public class FtpProducerMultipleSiteCommandTest extends FtpServerTestSupport {
private String site = "help site\nhelp site";
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/site?password=admin&siteCommand=#site";
+ return "ftp://admin@localhost:{{ftp.server.port}}/site?password=admin&siteCommand=#site";
}
@Test
public void testSiteCommands() throws Exception {
sendFile(getFtpUrl(), "Hello World", "hello.txt");
- File file = new File(FTP_ROOT_DIR + "/site/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/site/hello.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRawPasswordTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRawPasswordTest.java
index 7f1b0e8..f241a9c 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRawPasswordTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRawPasswordTest.java
@@ -35,7 +35,7 @@ public class FtpProducerRawPasswordTest extends FtpServerTestSupport {
// a RAW value and should not be
// uri encoded. This allows us to use the password 'as is' containing +
// & and other signs
- return "ftp://joe@localhost:" + getPort() + "/upload?password=RAW(p+%w0&r)d)&binary=false";
+ return "ftp://joe@localhost:{{ftp.server.port}}/upload?password=RAW(p+%w0&r)d)&binary=false";
// END SNIPPET: e1
}
@@ -43,7 +43,7 @@ public class FtpProducerRawPasswordTest extends FtpServerTestSupport {
public void testRawPassword() throws Exception {
sendFile(getFtpUrl(), "Hello World", "camel.txt");
- File file = new File(FTP_ROOT_DIR + "/upload/camel.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/camel.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRecipientListParallelTimeoutTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRecipientListParallelTimeoutTest.java
index ce9d49e..d9e154b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRecipientListParallelTimeoutTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRecipientListParallelTimeoutTest.java
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
public class FtpProducerRecipientListParallelTimeoutTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin:admin@127.0.0.2:" + (getPort() - 1) + "/timeout";
+ return "ftp://admin:admin@127.0.0.2:" + (service.getPort() - 1) + "/timeout";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRecipientListTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRecipientListTest.java
index de283fd..0348993 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRecipientListTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRecipientListTest.java
@@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerRecipientListTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/list?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/list?password=admin";
}
@Test
@@ -35,13 +35,13 @@ public class FtpProducerRecipientListTest extends FtpServerTestSupport {
template.sendBodyAndHeader("direct:start", "Bye World", "foo", getFtpUrl() + "&fileName=bye.txt");
template.sendBodyAndHeader("direct:start", "Hi World", "foo", getFtpUrl() + "&fileName=hi.txt");
- File file1 = new File(FTP_ROOT_DIR + "/list/hello.txt");
+ File file1 = new File(service.getFtpRootDir() + "/list/hello.txt");
assertTrue(file1.exists(), "File should exists " + file1);
- File file2 = new File(FTP_ROOT_DIR + "/list/bye.txt");
+ File file2 = new File(service.getFtpRootDir() + "/list/bye.txt");
assertTrue(file1.exists(), "File should exists " + file2);
- File file3 = new File(FTP_ROOT_DIR + "/list/hi.txt");
+ File file3 = new File(service.getFtpRootDir() + "/list/hi.txt");
assertTrue(file1.exists(), "File should exists " + file3);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerReplyStringTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerReplyStringTest.java
index d456515..c1a9e29 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerReplyStringTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerReplyStringTest.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
public class FtpProducerReplyStringTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/reply?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/reply?password=admin";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRootFileExistFailTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRootFileExistFailTest.java
index 0743526..f3280d5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRootFileExistFailTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerRootFileExistFailTest.java
@@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
public class FtpProducerRootFileExistFailTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "?password=admin&fileExist=Fail";
+ return "ftp://admin@localhost:{{ftp.server.port}}?password=admin&fileExist=Fail";
}
@Override
@@ -52,6 +52,6 @@ public class FtpProducerRootFileExistFailTest extends FtpServerTestSupport {
assertEquals("File already exist: hello.txt. Cannot write new file.", cause.getMessage());
// root file should still exist
- assertFileExists(FTP_ROOT_DIR + "/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/hello.txt");
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerSendNoopFalseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerSendNoopFalseTest.java
index a4058fd..70c62da 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerSendNoopFalseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerSendNoopFalseTest.java
@@ -27,14 +27,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerSendNoopFalseTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload?password=admin&sendNoop=false";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload?password=admin&sendNoop=false";
}
@Test
public void testSendNoopFalse() throws Exception {
sendFile(getFtpUrl(), "Hello World", "hello/claus.txt");
- File file = new File(FTP_ROOT_DIR + "/upload/hello/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/hello/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerSiteCommandTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerSiteCommandTest.java
index 768883d..b932001 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerSiteCommandTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerSiteCommandTest.java
@@ -27,14 +27,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerSiteCommandTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/site?password=admin&siteCommand=help site";
+ return "ftp://admin@localhost:{{ftp.server.port}}/site?password=admin&siteCommand=help site";
}
@Test
public void testSiteCommand() throws Exception {
sendFile(getFtpUrl(), "Hello World", "hello.txt");
- File file = new File(FTP_ROOT_DIR + "/site/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/site/hello.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempFileExistIssueTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempFileExistIssueTest.java
index 6de5a31..b2d725f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempFileExistIssueTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempFileExistIssueTest.java
@@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerTempFileExistIssueTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tempprefix/?password=admin";
+ return "ftp://admin@localhost:{{ftp.server.port}}/tempprefix/?password=admin";
}
@Test
@@ -55,7 +55,7 @@ public class FtpProducerTempFileExistIssueTest extends FtpServerTestSupport {
Thread.sleep(500);
- File file = new File(FTP_ROOT_DIR + "/tempprefix/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/tempprefix/hello.txt");
assertEquals(true, file.exists());
assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));
}
@@ -71,7 +71,7 @@ public class FtpProducerTempFileExistIssueTest extends FtpServerTestSupport {
Thread.sleep(500);
- File file = new File(FTP_ROOT_DIR + "/tempprefix/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/tempprefix/hello.txt");
assertEquals(true, file.exists());
assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));
}
@@ -87,7 +87,7 @@ public class FtpProducerTempFileExistIssueTest extends FtpServerTestSupport {
Thread.sleep(500);
- File file = new File(FTP_ROOT_DIR + "/tempprefix/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/tempprefix/hello.txt");
assertEquals(true, file.exists());
assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));
}
@@ -103,7 +103,7 @@ public class FtpProducerTempFileExistIssueTest extends FtpServerTestSupport {
Thread.sleep(500);
- File file = new File(FTP_ROOT_DIR + "/tempprefix/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/tempprefix/hello.txt");
// should not write new file as we should ignore
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
}
@@ -124,7 +124,7 @@ public class FtpProducerTempFileExistIssueTest extends FtpServerTestSupport {
Thread.sleep(500);
- File file = new File(FTP_ROOT_DIR + "/tempprefix/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/tempprefix/hello.txt");
// should not write new file as we should ignore
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempPrefixTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempPrefixTest.java
index 4828c45..4cbfd2b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempPrefixTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempPrefixTest.java
@@ -30,14 +30,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpProducerTempPrefixTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/upload/user/claus?binary=false&password=admin&tempPrefix=.uploading";
+ return "ftp://admin@localhost:{{ftp.server.port}}/upload/user/claus?binary=false&password=admin&tempPrefix=.uploading";
}
@Test
public void testProduceTempPrefixTest() throws Exception {
sendFile(getFtpUrl(), "Hello World", "claus.txt");
- File file = new File(FTP_ROOT_DIR + "/upload/user/claus/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/upload/user/claus/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerToDMoveExistingTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerToDMoveExistingTest.java
index e4ee2a3..b5c402d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerToDMoveExistingTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerToDMoveExistingTest.java
@@ -31,7 +31,7 @@ import static org.apache.camel.test.junit5.TestSupport.assertFileExists;
public class FtpProducerToDMoveExistingTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/${header.myDir}?password=admin&fileExist=Move&moveExisting=old-${file:onlyname}";
}
@@ -47,8 +47,8 @@ public class FtpProducerToDMoveExistingTest extends FtpServerTestSupport {
assertMockEndpointsSatisfied();
- assertFileExists(FTP_ROOT_DIR + "/out/old-hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/out/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/out/old-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/out/hello.txt");
}
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptServerStoppedTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptServerStoppedTest.java
index 91a70b9..0652fbe 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptServerStoppedTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptServerStoppedTest.java
@@ -24,17 +24,18 @@ import org.junit.jupiter.api.Test;
public class FtpReconnectAttemptServerStoppedTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/reconnect?password=admin&maximumReconnectAttempts=2&reconnectDelay=500&delete=true";
}
@Test
public void testFromFileToFtp() throws Exception {
// suspect serve so we cannot connect
- ftpServer.suspend();
+ service.suspend();
// put a file in the folder (do not use ftp as we then will connect)
- template.sendBodyAndHeader("file:" + FTP_ROOT_DIR + "/reconnect", "Hello World", Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file:" + service.getFtpRootDir() + "/reconnect", "Hello World", Exchange.FILE_NAME,
+ "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(0);
@@ -48,7 +49,7 @@ public class FtpReconnectAttemptServerStoppedTest extends FtpServerTestSupport {
mock.expectedMessageCount(1);
// resume the server so we can connect
- ftpServer.resume();
+ service.resume();
// wait a bit so that the server resumes properly
Thread.sleep(3000);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptUnknownHostTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptUnknownHostTest.java
index 5ac6e53..0f421fd 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptUnknownHostTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpReconnectAttemptUnknownHostTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class FtpReconnectAttemptUnknownHostTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@doesnotexisthost:" + getPort() + "/reconnect?password=admin";
+ return "ftp://admin@doesnotexisthost:{{ftp.server.port}}/reconnect?password=admin";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth2Test.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth2Test.java
index 759c414..0b04070 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth2Test.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth2Test.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
public class FtpRecursiveDepth2Test extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/depth2?password=admin&recursive=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/depth2?password=admin&recursive=true";
}
@Test
@@ -32,17 +32,17 @@ public class FtpRecursiveDepth2Test extends FtpServerTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("a2", "b2", "a3", "b3");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth2?password=admin", "a", Exchange.FILE_NAME,
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth2?password=admin", "a", Exchange.FILE_NAME,
"a.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth2?password=admin", "b", Exchange.FILE_NAME,
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth2?password=admin", "b", Exchange.FILE_NAME,
"b.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth2/bar?password=admin", "b2",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth2/bar?password=admin", "b2",
Exchange.FILE_NAME, "b2.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth2/foo?password=admin", "a2",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth2/foo?password=admin", "a2",
Exchange.FILE_NAME, "a2.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth2/foo/bar?password=admin", "a3",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth2/foo/bar?password=admin", "a3",
Exchange.FILE_NAME, "a3.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth2/bar/foo?password=admin", "b3",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth2/bar/foo?password=admin", "b3",
Exchange.FILE_NAME, "b3.txt");
assertMockEndpointsSatisfied();
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth3Test.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth3Test.java
index 0fd3041..ec7d663 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth3Test.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepth3Test.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
public class FtpRecursiveDepth3Test extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/depth3?password=admin&recursive=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/depth3?password=admin&recursive=true";
}
@Test
@@ -32,17 +32,17 @@ public class FtpRecursiveDepth3Test extends FtpServerTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("a", "b");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth3?password=admin", "a", Exchange.FILE_NAME,
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth3?password=admin", "a", Exchange.FILE_NAME,
"a.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth3?password=admin", "b", Exchange.FILE_NAME,
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth3?password=admin", "b", Exchange.FILE_NAME,
"b.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth3/foo?password=admin", "a2",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth3/foo?password=admin", "a2",
Exchange.FILE_NAME, "a.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth3/foo/bar?password=admin", "a3",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth3/foo/bar?password=admin", "a3",
Exchange.FILE_NAME, "a.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth3/bar?password=admin", "b2",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth3/bar?password=admin", "b2",
Exchange.FILE_NAME, "b.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth3/bar/foo?password=admin", "b3",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth3/bar/foo?password=admin", "b3",
Exchange.FILE_NAME, "b.txt");
assertMockEndpointsSatisfied();
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepthTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepthTest.java
index 5a51b2b..c9ec3b1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepthTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRecursiveDepthTest.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
public class FtpRecursiveDepthTest extends FtpServerTestSupport {
protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/depth?password=admin&recursive=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/depth?password=admin&recursive=true";
}
@Test
@@ -32,17 +32,19 @@ public class FtpRecursiveDepthTest extends FtpServerTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("a2", "b2");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth?password=admin", "a", Exchange.FILE_NAME,
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth?password=admin", "a", Exchange.FILE_NAME,
"a.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth?password=admin", "b", Exchange.FILE_NAME,
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth?password=admin", "b", Exchange.FILE_NAME,
"b.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth/foo?password=admin", "a2", Exchange.FILE_NAME,
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth/foo?password=admin", "a2",
+ Exchange.FILE_NAME,
"a2.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth/foo/bar?password=admin", "a3",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth/foo/bar?password=admin", "a3",
Exchange.FILE_NAME, "a.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth/bar?password=admin", "b2", Exchange.FILE_NAME,
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth/bar?password=admin", "b2",
+ Exchange.FILE_NAME,
"b2.txt");
- template.sendBodyAndHeader("ftp://admin@localhost:" + getPort() + "/depth/bar/foo?password=admin", "b3",
+ template.sendBodyAndHeader("ftp://admin@localhost:{{ftp.server.port}}/depth/bar/foo?password=admin", "b3",
Exchange.FILE_NAME, "b.txt");
// only expect 2 of the 6 sent, those at depth 2
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java
index 16c69cc..cf6c563 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java
@@ -16,144 +16,20 @@
*/
package org.apache.camel.component.file.remote;
-import java.io.File;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Map;
-import java.util.Set;
-
import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.ftpserver.ConnectionConfigFactory;
-import org.apache.ftpserver.FtpServer;
-import org.apache.ftpserver.FtpServerFactory;
-import org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory;
-import org.apache.ftpserver.ftplet.UserManager;
-import org.apache.ftpserver.impl.DefaultFtpServer;
-import org.apache.ftpserver.impl.FtpIoSession;
-import org.apache.ftpserver.listener.Listener;
-import org.apache.ftpserver.listener.ListenerFactory;
-import org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor;
-import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.camel.component.file.remote.services.FtpEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
import static org.apache.camel.language.simple.SimpleLanguage.simple;
-import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Base class for unit testing using a FTPServer
*/
public abstract class FtpServerTestSupport extends BaseServerTestSupport {
-
- protected static final String FTP_ROOT_DIR = "./target/res/home";
- protected static final File USERS_FILE = new File("./src/test/resources/users.properties");
- protected static final String DEFAULT_LISTENER = "default";
-
- private static final Logger LOG = LoggerFactory.getLogger(FtpServerTestSupport.class);
-
- protected FtpServer ftpServer;
- protected boolean canTest;
-
- @Override
- @BeforeEach
- public void setUp() throws Exception {
- deleteDirectory(FTP_ROOT_DIR);
-
- canTest = false;
- initPort();
- FtpServerFactory factory = createFtpServerFactory();
- if (factory != null) {
- ftpServer = factory.createServer();
- if (ftpServer != null) {
- ftpServer.start();
- canTest = true;
- }
- }
-
- try {
- super.setUp();
- } catch (Exception e) {
- // ignore if algorithm is not on the OS
- NoSuchAlgorithmException nsae = ObjectHelper.getException(NoSuchAlgorithmException.class, e);
- if (nsae != null) {
- canTest = false;
-
- String name = System.getProperty("os.name");
- String message = nsae.getMessage();
- LOG.warn("SunX509 is not avail on this platform [{}] Testing is skipped! Real cause: {}", name, message);
- } else {
- // some other error then throw it so the test can fail
- throw e;
- }
- }
- }
-
- @Override
- @AfterEach
- public void tearDown() throws Exception {
- super.tearDown();
-
- if (ftpServer != null) {
- try {
- ftpServer.stop();
- ftpServer = null;
- } catch (Exception e) {
- // ignore while shutting down as we could be polling during
- // shutdown
- // and get errors when the ftp server is stopping. This is only
- // an issue
- // since we host the ftp server embedded in the same jvm for
- // unit testing
- }
- }
- }
-
- protected boolean canTest() {
- return canTest;
- }
-
- protected FtpServerFactory createFtpServerFactory() throws Exception {
- assertTrue(USERS_FILE.exists());
- assertTrue(getPort() > 0, "Port number is not initialized in an expected range: " + getPort());
-
- NativeFileSystemFactory fsf = new NativeFileSystemFactory();
- fsf.setCreateHome(true);
-
- PropertiesUserManagerFactory pumf = new PropertiesUserManagerFactory();
- pumf.setAdminName("admin");
- pumf.setPasswordEncryptor(new ClearTextPasswordEncryptor());
- pumf.setFile(USERS_FILE);
- UserManager userMgr = pumf.createUserManager();
-
- ListenerFactory factory = new ListenerFactory();
- factory.setPort(getPort());
-
- FtpServerFactory serverFactory = new FtpServerFactory();
- serverFactory.setUserManager(userMgr);
- serverFactory.setFileSystem(fsf);
- serverFactory.setConnectionConfig(new ConnectionConfigFactory().createConnectionConfig());
- serverFactory.addListener(DEFAULT_LISTENER, factory.createListener());
-
- return serverFactory;
- }
+ @RegisterExtension
+ static FtpEmbeddedService service = new FtpEmbeddedService();
public void sendFile(String url, Object body, String fileName) {
template.sendBodyAndHeader(url, body, Exchange.FILE_NAME, simple(fileName));
}
-
- protected void disconnectAllSessions() throws IOException {
- // stop all listeners
- Map<String, Listener> listeners = ((DefaultFtpServer) ftpServer).getListeners();
- for (Listener listener : listeners.values()) {
- Set<FtpIoSession> sessions = listener.getActiveSessions();
- for (FtpIoSession session : sessions) {
- session.closeNow();
- }
- }
- }
-
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteAllTasksTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteAllTasksTest.java
index 6a746b8..2e1b6c3 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteAllTasksTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteAllTasksTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
public class FtpShutdownCompleteAllTasksTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/pending?password=admin&initialDelay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/pending?password=admin&initialDelay=5000";
}
@Override
@@ -44,7 +44,7 @@ public class FtpShutdownCompleteAllTasksTest extends FtpServerTestSupport {
private void prepareFtpServer() throws Exception {
// prepares the FTP Server by creating files on the server that we want
// to unit
- String ftpUrl = "ftp://admin@localhost:" + getPort() + "/pending/?password=admin";
+ String ftpUrl = "ftp://admin@localhost:{{ftp.server.port}}/pending/?password=admin";
template.sendBodyAndHeader(ftpUrl, "A", Exchange.FILE_NAME, "a.txt");
template.sendBodyAndHeader(ftpUrl, "B", Exchange.FILE_NAME, "b.txt");
template.sendBodyAndHeader(ftpUrl, "C", Exchange.FILE_NAME, "c.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java
index a236f4e..b26eaf8 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpShutdownCompleteCurrentTaskOnlyTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/pending?password=admin&initialDelay=5000";
+ return "ftp://admin@localhost:{{ftp.server.port}}/pending?password=admin&initialDelay=5000";
}
@Override
@@ -44,7 +44,7 @@ public class FtpShutdownCompleteCurrentTaskOnlyTest extends FtpServerTestSupport
private void prepareFtpServer() throws Exception {
// prepares the FTP Server by creating files on the server that we want
// to unit
- String ftpUrl = "ftp://admin@localhost:" + getPort() + "/pending/?password=admin";
+ String ftpUrl = "ftp://admin@localhost:{{ftp.server.port}}/pending/?password=admin";
template.sendBodyAndHeader(ftpUrl, "A", Exchange.FILE_NAME, "a.txt");
template.sendBodyAndHeader(ftpUrl, "B", Exchange.FILE_NAME, "b.txt");
template.sendBodyAndHeader(ftpUrl, "C", Exchange.FILE_NAME, "c.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeAbsoluteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeAbsoluteTest.java
index 342dfcd..18b4712 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeAbsoluteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeAbsoluteTest.java
@@ -25,16 +25,12 @@ public class FtpSimpleConsumeAbsoluteTest extends FtpServerTestSupport {
@Test
public void testFtpSimpleConsumeAbsolute() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
// FTP Server does not support absolute path, so lets simulate it
- String path = FTP_ROOT_DIR + "/tmp/mytemp";
+ String path = service.getFtpRootDir() + "/tmp/mytemp";
template.sendBodyAndHeader("file:" + path, expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
@@ -54,7 +50,7 @@ public class FtpSimpleConsumeAbsoluteTest extends FtpServerTestSupport {
// notice we use an absolute starting path: /tmp/mytemp
// - we must remember to use // slash because of the url
// separator
- from("ftp://localhost:" + getPort() + "//tmp/mytemp?username=admin&password=admin&delay=10000&disconnect=true")
+ from("ftp://localhost:{{ftp.server.port}}//tmp/mytemp?username=admin&password=admin&delay=10000&disconnect=true")
.routeId("foo").noAutoStartup().to("mock:result");
}
};
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeDirectoryParseWithAbsoluteDepthNoStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeDirectoryParseWithAbsoluteDepthNoStepwiseTest.java
index 14c435e..505b1fe 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeDirectoryParseWithAbsoluteDepthNoStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeDirectoryParseWithAbsoluteDepthNoStepwiseTest.java
@@ -25,16 +25,12 @@ public class FtpSimpleConsumeDirectoryParseWithAbsoluteDepthNoStepwiseTest exten
@Test
public void testFtpSimpleConsumeAbsolute() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
// FTP Server does not support absolute path, so lets simulate it
- String path = FTP_ROOT_DIR + "/tmp/mytemp";
+ String path = service.getFtpRootDir() + "/tmp/mytemp";
template.sendBodyAndHeader("file:" + path, expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
@@ -51,7 +47,7 @@ public class FtpSimpleConsumeDirectoryParseWithAbsoluteDepthNoStepwiseTest exten
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("ftp://localhost:" + getPort() + "//tmp/mytemp?username=admin&password=admin&delay=10000"
+ from("ftp://localhost:{{ftp.server.port}}//tmp/mytemp?username=admin&password=admin&delay=10000"
+ "&disconnect=true&download=true&stepwise=false&delete=false&handleDirectoryParserAbsoluteResult=true")
.routeId("foo").noAutoStartup().to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingPartialReadTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingPartialReadTest.java
index 3da000a..71e0225 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingPartialReadTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingPartialReadTest.java
@@ -33,16 +33,12 @@ public class FtpSimpleConsumeStreamingPartialReadTest extends FtpServerTestSuppo
@Test
public void testFtpSimpleConsumeAbsolute() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
// FTP Server does not support absolute path, so lets simulate it
- String path = FTP_ROOT_DIR + "/tmp/mytemp";
+ String path = service.getFtpRootDir() + "/tmp/mytemp";
template.sendBodyAndHeader("file:" + path, expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
@@ -68,7 +64,7 @@ public class FtpSimpleConsumeStreamingPartialReadTest extends FtpServerTestSuppo
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("ftp://localhost:" + getPort()
+ from("ftp://localhost:{{ftp.server.port}}"
+ "/tmp/mytemp?username=admin&password=admin&delay=10000&disconnect=true&streamDownload=true"
+ "&move=done&moveFailed=failed&stepwise=false")
.routeId("foo").noAutoStartup().process(new Processor() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseFalseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseFalseTest.java
index d983250..590aec6 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseFalseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseFalseTest.java
@@ -34,16 +34,12 @@ public class FtpSimpleConsumeStreamingStepwiseFalseTest extends FtpServerTestSup
@Test
public void testFtpSimpleConsumeAbsolute() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
// FTP Server does not support absolute path, so lets simulate it
- String path = FTP_ROOT_DIR + "/tmp/mytemp";
+ String path = service.getFtpRootDir() + "/tmp/mytemp";
template.sendBodyAndHeader("file:" + path, expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint();
@@ -71,7 +67,7 @@ public class FtpSimpleConsumeStreamingStepwiseFalseTest extends FtpServerTestSup
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("ftp://localhost:" + getPort()
+ from("ftp://localhost:{{ftp.server.port}}"
+ "/tmp/mytemp?username=admin&password=admin&delay=10000&disconnect=true&streamDownload=true&stepwise="
+ String.valueOf(isStepwise())).routeId("foo").noAutoStartup()
.to("mock:result");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingWithMultipleFilesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingWithMultipleFilesTest.java
index 8916733..a96f97f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingWithMultipleFilesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingWithMultipleFilesTest.java
@@ -30,17 +30,13 @@ public class FtpSimpleConsumeStreamingWithMultipleFilesTest extends FtpServerTes
@Test
public void testFtpSimpleConsumeAbsolute() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
String expected2 = "Goodbye World";
// create file using regular file
// FTP Server does not support absolute path, so lets simulate it
- String path = FTP_ROOT_DIR + "/tmp/mytemp";
+ String path = service.getFtpRootDir() + "/tmp/mytemp";
template.sendBodyAndHeader("file:" + path, expected, Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeader("file:" + path, expected2, Exchange.FILE_NAME, "goodbye.txt");
@@ -63,7 +59,7 @@ public class FtpSimpleConsumeStreamingWithMultipleFilesTest extends FtpServerTes
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("ftp://localhost:" + getPort()
+ from("ftp://localhost:{{ftp.server.port}}"
+ "/tmp/mytemp?username=admin&password=admin&delay=10000&disconnect=true&streamDownload=true&stepwise=false")
.routeId("foo").noAutoStartup()
.to("mock:result");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java
index c618c5f..b79ea7f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpStreamingMoveTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort()
+ return "ftp://admin@localhost:{{ftp.server.port}}"
+ "/mymove?password=admin&delay=1000&streamDownload=true&move=done&stepwise=false";
}
@@ -44,10 +44,6 @@ public class FtpStreamingMoveTest extends FtpServerTestSupport {
@Test
public void testStreamDownloadMove() throws Exception {
- if (!canTest()) {
- return;
- }
-
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
@@ -63,7 +59,7 @@ public class FtpStreamingMoveTest extends FtpServerTestSupport {
// give time for consumer to rename file
Thread.sleep(1000);
- File file = new File(FTP_ROOT_DIR + "/mymove/done/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/mymove/done/hello.txt");
assertTrue(file.exists(), "File should have been renamed");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpThrowExceptionOnConnectionFailedTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpThrowExceptionOnConnectionFailedTest.java
index 445295d..9fdbca3 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpThrowExceptionOnConnectionFailedTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpThrowExceptionOnConnectionFailedTest.java
@@ -44,13 +44,13 @@ public class FtpThrowExceptionOnConnectionFailedTest extends FtpServerTestSuppor
}
// assert file NOT created
- File file = new File(FTP_ROOT_DIR + "login/report.txt");
+ File file = new File(service.getFtpRootDir() + "login/report.txt");
assertFalse(file.exists(), "The file should NOT exists");
}
private void uploadFile(String username, String password) throws Exception {
Endpoint endpoint = context
- .getEndpoint("ftp://" + username + "@localhost:" + getPort() + "/login?password=" + password
+ .getEndpoint("ftp://" + username + "@localhost:{{ftp.server.port}}/login?password=" + password
+ "&maximumReconnectAttempts=0&throwExceptionOnConnectFailed=true");
Exchange exchange = endpoint.createExchange();
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitSSLWithClientAuthTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitSSLWithClientAuthTestSupport.java
index 6fa2c12..5890e92 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitSSLWithClientAuthTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitSSLWithClientAuthTestSupport.java
@@ -16,35 +16,19 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
/**
* Abstract base class for unit testing using a secure FTP Server over SSL (explicit) and with client authentication.
*/
public abstract class FtpsServerExplicitSSLWithClientAuthTestSupport extends FtpsServerTestSupport {
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getClientAuth()
- */
- @Override
- protected String getClientAuth() {
- return "true";
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * useImplicit()
- */
- @Override
- protected boolean useImplicit() {
- return false;
- }
+ @RegisterExtension
+ static FtpsEmbeddedService service = new FtpsEmbeddedService(false, AUTH_VALUE_SSL, true);
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getAuthValue()
- */
- @Override
- protected String getAuthValue() {
- return AUTH_VALUE_SSL;
+ @Deprecated
+ public static int getPort() {
+ return service.getPort();
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitSSLWithoutClientAuthTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitSSLWithoutClientAuthTestSupport.java
index 1754528..fb8e5f8 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitSSLWithoutClientAuthTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitSSLWithoutClientAuthTestSupport.java
@@ -16,35 +16,19 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
/**
* Abstract base class for unit testing using a secure FTP Server over SSL (explicit) and without client authentication.
*/
public abstract class FtpsServerExplicitSSLWithoutClientAuthTestSupport extends FtpsServerTestSupport {
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getClientAuth()
- */
- @Override
- protected String getClientAuth() {
- return "false";
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * useImplicit()
- */
- @Override
- protected boolean useImplicit() {
- return false;
- }
+ @RegisterExtension
+ static FtpsEmbeddedService service = new FtpsEmbeddedService(false, AUTH_VALUE_SSL, false);
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getAuthValue()
- */
- @Override
- protected String getAuthValue() {
- return AUTH_VALUE_SSL;
+ @Deprecated
+ public static int getPort() {
+ return service.getPort();
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitTLSWithClientAuthTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitTLSWithClientAuthTestSupport.java
index 4b18910..4f94aa0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitTLSWithClientAuthTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitTLSWithClientAuthTestSupport.java
@@ -16,35 +16,19 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
/**
* Abstract base class for unit testing using a secure FTP Server over TLS (explicit) and with client authentication.
*/
public abstract class FtpsServerExplicitTLSWithClientAuthTestSupport extends FtpsServerTestSupport {
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getClientAuth()
- */
- @Override
- protected String getClientAuth() {
- return "true";
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * useImplicit()
- */
- @Override
- protected boolean useImplicit() {
- return false;
- }
+ @RegisterExtension
+ static FtpsEmbeddedService service = new FtpsEmbeddedService(false, AUTH_VALUE_TLS, true);
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getAuthValue()
- */
- @Override
- protected String getAuthValue() {
- return AUTH_VALUE_TLS;
+ @Deprecated
+ public static int getPort() {
+ return service.getPort();
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitTLSWithoutClientAuthTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitTLSWithoutClientAuthTestSupport.java
index 569c292..23e1865 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitTLSWithoutClientAuthTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerExplicitTLSWithoutClientAuthTestSupport.java
@@ -16,35 +16,13 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
/**
* Abstract base class for unit testing using a secure FTP Server over TLS (explicit) and without client authentication.
*/
public abstract class FtpsServerExplicitTLSWithoutClientAuthTestSupport extends FtpsServerTestSupport {
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getClientAuth()
- */
- @Override
- protected String getClientAuth() {
- return "false";
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * useImplicit()
- */
- @Override
- protected boolean useImplicit() {
- return false;
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getAuthValue()
- */
- @Override
- protected String getAuthValue() {
- return AUTH_VALUE_TLS;
- }
+ @RegisterExtension
+ static FtpsEmbeddedService service = new FtpsEmbeddedService(false, AUTH_VALUE_TLS, false);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitSSLWithClientAuthTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitSSLWithClientAuthTestSupport.java
index 0a4bd01..f0547cb 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitSSLWithClientAuthTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitSSLWithClientAuthTestSupport.java
@@ -16,35 +16,18 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
/**
* Abstract base class for unit testing using a secure FTP Server over SSL (implicit) and with client authentication.
*/
public abstract class FtpsServerImplicitSSLWithClientAuthTestSupport extends FtpsServerTestSupport {
+ @RegisterExtension
+ static FtpsEmbeddedService service = new FtpsEmbeddedService(true, AUTH_VALUE_SSL, true);
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getClientAuth()
- */
- @Override
- protected String getClientAuth() {
- return "true";
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * useImplicit()
- */
- @Override
- protected boolean useImplicit() {
- return true;
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getAuthValue()
- */
- @Override
- protected String getAuthValue() {
- return AUTH_VALUE_SSL;
+ @Deprecated
+ public static int getPort() {
+ return service.getPort();
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitSSLWithoutClientAuthTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitSSLWithoutClientAuthTestSupport.java
index a43c621..6cf464c 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitSSLWithoutClientAuthTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitSSLWithoutClientAuthTestSupport.java
@@ -16,35 +16,18 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
/**
* Abstract base class for unit testing using a secure FTP Server over SSL (implicit) and without client authentication.
*/
public abstract class FtpsServerImplicitSSLWithoutClientAuthTestSupport extends FtpsServerTestSupport {
+ @RegisterExtension
+ static FtpsEmbeddedService service = new FtpsEmbeddedService(true, AUTH_VALUE_SSL, false);
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getClientAuth()
- */
- @Override
- protected String getClientAuth() {
- return "false";
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * useImplicit()
- */
- @Override
- protected boolean useImplicit() {
- return true;
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getAuthValue()
- */
- @Override
- protected String getAuthValue() {
- return AUTH_VALUE_SSL;
+ @Deprecated
+ public static int getPort() {
+ return service.getPort();
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitTLSWithClientAuthTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitTLSWithClientAuthTestSupport.java
index b3c9c33..f838d52 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitTLSWithClientAuthTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitTLSWithClientAuthTestSupport.java
@@ -16,35 +16,18 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
/**
* Abstract base class for unit testing using a secure FTP Server over TLS (implicit) and with client authentication.
*/
public abstract class FtpsServerImplicitTLSWithClientAuthTestSupport extends FtpsServerTestSupport {
+ @RegisterExtension
+ static FtpsEmbeddedService service = new FtpsEmbeddedService(true, AUTH_VALUE_TLS, true);
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getClientAuth()
- */
- @Override
- protected String getClientAuth() {
- return "true";
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * useImplicit()
- */
- @Override
- protected boolean useImplicit() {
- return true;
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getAuthValue()
- */
- @Override
- protected String getAuthValue() {
- return AUTH_VALUE_TLS;
+ @Deprecated
+ public static int getPort() {
+ return service.getPort();
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitTLSWithoutClientAuthTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitTLSWithoutClientAuthTestSupport.java
index 0d93eae..2d728f1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitTLSWithoutClientAuthTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerImplicitTLSWithoutClientAuthTestSupport.java
@@ -16,35 +16,19 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.component.file.remote.services.FtpsEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
/**
* Abstract base class for unit testing using a secure FTP Server over TLS (implicit) and without client authentication.
*/
public abstract class FtpsServerImplicitTLSWithoutClientAuthTestSupport extends FtpsServerTestSupport {
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getClientAuth()
- */
- @Override
- protected String getClientAuth() {
- return "false";
- }
-
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * useImplicit()
- */
- @Override
- protected boolean useImplicit() {
- return true;
- }
+ @RegisterExtension
+ static FtpsEmbeddedService service = new FtpsEmbeddedService(true, AUTH_VALUE_TLS, false);
- /*
- * @see org.apache.camel.component.file.remote.FtpServerSecureTestSupport#
- * getAuthValue()
- */
- @Override
- protected String getAuthValue() {
- return AUTH_VALUE_TLS;
+ @Deprecated
+ public static int getPort() {
+ return service.getPort();
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerTestSupport.java
index b883ac9..d34ba9b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsServerTestSupport.java
@@ -16,113 +16,10 @@
*/
package org.apache.camel.component.file.remote;
-import java.io.File;
-import java.security.NoSuchAlgorithmException;
-
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.TrustManagerFactory;
-
-import org.apache.camel.util.ObjectHelper;
-import org.apache.ftpserver.FtpServerFactory;
-import org.apache.ftpserver.listener.ListenerFactory;
-import org.apache.ftpserver.ssl.SslConfigurationFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Abstract base class for unit testing using a secure FTP Server (over SSL/TLS)
*/
-public abstract class FtpsServerTestSupport extends FtpServerTestSupport {
-
+public abstract class FtpsServerTestSupport extends BaseServerTestSupport {
protected static final String AUTH_VALUE_SSL = "SSLv3";
protected static final String AUTH_VALUE_TLS = "TLSv1.2";
-
- protected static final File FTPSERVER_KEYSTORE = new File("./src/test/resources/server.jks");
- protected static final String FTPSERVER_KEYSTORE_PASSWORD = "password";
-
- private static final Logger LOG = LoggerFactory.getLogger(FtpsServerTestSupport.class);
-
- @Override
- protected FtpServerFactory createFtpServerFactory() throws Exception {
- try {
- LOG.info("KeyManagerFactory using the default algorithm {}", KeyManagerFactory.getDefaultAlgorithm());
- LOG.info("TrustManagerFactory using the default algorithm {}", TrustManagerFactory.getDefaultAlgorithm());
-
- return doCreateFtpServerFactory();
- } catch (Exception e) {
- // ignore if algorithm is not on the OS
- NoSuchAlgorithmException nsae = ObjectHelper.getException(NoSuchAlgorithmException.class, e);
- if (nsae != null) {
- String name = System.getProperty("os.name");
- String message = nsae.getMessage();
- LOG.warn("SunX509 is not avail on this platform [{}] Testing is skipped! Real cause: {}", name, message);
-
- return null;
- } else {
- // some other error then throw it so the test can fail
- throw e;
- }
- }
- }
-
- protected FtpServerFactory doCreateFtpServerFactory() throws Exception {
- assertTrue(FTPSERVER_KEYSTORE.exists());
-
- FtpServerFactory serverFactory = super.createFtpServerFactory();
-
- ListenerFactory listenerFactory = new ListenerFactory(serverFactory.getListener(DEFAULT_LISTENER));
- listenerFactory.setImplicitSsl(useImplicit());
- listenerFactory.setSslConfiguration(createSslConfiguration().createSslConfiguration());
-
- serverFactory.addListener(DEFAULT_LISTENER, listenerFactory.createListener());
-
- return serverFactory;
- }
-
- protected SslConfigurationFactory createSslConfiguration() {
- // comment in, if you have trouble with SSL
- // System.setProperty("javax.net.debug", "all");
-
- SslConfigurationFactory sslConfigFactory = new SslConfigurationFactory();
- sslConfigFactory.setSslProtocol(getAuthValue());
-
- sslConfigFactory.setKeystoreFile(FTPSERVER_KEYSTORE);
- sslConfigFactory.setKeystoreType("JKS");
-
- sslConfigFactory.setKeystoreAlgorithm("SunX509");
- sslConfigFactory.setKeystorePassword(FTPSERVER_KEYSTORE_PASSWORD);
- sslConfigFactory.setKeyPassword(FTPSERVER_KEYSTORE_PASSWORD);
-
- sslConfigFactory.setClientAuthentication(getClientAuth());
-
- if (Boolean.valueOf(getClientAuth())) {
- sslConfigFactory.setTruststoreFile(FTPSERVER_KEYSTORE);
- sslConfigFactory.setTruststoreType("JKS");
- sslConfigFactory.setTruststoreAlgorithm("SunX509");
- sslConfigFactory.setTruststorePassword(FTPSERVER_KEYSTORE_PASSWORD);
- }
-
- return sslConfigFactory;
- }
-
- /**
- * Set what client authentication level to use, supported values are "yes" or "true" for required authentication,
- * "want" for wanted authentication and "false" or "none" for no authentication. Defaults to "none".
- *
- * @return clientAuthReqd
- */
- protected abstract String getClientAuth();
-
- /**
- * Should listeners created by this factory automatically be in SSL mode automatically or must the client explicitly
- * request to use SSL
- */
- protected abstract boolean useImplicit();
-
- /**
- * Set the SSL protocol used for this channel. Supported values are "SSL" and "TLS".
- */
- protected abstract String getAuthValue();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/PaddyRouteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/PaddyRouteTest.java
index bd84a41..4b6f8bd 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/PaddyRouteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/PaddyRouteTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class PaddyRouteTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/paddy/?password=admin&recursive=true";
+ return "ftp://admin@localhost:{{ftp.server.port}}/paddy/?password=admin&recursive=true";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RecipientListErrorHandlingIssueTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RecipientListErrorHandlingIssueTest.java
index a06951a..b0a8381 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RecipientListErrorHandlingIssueTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RecipientListErrorHandlingIssueTest.java
@@ -30,7 +30,7 @@ public class RecipientListErrorHandlingIssueTest extends FtpServerTestSupport {
// use a wrong password so we cannot login and get an exception so we
// can test that the error handler kick in and we know which endpoint
// failed
- return "ftp://admin@localhost:" + getPort() + "/recipientlist?password=denied";
+ return "ftp://admin@localhost:" + service.getPort() + "/recipientlist?password=denied";
}
@Test
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteFileProduceOverruleOnlyOnceTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteFileProduceOverruleOnlyOnceTest.java
index 95e2b6d..6be9294 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteFileProduceOverruleOnlyOnceTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteFileProduceOverruleOnlyOnceTest.java
@@ -41,7 +41,7 @@ public class RemoteFileProduceOverruleOnlyOnceTest extends FtpServerTestSupport
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedHeaderReceived(Exchange.FILE_NAME, "/sub/hello.txt");
- mock.expectedFileExists(FTP_ROOT_DIR + "/out/sub/ruled.txt", "Hello World");
+ mock.expectedFileExists(service.getFtpRootDir() + "/out/sub/ruled.txt", "Hello World");
mock.expectedFileExists("target/out/sub/hello.txt", "Hello World");
assertMockEndpointsSatisfied();
@@ -59,7 +59,7 @@ public class RemoteFileProduceOverruleOnlyOnceTest extends FtpServerTestSupport
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("direct:input").to("ftp://admin:admin@localhost:" + getPort() + "/out/").to("file://target/out",
+ from("direct:input").to("ftp://admin:admin@localhost:{{ftp.server.port}}/out/").to("file://target/out",
"mock:result");
}
};
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/SftpPollEnrichConsumeWithDisconnectAndDeleteTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/SftpPollEnrichConsumeWithDisconnectAndDeleteTest.java
index e638c8e..2e5c127 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/SftpPollEnrichConsumeWithDisconnectAndDeleteTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/SftpPollEnrichConsumeWithDisconnectAndDeleteTest.java
@@ -24,25 +24,25 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.remote.sftp.SftpServerTestSupport;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.condition.EnabledIf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertFalse;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpPollEnrichConsumeWithDisconnectAndDeleteTest extends SftpServerTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(SftpPollEnrichConsumeWithDisconnectAndDeleteTest.class);
+ @Timeout(value = 30)
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -65,7 +65,7 @@ public class SftpPollEnrichConsumeWithDisconnectAndDeleteTest extends SftpServer
// to
// be
// deleted
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
fileExists = file.exists();
if (fileExists) {
@@ -83,7 +83,7 @@ public class SftpPollEnrichConsumeWithDisconnectAndDeleteTest extends SftpServer
@Override
public void configure() throws Exception {
from("vm:trigger")
- .pollEnrich("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ .pollEnrich("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true&delete=true")
.routeId("foo").to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/ToFtpTempFileTargetFileExistTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/ToFtpTempFileTargetFileExistTest.java
index 21032a5..b2eab8b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/ToFtpTempFileTargetFileExistTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/ToFtpTempFileTargetFileExistTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class ToFtpTempFileTargetFileExistTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tempfile?password=admin&binary=false"
+ return "ftp://admin@localhost:{{ftp.server.port}}/tempfile?password=admin&binary=false"
+ "&fileName=./foo/bar/message.txt&tempFileName=${file:onlyname.noext}.tmp";
}
@@ -47,7 +47,7 @@ public class ToFtpTempFileTargetFileExistTest extends FtpServerTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Hello Again World");
- mock.expectedFileExists(FTP_ROOT_DIR + "/tempfile/foo/bar/message.txt", "Hello Again World");
+ mock.expectedFileExists(service.getFtpRootDir() + "/tempfile/foo/bar/message.txt", "Hello Again World");
template.sendBody("direct:start", "Hello Again World");
@@ -66,7 +66,7 @@ public class ToFtpTempFileTargetFileExistTest extends FtpServerTestSupport {
producer.stop();
// assert file is created
- File file = new File(FTP_ROOT_DIR + "/tempfile/foo/bar/message.txt");
+ File file = new File(service.getFtpRootDir() + "/tempfile/foo/bar/message.txt");
assertTrue(file.exists(), "The file should exists");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpEmbeddedService.java
similarity index 53%
copy from components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java
copy to components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpEmbeddedService.java
index 16c69cc..da48af2 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpServerTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpEmbeddedService.java
@@ -14,16 +14,18 @@
* 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.services;
import java.io.File;
import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
import java.util.Map;
import java.util.Set;
-import org.apache.camel.Exchange;
-import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.infra.ftp.common.FtpProperties;
+import org.apache.camel.test.infra.ftp.services.FtpService;
+import org.apache.camel.util.FileUtil;
import org.apache.ftpserver.ConnectionConfigFactory;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
@@ -35,91 +37,33 @@ import org.apache.ftpserver.listener.Listener;
import org.apache.ftpserver.listener.ListenerFactory;
import org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor;
import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.camel.language.simple.SimpleLanguage.simple;
-import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * Base class for unit testing using a FTPServer
- */
-public abstract class FtpServerTestSupport extends BaseServerTestSupport {
-
- protected static final String FTP_ROOT_DIR = "./target/res/home";
- protected static final File USERS_FILE = new File("./src/test/resources/users.properties");
+public class FtpEmbeddedService implements FtpService {
protected static final String DEFAULT_LISTENER = "default";
- private static final Logger LOG = LoggerFactory.getLogger(FtpServerTestSupport.class);
+ private static final Logger LOG = LoggerFactory.getLogger(FtpEmbeddedService.class);
+ private static final File USERS_FILE = new File("./src/test/resources/users.properties");
+ private static final String FTP_ROOT_DIR = "./target/res/home";
protected FtpServer ftpServer;
- protected boolean canTest;
-
- @Override
- @BeforeEach
- public void setUp() throws Exception {
- deleteDirectory(FTP_ROOT_DIR);
+ protected int port;
- canTest = false;
- initPort();
- FtpServerFactory factory = createFtpServerFactory();
- if (factory != null) {
- ftpServer = factory.createServer();
- if (ftpServer != null) {
- ftpServer.start();
- canTest = true;
- }
- }
-
- try {
- super.setUp();
- } catch (Exception e) {
- // ignore if algorithm is not on the OS
- NoSuchAlgorithmException nsae = ObjectHelper.getException(NoSuchAlgorithmException.class, e);
- if (nsae != null) {
- canTest = false;
-
- String name = System.getProperty("os.name");
- String message = nsae.getMessage();
- LOG.warn("SunX509 is not avail on this platform [{}] Testing is skipped! Real cause: {}", name, message);
- } else {
- // some other error then throw it so the test can fail
- throw e;
- }
- }
+ public FtpEmbeddedService() {
+ port = AvailablePortFinder.getNextAvailable();
}
- @Override
- @AfterEach
- public void tearDown() throws Exception {
- super.tearDown();
-
- if (ftpServer != null) {
- try {
- ftpServer.stop();
- ftpServer = null;
- } catch (Exception e) {
- // ignore while shutting down as we could be polling during
- // shutdown
- // and get errors when the ftp server is stopping. This is only
- // an issue
- // since we host the ftp server embedded in the same jvm for
- // unit testing
- }
- }
- }
+ public void setUp() throws Exception {
+ FileUtil.removeDir(new File(FTP_ROOT_DIR));
- protected boolean canTest() {
- return canTest;
+ FtpServerFactory factory = createFtpServerFactory();
+ ftpServer = factory.createServer();
+ ftpServer.start();
}
- protected FtpServerFactory createFtpServerFactory() throws Exception {
- assertTrue(USERS_FILE.exists());
- assertTrue(getPort() > 0, "Port number is not initialized in an expected range: " + getPort());
-
+ protected FtpServerFactory createFtpServerFactory() {
NativeFileSystemFactory fsf = new NativeFileSystemFactory();
fsf.setCreateHome(true);
@@ -130,7 +74,7 @@ public abstract class FtpServerTestSupport extends BaseServerTestSupport {
UserManager userMgr = pumf.createUserManager();
ListenerFactory factory = new ListenerFactory();
- factory.setPort(getPort());
+ factory.setPort(port);
FtpServerFactory serverFactory = new FtpServerFactory();
serverFactory.setUserManager(userMgr);
@@ -141,11 +85,27 @@ public abstract class FtpServerTestSupport extends BaseServerTestSupport {
return serverFactory;
}
- public void sendFile(String url, Object body, String fileName) {
- template.sendBodyAndHeader(url, body, Exchange.FILE_NAME, simple(fileName));
+ public void tearDown() throws Exception {
+ if (ftpServer == null) {
+ return;
+ }
+
+ try {
+ ftpServer.stop();
+ ftpServer = null;
+ } catch (Exception e) {
+ // ignore while shutting down as we could be polling during
+ // shutdown
+ // and get errors when the ftp server is stopping. This is only
+ // an issue
+ // since we host the ftp server embedded in the same jvm for
+ // unit testing
+
+ LOG.trace("Exception while shutting down: {}", e.getMessage(), e);
+ }
}
- protected void disconnectAllSessions() throws IOException {
+ public void disconnectAllSessions() throws IOException {
// stop all listeners
Map<String, Listener> listeners = ((DefaultFtpServer) ftpServer).getListeners();
for (Listener listener : listeners.values()) {
@@ -156,4 +116,46 @@ public abstract class FtpServerTestSupport extends BaseServerTestSupport {
}
}
+ @Override
+ public void registerProperties() {
+ System.setProperty(FtpProperties.SERVER_HOST, "localhost");
+ System.setProperty(FtpProperties.SERVER_PORT, String.valueOf(port));
+ System.setProperty(FtpProperties.ROOT_DIR, FTP_ROOT_DIR);
+ }
+
+ @Override
+ public void initialize() {
+ try {
+ setUp();
+
+ registerProperties();
+ } catch (Exception e) {
+ Assertions.fail("Unable to initialize the FTP server " + e.getMessage());
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ try {
+ tearDown();
+ } catch (Exception e) {
+ Assertions.fail("Unable to terminate the FTP server " + e.getMessage());
+ }
+ }
+
+ public static String getFtpRootDir() {
+ return FTP_ROOT_DIR;
+ }
+
+ public void suspend() {
+ ftpServer.suspend();
+ }
+
+ public void resume() {
+ ftpServer.resume();
+ }
+
+ public int getPort() {
+ return port;
+ }
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpsEmbeddedService.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpsEmbeddedService.java
new file mode 100644
index 0000000..2ffd189
--- /dev/null
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/FtpsEmbeddedService.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.file.remote.services;
+
+import java.io.File;
+import java.security.NoSuchAlgorithmException;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.ftpserver.FtpServerFactory;
+import org.apache.ftpserver.listener.ListenerFactory;
+import org.apache.ftpserver.ssl.SslConfigurationFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FtpsEmbeddedService extends FtpEmbeddedService {
+ private static final Logger LOG = LoggerFactory.getLogger(FtpsEmbeddedService.class);
+ private static final File FTPSERVER_KEYSTORE = new File("./src/test/resources/server.jks");
+ private static final String FTPSERVER_KEYSTORE_PASSWORD = "password";
+
+ private boolean useImplicit;
+ private String authValue;
+ private boolean clientAuth;
+
+ public FtpsEmbeddedService(boolean useImplicit, String authValue, boolean clientAuth) {
+ super();
+
+ this.useImplicit = useImplicit;
+ this.authValue = authValue;
+ this.clientAuth = clientAuth;
+ }
+
+ @Override
+ protected FtpServerFactory createFtpServerFactory() {
+ FtpServerFactory serverFactory = super.createFtpServerFactory();
+
+ ListenerFactory listenerFactory = new ListenerFactory(serverFactory.getListener(DEFAULT_LISTENER));
+ listenerFactory.setImplicitSsl(useImplicit);
+ listenerFactory.setSslConfiguration(createSslConfiguration().createSslConfiguration());
+
+ serverFactory.addListener(DEFAULT_LISTENER, listenerFactory.createListener());
+
+ return serverFactory;
+ }
+
+ protected SslConfigurationFactory createSslConfiguration() {
+ // comment in, if you have trouble with SSL
+ // System.setProperty("javax.net.debug", "all");
+
+ SslConfigurationFactory sslConfigFactory = new SslConfigurationFactory();
+ sslConfigFactory.setSslProtocol(authValue);
+
+ sslConfigFactory.setKeystoreFile(FTPSERVER_KEYSTORE);
+ sslConfigFactory.setKeystoreType("JKS");
+ sslConfigFactory.setKeystoreAlgorithm("SunX509");
+ sslConfigFactory.setKeystorePassword(FTPSERVER_KEYSTORE_PASSWORD);
+ sslConfigFactory.setKeyPassword(FTPSERVER_KEYSTORE_PASSWORD);
+
+ sslConfigFactory.setClientAuthentication(authValue);
+
+ if (clientAuth) {
+ sslConfigFactory.setTruststoreFile(FTPSERVER_KEYSTORE);
+ sslConfigFactory.setTruststoreType("JKS");
+ sslConfigFactory.setTruststoreAlgorithm("SunX509");
+ sslConfigFactory.setTruststorePassword(FTPSERVER_KEYSTORE_PASSWORD);
+ }
+
+ return sslConfigFactory;
+ }
+
+ public static boolean hasRequiredAlgorithms() {
+ LOG.info("Checking if the system has the required algorithms for the test execution");
+ try {
+ KeyManagerFactory.getInstance("SunX509");
+ TrustManagerFactory.getInstance("SunX509");
+
+ return true;
+ } catch (NoSuchAlgorithmException e) {
+ String name = System.getProperty("os.name");
+ String message = e.getMessage();
+
+ LOG.warn("SunX509 is not available on this platform [{}] Testing is skipped! Real cause: {}", name, message, e);
+ return false;
+ }
+ }
+}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/SftpEmbeddedService.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/SftpEmbeddedService.java
new file mode 100644
index 0000000..d3f33a8
--- /dev/null
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/services/SftpEmbeddedService.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.file.remote.services;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.infra.ftp.common.FtpProperties;
+import org.apache.camel.test.infra.ftp.services.FtpService;
+import org.apache.camel.util.FileUtil;
+import org.apache.commons.io.FileUtils;
+import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory;
+import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
+import org.apache.sshd.common.session.helpers.AbstractSession;
+import org.apache.sshd.server.SshServer;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
+import org.apache.sshd.server.scp.ScpCommandFactory;
+import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
+import org.junit.jupiter.api.Assertions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.test.junit5.TestSupport.createDirectory;
+
+public class SftpEmbeddedService implements FtpService {
+ private static final Logger LOG = LoggerFactory.getLogger(SftpEmbeddedService.class);
+ private static final String FTP_ROOT_DIR = "target/res/home";
+ private static final String KNOWN_HOSTS = "[localhost]:%d ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDdfIWeSV4o68dRrKS"
+ + "zFd/Bk51E65UTmmSrmW0O1ohtzi6HzsDPjXgCtlTt3FqTcfFfI92IlTr4JWqC9UK1QT1ZTeng0MkPQmv68hDANHbt5CpETZHjW5q4OOgWhV"
+ + "vj5IyOC2NZHtKlJBkdsMAa15ouOOJLzBvAvbqOR/yUROsEiQ==";
+
+ protected SshServer sshd;
+ protected String oldUserHome;
+ protected final boolean rootDirMode;
+ protected final int port;
+
+ private String simulatedUserHome = "./target/user-home";
+ private String simulatedUserSsh = "./target/user-home/.ssh";
+
+ public SftpEmbeddedService() {
+ this(false);
+ }
+
+ public SftpEmbeddedService(boolean rootDirMode) {
+ port = AvailablePortFinder.getNextAvailable();
+ this.rootDirMode = rootDirMode;
+ }
+
+ public void setUp() throws Exception {
+ FileUtil.removeDir(new File(FTP_ROOT_DIR));
+
+ oldUserHome = System.getProperty("user.home");
+
+ System.setProperty("user.home", "target/user-home");
+
+ FileUtil.removeDir(new File(simulatedUserHome));
+ createDirectory(simulatedUserHome);
+ createDirectory(simulatedUserSsh);
+
+ FileUtils.writeByteArrayToFile(new File(simulatedUserSsh + "/known_hosts"), buildKnownHosts());
+
+ setUpServer();
+ }
+
+ public void setUpServer() throws Exception {
+ sshd = SshServer.setUpDefaultServer();
+ sshd.setPort(port);
+ sshd.setKeyPairProvider(new FileKeyPairProvider(Paths.get("src/test/resources/hostkey.pem")));
+ sshd.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory()));
+ sshd.setCommandFactory(new ScpCommandFactory());
+ sshd.setPasswordAuthenticator((username, password, session) -> true);
+ sshd.setPublickeyAuthenticator(getPublickeyAuthenticator());
+
+ if (rootDirMode) {
+ sshd.setFileSystemFactory(new VirtualFileSystemFactory(
+ FileSystems.getDefault().getPath(System.getProperty("user.dir") + "/target/res")));
+ }
+
+ sshd.start();
+ }
+
+ protected PublickeyAuthenticator getPublickeyAuthenticator() {
+ return (username, key, session) -> true;
+ }
+
+ public void tearDown() throws Exception {
+ if (oldUserHome != null) {
+ System.setProperty("user.home", oldUserHome);
+ } else {
+ System.clearProperty("user.home");
+ }
+
+ tearDownServer();
+ }
+
+ public void tearDownServer() {
+ if (sshd == null) {
+ return;
+ }
+
+ try {
+ // stop asap as we may hang forever
+ sshd.stop(true);
+
+ sshd = null;
+ } catch (Exception e) {
+ // ignore while shutting down as we could be polling during
+ // shutdown
+ // and get errors when the ftp server is stopping. This is only
+ // an issue
+ // since we host the ftp server embedded in the same jvm for
+ // unit testing
+ LOG.trace("Exception while shutting down: {}", e.getMessage(), e);
+ }
+ }
+
+ // disconnect all existing SSH sessions to test reconnect functionality
+ public void disconnectAllSessions() throws IOException {
+ List<AbstractSession> sessions = sshd.getActiveSessions();
+ for (AbstractSession session : sessions) {
+ session.disconnect(4, "dummy");
+ }
+ }
+
+ public byte[] buildKnownHosts() {
+ return String.format(KNOWN_HOSTS, port).getBytes();
+ }
+
+ public String getKnownHostsFile() {
+ return simulatedUserSsh + "/known_hosts";
+ }
+
+ public static String getFtpRootDir() {
+ return FTP_ROOT_DIR;
+ }
+
+ @Override
+ public void registerProperties() {
+ System.setProperty(FtpProperties.SERVER_HOST, "localhost");
+ System.setProperty(FtpProperties.SERVER_PORT, String.valueOf(port));
+ System.setProperty(FtpProperties.ROOT_DIR, FTP_ROOT_DIR);
+ }
+
+ @Override
+ public void initialize() {
+ try {
+ setUp();
+
+ registerProperties();
+ } catch (Exception e) {
+ Assertions.fail("Unable to initialize the SFTP server " + e.getMessage());
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ try {
+ tearDown();
+ } catch (Exception e) {
+ Assertions.fail("Unable to shutdown the SFTP server " + e.getMessage());
+ }
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public static boolean hasRequiredAlgorithms() {
+ try {
+ FileKeyPairProvider provider = new FileKeyPairProvider(Paths.get("src/test/resources/hostkey.pem"));
+
+ provider.loadKeys();
+ return true;
+ } catch (Exception e) {
+ String name = System.getProperty("os.name");
+ String message = e.getMessage();
+
+ LOG.warn("SunX509 is not available on this platform [{}] Testing is skipped! Real cause: {}", name, message, e);
+ return false;
+ }
+ }
+}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/FromSftpRecursiveNotStepwiseNoBasePathTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/FromSftpRecursiveNotStepwiseNoBasePathTest.java
index 834c293..acb94b1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/FromSftpRecursiveNotStepwiseNoBasePathTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/FromSftpRecursiveNotStepwiseNoBasePathTest.java
@@ -18,22 +18,28 @@ package org.apache.camel.component.file.remote.sftp;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.remote.BaseServerTestSupport;
+import org.apache.camel.component.file.remote.services.SftpEmbeddedService;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
-public class FromSftpRecursiveNotStepwiseNoBasePathTest extends SftpServerTestSupport {
+public class FromSftpRecursiveNotStepwiseNoBasePathTest extends BaseServerTestSupport {
+
+ @RegisterExtension
+ protected static SftpEmbeddedService service = new SftpEmbeddedService(true);
protected String getSftpUrl() {
- return "sftp://admin@localhost:" + getPort() + "?password=admin&initialDelay=3000&stepwise=false" + "&recursive=true";
+ return "sftp://admin@localhost:{{ftp.server.port}}?password=admin&initialDelay=3000&stepwise=false"
+ + "&recursive=true";
}
- @Override
@BeforeEach
- public void setUp() throws Exception {
- rootDirMode = true;
- super.setUp();
- prepareFtpServer();
+ public void prepareFtpServer() throws Exception {
+ sendFile("Bye World", "bye.txt");
+ sendFile("Hello World", "sub/hello.txt");
+ sendFile("Goodday World", "sub/sub2/godday.txt");
}
@Test
@@ -54,13 +60,7 @@ public class FromSftpRecursiveNotStepwiseNoBasePathTest extends SftpServerTestSu
};
}
- private void prepareFtpServer() throws Exception {
- sendFile("Bye World", "bye.txt");
- sendFile("Hello World", "sub/hello.txt");
- sendFile("Goodday World", "sub/sub2/godday.txt");
- }
-
public void sendFile(Object body, String fileName) {
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, body, Exchange.FILE_NAME, fileName);
+ template.sendBodyAndHeader("file://{{ftp.root.dir}}", body, Exchange.FILE_NAME, fileName);
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpChangedReadLockTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpChangedReadLockTest.java
index 4946f7e..84341c1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpChangedReadLockTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpChangedReadLockTest.java
@@ -23,6 +23,7 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,15 +31,13 @@ import static org.apache.camel.test.junit5.TestSupport.createDirectory;
import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
import static org.junit.jupiter.api.Assertions.assertEquals;
-/**
- *
- */
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpChangedReadLockTest extends SftpServerTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(SftpChangedReadLockTest.class);
protected String getFtpUrl() {
- return "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ return "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "/changed?username=admin&password=admin&readLock=changed&readLockCheckInterval=1000&delete=true";
}
@@ -51,10 +50,6 @@ public class SftpChangedReadLockTest extends SftpServerTestSupport {
@Test
public void testChangedReadLock() throws Exception {
- if (!canTest()) {
- return;
- }
-
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedFileExists("target/changed/out/slowfile.dat");
@@ -76,8 +71,8 @@ public class SftpChangedReadLockTest extends SftpServerTestSupport {
private void writeSlowFile() throws Exception {
LOG.debug("Writing slow file...");
- createDirectory(FTP_ROOT_DIR + "/changed");
- FileOutputStream fos = new FileOutputStream(FTP_ROOT_DIR + "/changed/slowfile.dat", true);
+ createDirectory(service.getFtpRootDir() + "/changed");
+ FileOutputStream fos = new FileOutputStream(service.getFtpRootDir() + "/changed/slowfile.dat", true);
for (int i = 0; i < 20; i++) {
fos.write(("Line " + i + LS).getBytes());
LOG.debug("Writing line " + i);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpChmodTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpChmodTest.java
index 9a7da72..c275c82 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpChmodTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpChmodTest.java
@@ -20,24 +20,22 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpChmodTest extends SftpServerTestSupport {
@Test
- public void testSftpChmod() throws Exception {
- if (!canTest()) {
- return;
- }
-
+ public void testSftpChmod() {
template.sendBodyAndHeader(
- "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&chmod=777",
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&password=admin&chmod=777",
"Hello World", Exchange.FILE_NAME,
"hello.txt");
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumeTemplateTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumeTemplateTest.java
index b0b9bf3..81a9e1f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumeTemplateTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumeTemplateTest.java
@@ -18,23 +18,22 @@ package org.apache.camel.component.file.remote.sftp;
import org.apache.camel.Exchange;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpConsumeTemplateTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, "Hello World", Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), "Hello World", Exchange.FILE_NAME, "hello.txt");
String out = consumer.receiveBody(
- "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin", 5000, String.class);
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&password=admin", 5000,
+ String.class);
assertNotNull(out);
// Apache SSHD appends \u0000 at last byte in retrieved file
assertTrue(out.startsWith("Hello World"));
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerAutoCreateTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerAutoCreateTest.java
index 99fd4d2..996299f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerAutoCreateTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerAutoCreateTest.java
@@ -21,36 +21,34 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFileOperationFailedException;
import org.apache.camel.component.file.remote.SftpEndpoint;
-import org.junit.jupiter.api.BeforeEach;
+import org.apache.camel.util.FileUtil;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpConsumerAutoCreateTest extends SftpServerTestSupport {
-
protected String getFtpUrl() {
- return "sftp://admin@localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/foo/bar/baz/xxx?password=admin";
+ return "sftp://admin@localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "/foo/bar/baz/xxx?password=admin";
}
- @Override
- @BeforeEach
- public void setUp() throws Exception {
- super.setUp();
+ @AfterEach
+ public void cleanupDir() {
+ FileUtil.removeDir(new File(service.getFtpRootDir(), "/foo/bar/baz/xxx"));
}
@Test
public void testAutoCreate() throws Exception {
- if (!canTest()) {
- return;
- }
SftpEndpoint endpoint = (SftpEndpoint) this.getMandatoryEndpoint(getFtpUrl() + "&autoCreate=true");
endpoint.start();
endpoint.getExchanges();
- assertTrue(new File(FTP_ROOT_DIR + "/foo/bar/baz/xxx").exists());
+ assertTrue(new File(service.getFtpRootDir() + "/foo/bar/baz/xxx").exists());
// producer should create necessary subdirs
template.sendBodyAndHeader(getFtpUrl(), "Hello World", Exchange.FILE_NAME, "sub1/sub2/hello.txt");
- assertTrue(new File(FTP_ROOT_DIR + "/foo/bar/baz/xxx/sub1/sub2").exists());
+ assertTrue(new File(service.getFtpRootDir() + "/foo/bar/baz/xxx/sub1/sub2").exists());
// to see if another connect causes problems with autoCreate=true
endpoint.stop();
@@ -59,15 +57,12 @@ public class SftpConsumerAutoCreateTest extends SftpServerTestSupport {
}
@Test
- public void testNoAutoCreate() throws Exception {
+ public void testNoAutoCreate() {
SftpEndpoint endpoint = (SftpEndpoint) this.getMandatoryEndpoint(getFtpUrl() + "&autoCreate=false");
endpoint.start();
- try {
- endpoint.getExchanges();
- fail("Should fail with 550 No such directory.");
- } catch (GenericFileOperationFailedException ignored) {
- // ignore
- }
+
+ assertThrows(GenericFileOperationFailedException.class, () -> endpoint.getExchanges(),
+ "Should fail with 550 No such directory.");
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerDisconnectTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerDisconnectTest.java
index 953587c..a5bb818 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerDisconnectTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerDisconnectTest.java
@@ -40,10 +40,6 @@ public class SftpConsumerDisconnectTest extends SftpServerTestSupport {
@Test
public void testConsumeDelete() throws Exception {
- if (!canTest()) {
- return;
- }
-
// prepare sample file to be consumed by SFTP consumer
createSampleFile(SAMPLE_FILE_NAME_1);
@@ -60,18 +56,14 @@ public class SftpConsumerDisconnectTest extends SftpServerTestSupport {
Thread.sleep(250);
// File is deleted
- File deletedFile = new File(FTP_ROOT_DIR + "/" + SAMPLE_FILE_NAME_1);
+ File deletedFile = new File(service.getFtpRootDir() + "/" + SAMPLE_FILE_NAME_1);
assertFalse(deletedFile.exists(), "File should have been deleted: " + deletedFile);
}
@Test
public void testConsumeMove() throws Exception {
- if (!canTest()) {
- return;
- }
-
// moved file after its processed
- String movedFile = FTP_ROOT_DIR + "/.camel/" + SAMPLE_FILE_NAME_2;
+ String movedFile = service.getFtpRootDir() + "/.camel/" + SAMPLE_FILE_NAME_2;
// prepare sample file to be consumed by SFTP consumer
createSampleFile(SAMPLE_FILE_NAME_2);
@@ -94,21 +86,22 @@ public class SftpConsumerDisconnectTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&delete=true")
- .routeId("foo").noAutoStartup().process(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- disconnectAllSessions(); // disconnect all Sessions from
- // the SFTP server
- }
- }).to("mock:result");
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ + "?username=admin&password=admin&delete=true")
+ .routeId("foo").noAutoStartup().process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ service.disconnectAllSessions(); // disconnect all Sessions from
+ // the SFTP server
+ }
+ }).to("mock:result");
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&noop=false&move=.camel").routeId("bar").noAutoStartup()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- disconnectAllSessions(); // disconnect all Sessions
- // from the SFTP server
+ service.disconnectAllSessions(); // disconnect all Sessions
+ // from the SFTP server
}
}).to("mock:result");
}
@@ -116,7 +109,7 @@ public class SftpConsumerDisconnectTest extends SftpServerTestSupport {
}
private void createSampleFile(String fileName) throws IOException {
- File file = new File(FTP_ROOT_DIR + "/" + fileName);
+ File file = new File(service.getFtpRootDir() + "/" + fileName);
FileUtils.write(file, SAMPLE_FILE_PAYLOAD, SAMPLE_FILE_CHARSET);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerProcessStrategyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerProcessStrategyTest.java
index bdc0f28..c21007a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerProcessStrategyTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerProcessStrategyTest.java
@@ -23,11 +23,13 @@ import org.apache.camel.component.file.GenericFileEndpoint;
import org.apache.camel.component.file.GenericFileOperations;
import org.apache.camel.component.file.GenericFileProcessStrategy;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpConsumerProcessStrategyTest extends SftpServerTestSupport {
@BindToRegistry("myStrategy")
@@ -35,14 +37,10 @@ public class SftpConsumerProcessStrategyTest extends SftpServerTestSupport {
@Test
public void testSftpConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, "Hello World", Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), "Hello World", Exchange.FILE_NAME, "hello.txt");
- String out = consumer.receiveBody("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ String out = consumer.receiveBody("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&processStrategy=#myStrategy",
5000, String.class);
assertNotNull(out);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerWithCharsetTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerWithCharsetTest.java
index 88a1344..da59146 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerWithCharsetTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpConsumerWithCharsetTest.java
@@ -26,10 +26,12 @@ import org.apache.camel.component.file.remote.RemoteFile;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpConsumerWithCharsetTest extends SftpServerTestSupport {
private static final String SAMPLE_FILE_NAME
@@ -45,10 +47,6 @@ public class SftpConsumerWithCharsetTest extends SftpServerTestSupport {
@Test
public void testConsumeWithCharset() throws Exception {
- if (!canTest()) {
- return;
- }
-
// prepare sample file to be consumed by SFTP consumer
createSampleFile();
@@ -74,7 +72,8 @@ public class SftpConsumerWithCharsetTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&charset="
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ + "?username=admin&password=admin&charset="
+ SAMPLE_FILE_CHARSET).routeId("foo").noAutoStartup()
.to("mock:result");
}
@@ -82,7 +81,7 @@ public class SftpConsumerWithCharsetTest extends SftpServerTestSupport {
}
private void createSampleFile() throws IOException {
- File file = new File(FTP_ROOT_DIR + "/" + SAMPLE_FILE_NAME);
+ File file = new File(service.getFtpRootDir() + "/" + SAMPLE_FILE_NAME);
FileUtils.write(file, SAMPLE_FILE_PAYLOAD, SAMPLE_FILE_CHARSET);
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpECKeyFileConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpECKeyFileConsumeTest.java
index a87afaf..79a30d9 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpECKeyFileConsumeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpECKeyFileConsumeTest.java
@@ -23,19 +23,17 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpECKeyFileConsumeTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -47,7 +45,6 @@ public class SftpECKeyFileConsumeTest extends SftpServerTestSupport {
assertMockEndpointsSatisfied();
}
- @Override
protected PublickeyAuthenticator getPublickeyAuthenticator() {
return (username, key, session) -> key instanceof ECPublicKey;
}
@@ -57,8 +54,8 @@ public class SftpECKeyFileConsumeTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&knownHostsFile="
- + getKnownHostsFile()
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&knownHostsFile="
+ + service.getKnownHostsFile()
+ "&privateKeyFile=./src/test/resources/ec.pem&delay=10000&disconnect=true").routeId("foo").noAutoStartup()
.to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpFromSedaDeleteFileTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpFromSedaDeleteFileTest.java
index 8a00451..5bec647 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpFromSedaDeleteFileTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpFromSedaDeleteFileTest.java
@@ -33,7 +33,8 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
public class SftpFromSedaDeleteFileTest extends SftpServerTestSupport {
protected String getFtpUrl() {
- return "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&knownHostsFile=" + getKnownHostsFile()
+ return "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&knownHostsFile="
+ + service.getKnownHostsFile()
+ "&privateKeyFile=./src/test/resources/id_rsa"
+ "&privateKeyPassphrase=secret&delay=500&disconnect=false&delete=true";
}
@@ -56,12 +57,12 @@ public class SftpFromSedaDeleteFileTest extends SftpServerTestSupport {
Thread.sleep(500);
// assert the file is deleted
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
assertFalse(file.exists(), "The file should have been deleted");
}
private void createSampleFile() throws IOException {
- File file = new File(FTP_ROOT_DIR + "/" + "foo.txt");
+ File file = new File(service.getFtpRootDir() + "/" + "foo.txt");
FileUtils.write(file, "Hello World this file will be deleted");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyConsumeTest.java
index 042e063..08bca5a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyConsumeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyConsumeTest.java
@@ -28,19 +28,17 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpKeyConsumeTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -77,7 +75,7 @@ public class SftpKeyConsumeTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&knownHosts=#knownHosts&privateKey=#privateKey&privateKeyPassphrase=secret&delay=10000&strictHostKeyChecking=yes&disconnect=true")
.routeId("foo").noAutoStartup().to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyFileConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyFileConsumeTest.java
index fc6eaba..cd4869c 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyFileConsumeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyFileConsumeTest.java
@@ -23,19 +23,17 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpKeyFileConsumeTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -47,7 +45,6 @@ public class SftpKeyFileConsumeTest extends SftpServerTestSupport {
assertMockEndpointsSatisfied();
}
- @Override
protected PublickeyAuthenticator getPublickeyAuthenticator() {
return (username, key, session) -> key instanceof RSAPublicKey;
}
@@ -57,8 +54,8 @@ public class SftpKeyFileConsumeTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&knownHostsFile="
- + getKnownHostsFile()
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&knownHostsFile="
+ + service.getKnownHostsFile()
+ "&privateKeyFile=./src/test/resources/id_rsa&privateKeyPassphrase=secret&delay=10000&disconnect=true")
.routeId("foo").noAutoStartup().to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyPairDSAConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyPairDSAConsumeTest.java
index 4ce0439..e2dd25b 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyPairDSAConsumeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyPairDSAConsumeTest.java
@@ -25,7 +25,9 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpKeyPairDSAConsumeTest extends SftpServerTestSupport {
private static KeyPair keyPair;
@@ -39,14 +41,10 @@ public class SftpKeyPairDSAConsumeTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -58,7 +56,6 @@ public class SftpKeyPairDSAConsumeTest extends SftpServerTestSupport {
assertMockEndpointsSatisfied();
}
- @Override
protected PublickeyAuthenticator getPublickeyAuthenticator() {
return (username, key, session) -> key.equals(keyPair.getPublic());
}
@@ -66,12 +63,12 @@ public class SftpKeyPairDSAConsumeTest extends SftpServerTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
context.getRegistry().bind("keyPair", keyPair);
- context.getRegistry().bind("knownHosts", buildKnownHosts());
+ context.getRegistry().bind("knownHosts", service.buildKnownHosts());
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&knownHosts=#knownHosts&keyPair=#keyPair&delay=10000&strictHostKeyChecking=yes&disconnect=true")
.routeId("foo").noAutoStartup()
.to("mock:result");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyPairRSAConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyPairRSAConsumeTest.java
index 913144b..7241192 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyPairRSAConsumeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyPairRSAConsumeTest.java
@@ -31,7 +31,9 @@ import org.apache.camel.util.IOHelper;
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpKeyPairRSAConsumeTest extends SftpServerTestSupport {
private static KeyPair keyPair;
@@ -45,14 +47,10 @@ public class SftpKeyPairRSAConsumeTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -72,7 +70,6 @@ public class SftpKeyPairRSAConsumeTest extends SftpServerTestSupport {
return output.toByteArray();
}
- @Override
protected PublickeyAuthenticator getPublickeyAuthenticator() {
return (username, key, session) -> key.equals(keyPair.getPublic());
}
@@ -80,12 +77,12 @@ public class SftpKeyPairRSAConsumeTest extends SftpServerTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
context.getRegistry().bind("keyPair", keyPair);
- context.getRegistry().bind("knownHosts", buildKnownHosts());
+ context.getRegistry().bind("knownHosts", service.buildKnownHosts());
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&knownHosts=#knownHosts&keyPair=#keyPair&delay=10000&strictHostKeyChecking=yes&disconnect=true")
.routeId("foo").noAutoStartup()
.to("mock:result");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyUriConsumeFromClasspathTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyUriConsumeFromClasspathTest.java
index 0ee966a..f96c3c5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyUriConsumeFromClasspathTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyUriConsumeFromClasspathTest.java
@@ -20,19 +20,17 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpKeyUriConsumeFromClasspathTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -49,7 +47,7 @@ public class SftpKeyUriConsumeFromClasspathTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&knownHostsUri=known_hosts&privateKeyUri=id_rsa&privateKeyPassphrase=secret&delay=10000&disconnect=true")
.routeId("foo").noAutoStartup()
.to("mock:result");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyUriConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyUriConsumeTest.java
index 9e6ccfc..0047fc4 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyUriConsumeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyUriConsumeTest.java
@@ -20,19 +20,17 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpKeyUriConsumeTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -49,8 +47,8 @@ public class SftpKeyUriConsumeTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&knownHostsUri=file:"
- + getKnownHostsFile()
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&knownHostsUri=file:"
+ + service.getKnownHostsFile()
+ "&privateKeyUri=file:./src/test/resources/id_rsa&privateKeyPassphrase=secret&delay=10000&disconnect=true")
.routeId("foo").noAutoStartup().to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProduceTempFileTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProduceTempFileTest.java
index f4938eb..8ef11c9 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProduceTempFileTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProduceTempFileTest.java
@@ -21,36 +21,30 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.apache.camel.util.FileUtil;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpProduceTempFileTest extends SftpServerTestSupport {
@Test
public void testSftpTempFile() throws Exception {
- if (!canTest()) {
- return;
- }
-
- template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ template.sendBodyAndHeader("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&tempFileName=temp-${file:name}",
"Hello World",
Exchange.FILE_NAME, "hello.txt");
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
}
@Test
public void testSftpTempFileNoStartingPath() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(
- "sftp://localhost:" + getPort() + "/?username=admin&password=admin&tempFileName=temp-${file:name}",
+ "sftp://localhost:{{ftp.server.port}}/?username=admin&password=admin&tempFileName=temp-${file:name}",
"Hello World", Exchange.FILE_NAME,
"hello.txt");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerFileWithPathNoStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerFileWithPathNoStepwiseTest.java
index 15dba78..2c06360 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerFileWithPathNoStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerFileWithPathNoStepwiseTest.java
@@ -21,25 +21,23 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.apache.camel.converter.IOConverter;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpProducerFileWithPathNoStepwiseTest extends SftpServerTestSupport {
private String getFtpUrl() {
- return "sftp://admin@localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?password=admin&stepwise=false";
+ return "sftp://admin@localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?password=admin&stepwise=false";
}
@Test
public void testProducerFileWithPathNoStepwise() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(getFtpUrl(), "Hello World", Exchange.FILE_NAME, "hello/claus.txt");
- File file = new File(FTP_ROOT_DIR + "/hello/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/hello/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerFileWithPathTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerFileWithPathTest.java
index ac7ce9f..341af75 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerFileWithPathTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerFileWithPathTest.java
@@ -21,77 +21,63 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.apache.camel.converter.IOConverter;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpProducerFileWithPathTest extends SftpServerTestSupport {
private String getFtpUrl() {
- return "sftp://admin@localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?password=admin";
+ return "sftp://admin@localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?password=admin";
}
@Test
public void testProducerFileWithPath() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(getFtpUrl(), "Hello World", Exchange.FILE_NAME, "hello/claus.txt");
- File file = new File(FTP_ROOT_DIR + "/hello/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/hello/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
}
@Test
public void testProducerFileWithPathTwice() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(getFtpUrl(), "Hello World", Exchange.FILE_NAME, "hello/claus.txt");
template.sendBodyAndHeader(getFtpUrl(), "Hello Again World", Exchange.FILE_NAME, "hello/andrea.txt");
- File file = new File(FTP_ROOT_DIR + "/hello/claus.txt");
+ File file = new File(service.getFtpRootDir() + "/hello/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello World", IOConverter.toString(file, null));
- file = new File(FTP_ROOT_DIR + "/hello/andrea.txt");
+ file = new File(service.getFtpRootDir() + "/hello/andrea.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Hello Again World", IOConverter.toString(file, null));
}
@Test
public void testProducerFileWithPathExistDirCheckUsingLs() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(getFtpUrl() + "&existDirCheckUsingLs=false", "Bye World", Exchange.FILE_NAME,
"bye/andrea.txt");
- File file = new File(FTP_ROOT_DIR + "/bye/andrea.txt");
+ File file = new File(service.getFtpRootDir() + "/bye/andrea.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Bye World", IOConverter.toString(file, null));
}
@Test
public void testProducerFileWithPathExistDirCheckUsingLsTwice() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(getFtpUrl() + "&existDirCheckUsingLs=false", "Bye World", Exchange.FILE_NAME,
"bye/andrea.txt");
template.sendBodyAndHeader(getFtpUrl() + "&existDirCheckUsingLs=false", "Bye Again World", Exchange.FILE_NAME,
"bye/claus.txt");
- File file = new File(FTP_ROOT_DIR + "/bye/andrea.txt");
+ File file = new File(service.getFtpRootDir() + "/bye/andrea.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Bye World", IOConverter.toString(file, null));
- file = new File(FTP_ROOT_DIR + "/bye/claus.txt");
+ file = new File(service.getFtpRootDir() + "/bye/claus.txt");
assertTrue(file.exists(), "The uploaded file should exists");
assertEquals("Bye Again World", IOConverter.toString(file, null));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerMoveExistingTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerMoveExistingTest.java
index 94e36a7..f375a6d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerMoveExistingTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerMoveExistingTest.java
@@ -21,7 +21,11 @@ import java.io.File;
import org.apache.camel.CamelExecutionException;
import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFileOperationFailedException;
+import org.apache.camel.util.FileUtil;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.apache.camel.test.junit5.TestSupport.assertFileExists;
import static org.apache.camel.test.junit5.TestSupport.assertFileNotExists;
@@ -30,73 +34,64 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-/**
- *
- */
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpProducerMoveExistingTest extends SftpServerTestSupport {
private String getFtpUrl() {
- return "sftp://admin@localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/move?password=admin&fileExist=Move";
+ return "sftp://admin@localhost:{{ftp.server.port}}/{{ftp.root.dir}}/move?password=admin&fileExist=Move";
+ }
+
+ @AfterEach
+ public void cleanupDir() {
+ File moveToDir = new File(service.getFtpRootDir(), "/move");
+ FileUtil.removeDir(moveToDir);
}
@Test
public void testExistingFileDoesNotExists() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(getFtpUrl() + "&moveExisting=${file:parent}/renamed-${file:onlyname}", "Hello World",
Exchange.FILE_NAME, "hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
- assertFileNotExists(FTP_ROOT_DIR + "/move/renamed-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
+ assertFileNotExists(service.getFtpRootDir() + "/move/renamed-hello.txt");
}
@Test
public void testExistingFileExists() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(getFtpUrl() + "&moveExisting=${file:parent}/renamed-${file:onlyname}", "Hello World",
Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeader(getFtpUrl() + "&moveExisting=${file:parent}/renamed-${file:onlyname}", "Bye World",
Exchange.FILE_NAME, "hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
- assertFileExists(FTP_ROOT_DIR + "/move/renamed-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/renamed-hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/renamed-hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/renamed-hello.txt")));
}
@Test
public void testExistingFileExistsMoveSubDir() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(getFtpUrl() + "&moveExisting=backup", "Hello World", Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeader(getFtpUrl() + "&moveExisting=backup", "Bye World", Exchange.FILE_NAME, "hello.txt");
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
// would move into sub directory and keep existing name as is
- assertFileExists(FTP_ROOT_DIR + "/move/backup/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/backup/hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/backup/hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/backup/hello.txt")));
}
@Test
public void testFailOnMoveExistingFileExistsEagerDeleteTrue() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(
getFtpUrl() + "&moveExisting=${file:parent}/renamed-${file:onlyname}&eagerDeleteTargetFile=true", "Old file",
Exchange.FILE_NAME,
@@ -112,22 +107,19 @@ public class SftpProducerMoveExistingTest extends SftpServerTestSupport {
Exchange.FILE_NAME, "hello.txt");
// we could write the new file so the old context should be there
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Bye World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
// and the renamed file should be overridden
- assertFileExists(FTP_ROOT_DIR + "/move/renamed-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/renamed-hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/renamed-hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/renamed-hello.txt")));
}
@Test
public void testFailOnMoveExistingFileExistsEagerDeleteFalse() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(
getFtpUrl() + "&moveExisting=${file:parent}/renamed-${file:onlyname}&eagerDeleteTargetFile=true", "Old file",
Exchange.FILE_NAME,
@@ -148,13 +140,14 @@ public class SftpProducerMoveExistingTest extends SftpServerTestSupport {
// we could not write the new file so the previous context should be
// there
- assertFileExists(FTP_ROOT_DIR + "/move/hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/hello.txt");
assertEquals("Hello World",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/hello.txt")));
+ context.getTypeConverter().convertTo(String.class, new File(service.getFtpRootDir() + "/move/hello.txt")));
// and the renamed file should be untouched
- assertFileExists(FTP_ROOT_DIR + "/move/renamed-hello.txt");
+ assertFileExists(service.getFtpRootDir() + "/move/renamed-hello.txt");
assertEquals("Old file",
- context.getTypeConverter().convertTo(String.class, new File(FTP_ROOT_DIR + "/move/renamed-hello.txt")));
+ context.getTypeConverter().convertTo(String.class,
+ new File(service.getFtpRootDir() + "/move/renamed-hello.txt")));
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerWithCharsetTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerWithCharsetTest.java
index c6f20a4..a5f0fb8 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerWithCharsetTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpProducerWithCharsetTest.java
@@ -21,10 +21,12 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpProducerWithCharsetTest extends SftpServerTestSupport {
private static final String SAMPLE_FILE_NAME
@@ -40,13 +42,9 @@ public class SftpProducerWithCharsetTest extends SftpServerTestSupport {
@Test
public void testProducerWithCharset() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(getSftpUri(), SAMPLE_FILE_PAYLOAD, Exchange.FILE_NAME, SAMPLE_FILE_NAME);
- File file = new File(FTP_ROOT_DIR + "/" + SAMPLE_FILE_NAME);
+ File file = new File(service.getFtpRootDir() + "/" + SAMPLE_FILE_NAME);
assertTrue(file.exists(), "The uploaded file should exist");
String storedPayload = FileUtils.readFileToString(file, SAMPLE_FILE_CHARSET);
@@ -54,7 +52,7 @@ public class SftpProducerWithCharsetTest extends SftpServerTestSupport {
}
private String getSftpUri() {
- return "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&charset="
+ return "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&password=admin&charset="
+ SAMPLE_FILE_CHARSET;
}
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpServerTestSupport.java
index f0bc090..ca92eb9 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpServerTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpServerTestSupport.java
@@ -16,149 +16,11 @@
*/
package org.apache.camel.component.file.remote.sftp;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.FileSystems;
-import java.nio.file.Paths;
-import java.security.NoSuchAlgorithmException;
-import java.util.Collections;
-import java.util.List;
-
import org.apache.camel.component.file.remote.BaseServerTestSupport;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.commons.io.FileUtils;
-import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory;
-import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
-import org.apache.sshd.common.session.helpers.AbstractSession;
-import org.apache.sshd.server.SshServer;
-import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
-import org.apache.sshd.server.scp.ScpCommandFactory;
-import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.camel.test.junit5.TestSupport.createDirectory;
-import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
+import org.apache.camel.component.file.remote.services.SftpEmbeddedService;
+import org.junit.jupiter.api.extension.RegisterExtension;
public class SftpServerTestSupport extends BaseServerTestSupport {
-
- protected static final String FTP_ROOT_DIR = "target/res/home";
- private static final Logger LOG = LoggerFactory.getLogger(SftpServerTestSupport.class);
- private static final String KNOWN_HOSTS = "[localhost]:%d ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDdfIWeSV4o68dRrKS"
- + "zFd/Bk51E65UTmmSrmW0O1ohtzi6HzsDPjXgCtlTt3FqTcfFfI92IlTr4JWqC9UK1QT1ZTeng0MkPQmv68hDANHbt5CpETZHjW5q4OOgWhV"
- + "vj5IyOC2NZHtKlJBkdsMAa15ouOOJLzBvAvbqOR/yUROsEiQ==";
- protected SshServer sshd;
- protected boolean canTest;
- protected String oldUserHome;
- protected boolean rootDirMode;
- private String simulatedUserHome = "./target/user-home";
- private String simulatedUserSsh = "./target/user-home/.ssh";
-
- @Override
- @BeforeEach
- public void setUp() throws Exception {
- deleteDirectory(FTP_ROOT_DIR);
-
- oldUserHome = System.getProperty("user.home");
-
- System.setProperty("user.home", "target/user-home");
-
- deleteDirectory(simulatedUserHome);
- createDirectory(simulatedUserHome);
- createDirectory(simulatedUserSsh);
-
- super.setUp();
-
- FileUtils.writeByteArrayToFile(new File(simulatedUserSsh + "/known_hosts"), buildKnownHosts());
-
- setUpServer();
- }
-
- protected void setUpServer() throws Exception {
- canTest = true;
- try {
- sshd = SshServer.setUpDefaultServer();
- sshd.setPort(getPort());
- sshd.setKeyPairProvider(new FileKeyPairProvider(Paths.get("src/test/resources/hostkey.pem")));
- sshd.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory()));
- sshd.setCommandFactory(new ScpCommandFactory());
- sshd.setPasswordAuthenticator((username, password, session) -> true);
- sshd.setPublickeyAuthenticator(getPublickeyAuthenticator());
- if (rootDirMode) {
- sshd.setFileSystemFactory(new VirtualFileSystemFactory(
- FileSystems.getDefault().getPath(System.getProperty("user.dir") + "/target/res")));
- }
- sshd.start();
- } catch (Exception e) {
- // ignore if algorithm is not on the OS
- NoSuchAlgorithmException nsae = ObjectHelper.getException(NoSuchAlgorithmException.class, e);
- if (nsae != null) {
- canTest = false;
-
- String name = System.getProperty("os.name");
- String message = nsae.getMessage();
- LOG.warn("SunX509 is not avail on this platform [{}] Testing is skipped! Real cause: {}", name, message);
- } else {
- // some other error then throw it so the test can fail
- throw e;
- }
- }
- }
-
- protected PublickeyAuthenticator getPublickeyAuthenticator() {
- return (username, key, session) -> true;
- }
-
- @Override
- @AfterEach
- public void tearDown() throws Exception {
- if (oldUserHome != null) {
- System.setProperty("user.home", oldUserHome);
- } else {
- System.clearProperty("user.home");
- }
-
- super.tearDown();
-
- tearDownServer();
- }
-
- protected void tearDownServer() {
- if (sshd != null) {
- try {
- // stop asap as we may hang forever
- sshd.stop(true);
- sshd = null;
- } catch (Exception e) {
- // ignore while shutting down as we could be polling during
- // shutdown
- // and get errors when the ftp server is stopping. This is only
- // an issue
- // since we host the ftp server embedded in the same jvm for
- // unit testing
- }
- }
- }
-
- protected boolean canTest() {
- return canTest;
- }
-
- // disconnect all existing SSH sessions to test reconnect functionality
- protected void disconnectAllSessions() throws IOException {
- List<AbstractSession> sessions = sshd.getActiveSessions();
- for (AbstractSession session : sessions) {
- session.disconnect(4, "dummy");
- }
- }
-
- protected byte[] buildKnownHosts() {
- return String.format(KNOWN_HOSTS, port).getBytes();
- }
-
- protected String getKnownHostsFile() {
- return simulatedUserSsh + "/known_hosts";
- }
+ @RegisterExtension
+ protected static SftpEmbeddedService service = new SftpEmbeddedService();
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSetCipherTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSetCipherTest.java
index f676fce..c4c4664 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSetCipherTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSetCipherTest.java
@@ -21,24 +21,24 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.apache.camel.component.file.remote.SftpEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSetCipherTest extends SftpServerTestSupport {
@Test
public void testSftpSetCipherName() throws Exception {
- if (!canTest()) {
- return;
- }
-
String cipher = "blowfish-cbc";
- String uri = "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&ciphers=" + cipher;
+ String uri
+ = "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&password=admin&ciphers="
+ + cipher;
template.sendBodyAndHeader(uri, "Hello World", Exchange.FILE_NAME, "hello.txt");
// test setting the cipher doesn't interfere with message payload
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSetOperationsTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSetOperationsTest.java
index b86c7bd..45d039d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSetOperationsTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSetOperationsTest.java
@@ -21,25 +21,23 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.apache.camel.component.file.remote.SftpEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSetOperationsTest extends SftpServerTestSupport {
@Test
public void testSftpSetOperations() throws Exception {
- if (!canTest()) {
- return;
- }
-
String preferredAuthentications = "password,publickey";
- String uri = "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ String uri = "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&ciphers=blowfish-cbc" + "&preferredAuthentications=password,publickey";
template.sendBodyAndHeader(uri, "Hello World", Exchange.FILE_NAME, "hello.txt");
// test setting the cipher doesn't interfere with message payload
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeNoStartingDirTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeNoStartingDirTest.java
index fb0a51a..ca39e6d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeNoStartingDirTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeNoStartingDirTest.java
@@ -23,15 +23,13 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.util.FileUtil;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleConsumeNoStartingDirTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
// create files using regular file
File file = new File("a.txt");
FileOutputStream fos = new FileOutputStream(file, false);
@@ -53,7 +51,7 @@ public class SftpSimpleConsumeNoStartingDirTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/"
+ from("sftp://localhost:{{ftp.server.port}}/"
+ "?fileName=a.txt&username=admin&password=admin&delay=10000&disconnect=true").routeId("foo")
.noAutoStartup().to("log:result", "mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeNotStepwiseTest.java
index 5b0e8b9..0876161 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeNotStepwiseTest.java
@@ -17,7 +17,9 @@
package org.apache.camel.component.file.remote.sftp;
import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleConsumeNotStepwiseTest extends SftpSimpleConsumeTest {
@Override
@@ -25,7 +27,7 @@ public class SftpSimpleConsumeNotStepwiseTest extends SftpSimpleConsumeTest {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true&stepwise=false").routeId("foo")
.noAutoStartup().to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeRecursiveNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeRecursiveNotStepwiseTest.java
index 521ad68..5e89cee 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeRecursiveNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeRecursiveNotStepwiseTest.java
@@ -25,7 +25,7 @@ public class SftpSimpleConsumeRecursiveNotStepwiseTest extends SftpSimpleConsume
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true&recursive=true&stepwise=false")
.routeId("foo")
.noAutoStartup().to("log:result", "mock:result");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeRecursiveTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeRecursiveTest.java
index 64f18a7..12f9ca0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeRecursiveTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeRecursiveTest.java
@@ -20,20 +20,18 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleConsumeRecursiveTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsumeRecursive() throws Exception {
- if (!canTest()) {
- return;
- }
-
// create files using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, "A", Exchange.FILE_NAME, "a.txt");
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR + "/foo", "B", Exchange.FILE_NAME, "b.txt");
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR + "/bar", "C", Exchange.FILE_NAME, "c.txt");
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR + "/bar/cake", "D", Exchange.FILE_NAME, "d.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), "A", Exchange.FILE_NAME, "a.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir() + "/foo", "B", Exchange.FILE_NAME, "b.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir() + "/bar", "C", Exchange.FILE_NAME, "c.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir() + "/bar/cake", "D", Exchange.FILE_NAME, "d.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(4);
@@ -48,7 +46,7 @@ public class SftpSimpleConsumeRecursiveTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true&recursive=true").routeId("foo")
.noAutoStartup().to("log:result", "mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingPartialReadTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingPartialReadTest.java
index ae3de2b..c660afe 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingPartialReadTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingPartialReadTest.java
@@ -25,6 +25,7 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -32,18 +33,15 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests that a file move can occur on the server even if the remote stream was only partially read.
*/
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleConsumeStreamingPartialReadTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -58,7 +56,7 @@ public class SftpSimpleConsumeStreamingPartialReadTest extends SftpServerTestSup
// Wait a little bit for the move to finish.
Thread.sleep(2000);
- File resultFile = new File(FTP_ROOT_DIR + File.separator + "failed", "hello.txt");
+ File resultFile = new File(service.getFtpRootDir() + File.separator + "failed", "hello.txt");
assertTrue(resultFile.exists());
assertFalse(resultFile.isDirectory());
}
@@ -68,7 +66,7 @@ public class SftpSimpleConsumeStreamingPartialReadTest extends SftpServerTestSup
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true&streamDownload=true"
+ "&move=done&moveFailed=failed").routeId("foo").noAutoStartup().process(new Processor() {
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingTest.java
index ea89188..e9d2dc4 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingTest.java
@@ -23,21 +23,19 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleConsumeStreamingTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -56,7 +54,7 @@ public class SftpSimpleConsumeStreamingTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true&streamDownload=true").routeId("foo")
.noAutoStartup().to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingWithMultipleFilesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingWithMultipleFilesTest.java
index a36f5f1..7bceb27 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingWithMultipleFilesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeStreamingWithMultipleFilesTest.java
@@ -23,23 +23,21 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleConsumeStreamingWithMultipleFilesTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
String expected2 = "Goodbye World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected2, Exchange.FILE_NAME, "goodbye.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected2, Exchange.FILE_NAME, "goodbye.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
@@ -60,7 +58,7 @@ public class SftpSimpleConsumeStreamingWithMultipleFilesTest extends SftpServerT
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true&streamDownload=true").routeId("foo")
.noAutoStartup().to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeTest.java
index ce7efe4..f4b5140 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeTest.java
@@ -20,19 +20,17 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleConsumeTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -49,7 +47,7 @@ public class SftpSimpleConsumeTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true").routeId("foo").noAutoStartup()
.to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeThroughProxyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeThroughProxyTest.java
index f17ea8e..7c8f477 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeThroughProxyTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleConsumeThroughProxyTest.java
@@ -22,23 +22,24 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.AvailablePortFinder;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.condition.EnabledIf;
import org.littleshoot.proxy.HttpProxyServer;
import org.littleshoot.proxy.ProxyAuthenticator;
import org.littleshoot.proxy.impl.DefaultHttpProxyServer;
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleConsumeThroughProxyTest extends SftpServerTestSupport {
-
+ private static HttpProxyServer proxyServer;
private final int proxyPort = AvailablePortFinder.getNextAvailable();
- @Test
- public void testSftpSimpleConsumeThroughProxy() throws Exception {
- if (!canTest()) {
- return;
- }
-
- // start http proxy
- HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap()
+ @BeforeAll
+ public void setupProxy() {
+ proxyServer = DefaultHttpProxyServer.bootstrap()
.withPort(proxyPort)
.withProxyAuthenticator(new ProxyAuthenticator() {
@Override
@@ -51,11 +52,19 @@ public class SftpSimpleConsumeThroughProxyTest extends SftpServerTestSupport {
return "myrealm";
}
}).start();
+ }
+
+ @AfterAll
+ public void cleanup() {
+ proxyServer.stop();
+ }
+ @Test
+ public void testSftpSimpleConsumeThroughProxy() throws Exception {
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -65,8 +74,6 @@ public class SftpSimpleConsumeThroughProxyTest extends SftpServerTestSupport {
context.getRouteController().startRoute("foo");
assertMockEndpointsSatisfied();
-
- proxyServer.stop();
}
@Override
@@ -74,7 +81,7 @@ public class SftpSimpleConsumeThroughProxyTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true&proxy=#proxy").routeId("foo").noAutoStartup()
.to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java
index 0f00f41..18fdf7c 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java
@@ -21,20 +21,18 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
@Disabled
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleIPV6ConsumeTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleConsume() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "hello.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -51,7 +49,7 @@ public class SftpSimpleIPV6ConsumeTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://[::1]:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://[::1]:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true").routeId("foo").noAutoStartup()
.to("mock:result");
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceDisconnectTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceDisconnectTest.java
index 1730ba1..7fc7b16 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceDisconnectTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceDisconnectTest.java
@@ -20,33 +20,33 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleProduceDisconnectTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleProduce() throws Exception {
- if (!canTest()) {
- return;
- }
-
- template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin",
+ template.sendBodyAndHeader(
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&password=admin",
"Hello World", Exchange.FILE_NAME, "hello.txt");
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
// restart the SFTP server now
- tearDownServer();
- setUpServer();
+ service.tearDownServer();
+ service.setUpServer();
- template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin",
+ template.sendBodyAndHeader(
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&password=admin",
"Hello World", Exchange.FILE_NAME, "hello1.txt");
- file = new File(FTP_ROOT_DIR + "/hello1.txt");
+ file = new File(service.getFtpRootDir() + "/hello1.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceNotStepwiseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceNotStepwiseTest.java
index 56b6d3e..9d8fdf8 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceNotStepwiseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceNotStepwiseTest.java
@@ -20,56 +20,48 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleProduceNotStepwiseTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleProduce() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(
- "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&stepwise=false",
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ + "?username=admin&password=admin&stepwise=false",
"Hello World", Exchange.FILE_NAME,
"hello.txt");
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
}
@Test
public void testSftpSimpleSubPathProduce() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(
- "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/mysub?username=admin&password=admin&stepwise=false",
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ + "/mysub?username=admin&password=admin&stepwise=false",
"Bye World", Exchange.FILE_NAME,
"bye.txt");
- File file = new File(FTP_ROOT_DIR + "/mysub/bye.txt");
+ File file = new File(service.getFtpRootDir() + "/mysub/bye.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));
}
@Test
public void testSftpSimpleTwoSubPathProduce() throws Exception {
- if (!canTest()) {
- return;
- }
-
- template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ template.sendBodyAndHeader("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "/mysub/myother?username=admin&password=admin&stepwise=false",
"Farewell World",
Exchange.FILE_NAME, "farewell.txt");
- File file = new File(FTP_ROOT_DIR + "/mysub/myother/farewell.txt");
+ File file = new File(service.getFtpRootDir() + "/mysub/myother/farewell.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Farewell World", context.getTypeConverter().convertTo(String.class, file));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceTest.java
index de8444f..94c44bd 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceTest.java
@@ -20,53 +20,46 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleProduceTest extends SftpServerTestSupport {
@Test
public void testSftpSimpleProduce() throws Exception {
- if (!canTest()) {
- return;
- }
-
- template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin",
+ template.sendBodyAndHeader(
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "?username=admin&password=admin",
"Hello World", Exchange.FILE_NAME, "hello.txt");
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir() + "/hello.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
}
@Test
public void testSftpSimpleSubPathProduce() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(
- "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/mysub?username=admin&password=admin", "Bye World",
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir() + "/mysub?username=admin&password=admin",
+ "Bye World",
Exchange.FILE_NAME, "bye.txt");
- File file = new File(FTP_ROOT_DIR + "/mysub/bye.txt");
+ File file = new File(service.getFtpRootDir() + "/mysub/bye.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));
}
@Test
public void testSftpSimpleTwoSubPathProduce() throws Exception {
- if (!canTest()) {
- return;
- }
-
template.sendBodyAndHeader(
- "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/mysub/myother?username=admin&password=admin",
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ + "/mysub/myother?username=admin&password=admin",
"Farewell World", Exchange.FILE_NAME,
"farewell.txt");
- File file = new File(FTP_ROOT_DIR + "/mysub/myother/farewell.txt");
+ File file = new File(service.getFtpRootDir() + "/mysub/myother/farewell.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Farewell World", context.getTypeConverter().convertTo(String.class, file));
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceThroughProxyTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceThroughProxyTest.java
index 5b6a517..106ef8f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceThroughProxyTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleProduceThroughProxyTest.java
@@ -22,7 +22,11 @@ import com.jcraft.jsch.ProxyHTTP;
import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.test.AvailablePortFinder;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.condition.EnabledIf;
import org.littleshoot.proxy.HttpProxyServer;
import org.littleshoot.proxy.ProxyAuthenticator;
import org.littleshoot.proxy.impl.DefaultHttpProxyServer;
@@ -30,18 +34,16 @@ import org.littleshoot.proxy.impl.DefaultHttpProxyServer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpSimpleProduceThroughProxyTest extends SftpServerTestSupport {
+ private static HttpProxyServer proxyServer;
private final int proxyPort = AvailablePortFinder.getNextAvailable();
- @Test
- public void testSftpSimpleProduceThroughProxy() throws Exception {
- if (!canTest()) {
- return;
- }
-
- // start http proxy
- HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap()
+ @BeforeAll
+ public void setupProxy() {
+ proxyServer = DefaultHttpProxyServer.bootstrap()
.withPort(proxyPort)
.withProxyAuthenticator(new ProxyAuthenticator() {
@Override
@@ -54,83 +56,49 @@ public class SftpSimpleProduceThroughProxyTest extends SftpServerTestSupport {
return "myrealm";
}
}).start();
+ }
+
+ @AfterAll
+ public void cleanup() {
+ proxyServer.stop();
+ }
+ @Test
+ public void testSftpSimpleProduceThroughProxy() {
template.sendBodyAndHeader(
- "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&proxy=#proxy",
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ + "?username=admin&password=admin&proxy=#proxy",
"Hello World", Exchange.FILE_NAME,
"hello.txt");
- File file = new File(FTP_ROOT_DIR + "/hello.txt");
+ File file = new File(service.getFtpRootDir(), "/hello.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
-
- proxyServer.stop();
}
@Test
- public void testSftpSimpleSubPathProduceThroughProxy() throws Exception {
- if (!canTest()) {
- return;
- }
-
- // start http proxy
- HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap()
- .withPort(proxyPort)
- .withProxyAuthenticator(new ProxyAuthenticator() {
- @Override
- public boolean authenticate(String userName, String password) {
- return "user".equals(userName) && "password".equals(password);
- }
-
- @Override
- public String getRealm() {
- return "myrealm";
- }
- }).start();
-
+ public void testSftpSimpleSubPathProduceThroughProxy() {
template.sendBodyAndHeader(
- "sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR + "/mysub?username=admin&password=admin&proxy=#proxy",
+ "sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ + "/mysub?username=admin&password=admin&proxy=#proxy",
"Bye World", Exchange.FILE_NAME,
"bye.txt");
- File file = new File(FTP_ROOT_DIR + "/mysub/bye.txt");
+ File file = new File(service.getFtpRootDir(), "/mysub/bye.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));
-
- proxyServer.stop();
}
@Test
- public void testSftpSimpleTwoSubPathProduceThroughProxy() throws Exception {
- if (!canTest()) {
- return;
- }
-
- // start http proxy
- HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap()
- .withPort(proxyPort)
- .withProxyAuthenticator(new ProxyAuthenticator() {
- @Override
- public boolean authenticate(String userName, String password) {
- return "user".equals(userName) && "password".equals(password);
- }
-
- @Override
- public String getRealm() {
- return "myrealm";
- }
- }).start();
-
- template.sendBodyAndHeader("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ public void testSftpSimpleTwoSubPathProduceThroughProxy() {
+ template.sendBodyAndHeader("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "/mysub/myother?username=admin&password=admin&proxy=#proxy",
"Farewell World",
Exchange.FILE_NAME, "farewell.txt");
- File file = new File(FTP_ROOT_DIR + "/mysub/myother/farewell.txt");
+ File file = new File(service.getFtpRootDir(), "/mysub/myother/farewell.txt");
assertTrue(file.exists(), "File should exist: " + file);
assertEquals("Farewell World", context.getTypeConverter().convertTo(String.class, file));
-
- proxyServer.stop();
}
@BindToRegistry("proxy")
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpUseListFalseTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpUseListFalseTest.java
index e15f492..1f1f3b0 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpUseListFalseTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpUseListFalseTest.java
@@ -20,19 +20,17 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
+@EnabledIf(value = "org.apache.camel.component.file.remote.services.SftpEmbeddedService#hasRequiredAlgorithms")
public class SftpUseListFalseTest extends SftpServerTestSupport {
@Test
public void testSftpUseListFalse() throws Exception {
- if (!canTest()) {
- return;
- }
-
String expected = "Hello World";
// create file using regular file
- template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "report.txt");
+ template.sendBodyAndHeader("file://" + service.getFtpRootDir(), expected, Exchange.FILE_NAME, "report.txt");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
@@ -49,7 +47,7 @@ public class SftpUseListFalseTest extends SftpServerTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("sftp://localhost:" + getPort() + "/" + FTP_ROOT_DIR
+ from("sftp://localhost:{{ftp.server.port}}/" + service.getFtpRootDir()
+ "?username=admin&password=admin&delay=10000&disconnect=true&stepwise=false&useList=false&fileName=report.txt&delete=true")
.routeId("foo").noAutoStartup()
.to("mock:result");
diff --git a/test-infra/camel-test-infra-ftp/pom.xml b/test-infra/camel-test-infra-ftp/pom.xml
new file mode 100644
index 0000000..0fba0de
--- /dev/null
+++ b/test-infra/camel-test-infra-ftp/pom.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ 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">
+ <parent>
+ <artifactId>camel-test-infra-parent</artifactId>
+ <groupId>org.apache.camel</groupId>
+ <relativePath>../camel-test-infra-parent/pom.xml</relativePath>
+ <version>3.7.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-test-infra-ftp</artifactId>
+ <name>Camel :: Test Infra :: Ftp</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
\ No newline at end of file
diff --git a/test-infra/camel-test-infra-ftp/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-ftp/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e69de29
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpNotStepwiseTest.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/common/FtpProperties.java
similarity index 73%
copy from components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpNotStepwiseTest.java
copy to test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/common/FtpProperties.java
index ce77297..b040642 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFileToFtpNotStepwiseTest.java
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/common/FtpProperties.java
@@ -14,13 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.file.remote;
-public class FromFileToFtpNotStepwiseTest extends FromFileToFtpTest {
+package org.apache.camel.test.infra.ftp.common;
- @Override
- protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/tmp2/camel?password=admin&initialDelay=3000&stepwise=false";
- }
+public final class FtpProperties {
+ public static final String SERVER_HOST = "ftp.server.host";
+ public static final String SERVER_PORT = "ftp.server.port";
+ public static final String ROOT_DIR = "ftp.root.dir";
+
+ private FtpProperties() {
+ }
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/FtpRemoteService.java
similarity index 72%
copy from components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
copy to test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/FtpRemoteService.java
index ecb4c09..1756609 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/FtpRemoteService.java
@@ -14,16 +14,22 @@
* 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.test.infra.ftp.services;
-/**
- * Unit test to test delete option.
- */
-public class FromFtpDeleteFileScottTigerTest extends FromFtpDeleteFileTest {
+public class FtpRemoteService implements FtpService {
+
+ @Override
+ public void registerProperties() {
+ // NO-OP
+ }
@Override
- protected String getFtpUrl() {
- return "ftp://scott:tiger@localhost:" + getPort() + "/deletefile?binary=false&delete=true";
+ public void initialize() {
+ registerProperties();
}
+ @Override
+ public void shutdown() {
+ // NO-OP
+ }
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedNotStepwiseTest.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/FtpService.java
similarity index 61%
copy from components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedNotStepwiseTest.java
copy to test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/FtpService.java
index 75096ca..c6bf6ac 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedNotStepwiseTest.java
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/FtpService.java
@@ -14,16 +14,25 @@
* 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.test.infra.ftp.services;
+
+import org.apache.camel.test.infra.common.services.TestService;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
/**
- * Unit test to test keepLastModified option.
+ * Test infra service for Ftp
*/
-public class FromFtpKeepLastModifiedNotStepwiseTest extends FromFtpKeepLastModifiedTest {
+public interface FtpService extends BeforeAllCallback, AfterAllCallback, TestService {
@Override
- protected String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/keep?password=admin&binary=false&noop=true&stepwise=false";
+ default void beforeAll(ExtensionContext extensionContext) throws Exception {
+ initialize();
}
+ @Override
+ default void afterAll(ExtensionContext extensionContext) throws Exception {
+ shutdown();
+ }
}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoEncodedTest.java b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/FtpServiceFactory.java
similarity index 56%
copy from components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoEncodedTest.java
copy to test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/FtpServiceFactory.java
index 0801087..f7e4e3f 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFilePercentSignInPasswordUserInfoEncodedTest.java
+++ b/test-infra/camel-test-infra-ftp/src/test/java/org/apache/camel/test/infra/ftp/services/FtpServiceFactory.java
@@ -14,13 +14,26 @@
* 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.test.infra.ftp.services;
-public class FromFilePercentSignInPasswordUserInfoEncodedTest extends FromFilePercentSignInPasswordTest {
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class FtpServiceFactory {
+ private static final Logger LOG = LoggerFactory.getLogger(FtpServiceFactory.class);
+
+ private FtpServiceFactory() {
- @Override
- protected String getFtpUrl() {
- return "ftp://us%40r:t%25st@localhost:" + getPort() + "/tmp3/camel?initialDelay=3000";
}
+ public static FtpService createService() {
+ String instanceType = System.getProperty("ftp.instance.type");
+
+ if (instanceType.equals("remote")) {
+ return new FtpRemoteService();
+ }
+
+ LOG.error("Ftp instance must be one of 'remote");
+ throw new UnsupportedOperationException("Invalid Ftp instance type");
+ }
}
diff --git a/test-infra/pom.xml b/test-infra/pom.xml
index bd28c36..5c78124 100644
--- a/test-infra/pom.xml
+++ b/test-infra/pom.xml
@@ -66,5 +66,6 @@
<module>camel-test-infra-zookeeper</module>
<module>camel-test-infra-postgres</module>
<module>camel-test-infra-couchdb</module>
+ <module>camel-test-infra-ftp</module>
</modules>
</project>