You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/07/24 13:52:09 UTC
[camel] 01/02: Camel-FTP: Use BindToRegistry annotation where
possible
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0d974638f3b3a0366d49fbfd94fb274f23abad2e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jul 24 15:30:42 2019 +0200
Camel-FTP: Use BindToRegistry annotation where possible
---
...icitSSLWithClientAuthAndSSLContextParametersTest.java | 10 ++++------
...tSSLWithoutClientAuthAndSSLContextParametersTest.java | 9 ++++-----
...icitTLSWithClientAuthAndSSLContextParametersTest.java | 10 +++++-----
...tTLSWithoutClientAuthAndSSLContextParametersTest.java | 9 ++++-----
...icitSSLWithClientAuthAndSSLContextParametersTest.java | 9 ++++-----
...tSSLWithoutClientAuthAndSSLContextParametersTest.java | 9 ++++-----
...icitTLSWithClientAuthAndSSLContextParametersTest.java | 9 ++++-----
...tTLSWithoutClientAuthAndSSLContextParametersTest.java | 9 ++++-----
.../remote/FileToFtpsWithFtpClientConfigRefTest.java | 16 +++++++---------
.../file/remote/FromFtpClientConfigRefTest.java | 9 ++++-----
.../camel/component/file/remote/FromFtpFilterTest.java | 11 ++++-------
.../remote/FromFtpRemoteFileFilterDirectoryTest.java | 12 +++++-------
.../file/remote/FromFtpRemoteFileFilterTest.java | 12 +++++-------
.../file/remote/FromFtpRemoteFileSorterTest.java | 9 +++------
.../remote/FromFtpSimulateNetworkIssueRecoverTest.java | 11 ++++-------
.../file/remote/FtpBadLoginConnectionLeakTest.java | 13 ++++---------
.../remote/FtpBadLoginInProducerConnectionLeakTest.java | 13 ++++---------
.../remote/FtpBadLoginMockNoopConnectionLeakTest.java | 13 ++++---------
.../file/remote/FtpConsumerIdempotentMemoryRefTest.java | 9 ++++-----
.../file/remote/FtpConsumerIdempotentRefTest.java | 11 ++++-------
.../file/remote/FtpConsumerMoveExpressionTest.java | 11 ++++-------
.../file/remote/FtpConsumerProcessStrategyTest.java | 12 +++---------
.../FtpConsumerThrowExceptionOnLoginFailedTest.java | 11 ++++-------
.../file/remote/FtpConsumerUsingFTPClientConfigTest.java | 11 +++--------
.../component/file/remote/FtpProducerExpressionTest.java | 11 ++++-------
.../file/remote/FtpProducerMultipleSiteCommandTest.java | 9 +++------
.../camel/component/file/remote/FtpSoTimeoutTest.java | 9 ++++-----
.../remote/sftp/SftpConsumerProcessStrategyTest.java | 12 +++---------
.../component/file/remote/sftp/SftpKeyConsumeTest.java | 15 +++++++++------
.../remote/sftp/SftpSimpleConsumeThroughProxyTest.java | 10 +++++-----
.../remote/sftp/SftpSimpleProduceThroughProxyTest.java | 10 +++++-----
31 files changed, 132 insertions(+), 202 deletions(-)
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 5f594e0..f7912ef 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
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.file.remote;
-import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
@@ -24,8 +24,8 @@ import org.apache.camel.support.jsse.TrustManagersParameters;
public class FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersTest extends FileToFtpsExplicitSSLWithClientAuthTest {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+ @BindToRegistry("sslContextParameters")
+ public SSLContextParameters createSslContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("server.jks");
ksp.setPassword("password");
@@ -42,9 +42,7 @@ public class FileToFtpsExplicitSSLWithClientAuthAndSSLContextParametersTest exte
sslContextParameters.setKeyManagers(kmp);
sslContextParameters.setTrustManagers(tmp);
- JndiRegistry registry = super.createRegistry();
- registry.bind("sslContextParameters", sslContextParameters);
- return registry;
+ return sslContextParameters;
}
protected String getFtpUrl() {
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 09fad63..dbe6452 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
@@ -23,8 +24,8 @@ import org.apache.camel.support.jsse.TrustManagersParameters;
public class FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersTest extends FileToFtpsExplicitSSLWithoutClientAuthTest {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+ @BindToRegistry("sslContextParameters")
+ public SSLContextParameters createSslContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("server.jks");
ksp.setPassword("password");
@@ -36,9 +37,7 @@ public class FileToFtpsExplicitSSLWithoutClientAuthAndSSLContextParametersTest e
sslContextParameters.setSecureSocketProtocol("SSLv3");
sslContextParameters.setTrustManagers(tmp);
- JndiRegistry registry = super.createRegistry();
- registry.bind("sslContextParameters", sslContextParameters);
- return registry;
+ return sslContextParameters;
}
protected String getFtpUrl() {
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 0e2dd66..3f13af5 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
@@ -23,8 +24,9 @@ import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
public class FileToFtpsExplicitTLSWithClientAuthAndSSLContextParametersTest extends FileToFtpsExplicitTLSWithClientAuthTest {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+
+ @BindToRegistry("sslContextParameters")
+ public SSLContextParameters createSslContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("server.jks");
ksp.setPassword("password");
@@ -41,9 +43,7 @@ public class FileToFtpsExplicitTLSWithClientAuthAndSSLContextParametersTest exte
sslContextParameters.setKeyManagers(kmp);
sslContextParameters.setTrustManagers(tmp);
- JndiRegistry registry = super.createRegistry();
- registry.bind("sslContextParameters", sslContextParameters);
- return registry;
+ return sslContextParameters;
}
protected String getFtpUrl() {
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 13e79af..f7b1a69 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
@@ -16,14 +16,15 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
public class FileToFtpsExplicitTLSWithoutClientAuthAndSSLContextParametersTest extends FileToFtpsExplicitTLSWithoutClientAuthTest {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+ @BindToRegistry("sslContextParameters")
+ public SSLContextParameters createSslContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("server.jks");
ksp.setPassword("password");
@@ -35,9 +36,7 @@ public class FileToFtpsExplicitTLSWithoutClientAuthAndSSLContextParametersTest e
sslContextParameters.setSecureSocketProtocol("TLSv1.2");
sslContextParameters.setTrustManagers(tmp);
- JndiRegistry registry = super.createRegistry();
- registry.bind("sslContextParameters", sslContextParameters);
- return registry;
+ return sslContextParameters;
}
protected String getFtpUrl() {
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 c2610a8..4410048 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
@@ -23,8 +24,8 @@ import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
public class FileToFtpsImplicitSSLWithClientAuthAndSSLContextParametersTest extends FileToFtpsImplicitSSLWithClientAuthTest {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+ @BindToRegistry("sslContextParameters")
+ public SSLContextParameters createSslContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("server.jks");
ksp.setPassword("password");
@@ -41,9 +42,7 @@ public class FileToFtpsImplicitSSLWithClientAuthAndSSLContextParametersTest exte
sslContextParameters.setKeyManagers(kmp);
sslContextParameters.setTrustManagers(tmp);
- JndiRegistry registry = super.createRegistry();
- registry.bind("sslContextParameters", sslContextParameters);
- return registry;
+ return sslContextParameters;
}
protected String getFtpUrl() {
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 6cdfe75..0b825ad 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
@@ -16,14 +16,15 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
public class FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersTest extends FileToFtpsImplicitSSLWithoutClientAuthTest {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+ @BindToRegistry("sslContextParameters")
+ public SSLContextParameters createSslContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("server.jks");
ksp.setPassword("password");
@@ -35,9 +36,7 @@ public class FileToFtpsImplicitSSLWithoutClientAuthAndSSLContextParametersTest e
sslContextParameters.setSecureSocketProtocol("SSLv3");
sslContextParameters.setTrustManagers(tmp);
- JndiRegistry registry = super.createRegistry();
- registry.bind("sslContextParameters", sslContextParameters);
- return registry;
+ return sslContextParameters;
}
protected String getFtpUrl() {
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 e2173df..16c9f7c 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
@@ -23,8 +24,8 @@ import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
public class FileToFtpsImplicitTLSWithClientAuthAndSSLContextParametersTest extends FileToFtpsImplicitTLSWithClientAuthTest {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+ @BindToRegistry("sslContextParameters")
+ public SSLContextParameters createSslContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("server.jks");
ksp.setPassword("password");
@@ -41,9 +42,7 @@ public class FileToFtpsImplicitTLSWithClientAuthAndSSLContextParametersTest exte
sslContextParameters.setKeyManagers(kmp);
sslContextParameters.setTrustManagers(tmp);
- JndiRegistry registry = super.createRegistry();
- registry.bind("sslContextParameters", sslContextParameters);
- return registry;
+ return sslContextParameters;
}
protected String getFtpUrl() {
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 23c2a45..84246ca 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
@@ -16,14 +16,15 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
public class FileToFtpsImplicitTLSWithoutClientAuthAndSSLContextParametersTest extends FileToFtpsImplicitTLSWithoutClientAuthTest {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+ @BindToRegistry("sslContextParameters")
+ public SSLContextParameters createSslContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("server.jks");
ksp.setPassword("password");
@@ -35,9 +36,7 @@ public class FileToFtpsImplicitTLSWithoutClientAuthAndSSLContextParametersTest e
sslContextParameters.setSecureSocketProtocol("TLSv1.2");
sslContextParameters.setTrustManagers(tmp);
- JndiRegistry registry = super.createRegistry();
- registry.bind("sslContextParameters", sslContextParameters);
- return registry;
+ return sslContextParameters;
}
protected String getFtpUrl() {
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 3f5f956..4159115 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
@@ -27,21 +28,18 @@ import org.junit.Test;
*/
public class FileToFtpsWithFtpClientConfigRefTest extends FtpsServerExplicitSSLWithoutClientAuthTestSupport {
+ @BindToRegistry("ftpsClient")
+ private FTPSClient client = new FTPSClient("SSLv3");
+
+ @BindToRegistry("ftpsClientIn")
+ private FTPSClient client1 = new FTPSClient("SSLv3");
+
private String getFtpUrl(boolean in) {
return "ftps://admin@localhost:" + getPort()
+ "/tmp2/camel?password=admin&consumer.initialDelay=2000&ftpClient=#ftpsClient"
+ (in ? "In" : "") + "&disableSecureDataChannelDefaults=true&delete=true";
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
-
- jndi.bind("ftpsClient", new FTPSClient("SSLv3"));
- jndi.bind("ftpsClientIn", new FTPSClient("SSLv3"));
- return jndi;
- }
-
@Test
public void testFromFileToFtp() throws Exception {
// some platforms cannot test SSL
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 642566e..b4ec17d 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Producer;
@@ -32,16 +33,14 @@ public class FromFtpClientConfigRefTest extends FtpServerTestSupport {
return "ftp://admin@localhost:" + getPort() + "/timeout/?password=admin&ftpClientConfig=#myConfig";
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
+ @BindToRegistry("myConfig")
+ public FTPClientConfig addFtpConfig() throws Exception {
FTPClientConfig config = new FTPClientConfig();
config.setServerLanguageCode("fr");
config.setLenientFutureDates(true);
- jndi.bind("myConfig", config);
- return jndi;
+ return config;
}
@Override
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 6aed432..9c323ff 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileFilter;
@@ -28,17 +29,13 @@ import org.junit.Test;
*/
public class FromFtpFilterTest extends FtpServerTestSupport {
+ @BindToRegistry("myFilter")
+ private MyFileFilter filter = new MyFileFilter<>();
+
protected String getFtpUrl() {
return "ftp://admin@localhost:" + getPort() + "/filter?password=admin&binary=false&filter=#myFilter";
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myFilter", new MyFileFilter<>());
- return jndi;
- }
-
@Test
public void testFilterFiles() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
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 9c56d36..bc815f8 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
@@ -16,9 +16,11 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileFilter;
+import org.apache.camel.component.file.remote.FromFtpFilterTest.MyFileFilter;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
import org.junit.Before;
@@ -32,13 +34,9 @@ public class FromFtpRemoteFileFilterDirectoryTest extends FtpServerTestSupport {
private String getFtpUrl() {
return "ftp://admin@localhost:" + getPort() + "/filefilter?password=admin&recursive=true&filter=#myFilter";
}
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myFilter", new MyFileFilter<>());
- return jndi;
- }
+
+ @BindToRegistry("myFilter")
+ private MyFileFilter filter = new MyFileFilter<>();
@Override
@Before
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 e3a838b..024af23 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
@@ -16,9 +16,11 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileFilter;
+import org.apache.camel.component.file.remote.FromFtpRemoteFileFilterDirectoryTest.MyFileFilter;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
import org.junit.Before;
@@ -32,13 +34,9 @@ public class FromFtpRemoteFileFilterTest extends FtpServerTestSupport {
private String getFtpUrl() {
return "ftp://admin@localhost:" + getPort() + "/filefilter?password=admin&filter=#myFilter";
}
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myFilter", new MyFileFilter<>());
- return jndi;
- }
+
+ @BindToRegistry("myFilter")
+ private MyFileFilter filter = new MyFileFilter<>();
@Override
@Before
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 d64b96d..9404425 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
@@ -18,6 +18,7 @@ package org.apache.camel.component.file.remote;
import java.util.Comparator;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
@@ -33,12 +34,8 @@ public class FromFtpRemoteFileSorterTest extends FtpServerTestSupport {
return "ftp://admin@localhost:" + getPort() + "/sorter?password=admin&sorter=#mySorter";
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("mySorter", new MyRemoteFileSorter());
- return jndi;
- }
+ @BindToRegistry("mySorter")
+ private MyRemoteFileSorter sorter = new MyRemoteFileSorter();
@Override
@Before
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 d0984d9..43371d2 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Consumer;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
@@ -35,13 +36,9 @@ public class FromFtpSimulateNetworkIssueRecoverTest extends FtpServerTestSupport
private String getFtpUrl() {
return "ftp://admin@localhost:" + getPort() + "/recover?password=admin&pollStrategy=#myPoll";
}
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myPoll", new MyPollStrategy());
- return jndi;
- }
+
+ @BindToRegistry("myPoll")
+ private MyPollStrategy strategy = new MyPollStrategy();
@Test
public void testFtpRecover() throws Exception {
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 d1b7ac3..6875ae5 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
@@ -25,6 +25,7 @@ import java.util.Map;
import javax.net.SocketFactory;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
@@ -36,21 +37,15 @@ public class FtpBadLoginConnectionLeakTest extends FtpServerTestSupport {
* Mapping of socket hashcode to two element tab ([connect() called, close() called])
*/
private Map<Integer, boolean[]> socketAudits = new HashMap<>();
+
+ @BindToRegistry("sf")
+ private SocketFactory sf = new AuditingSocketFactory();
private String getFtpUrl() {
return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber"
+ "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
-
- SocketFactory sf = new AuditingSocketFactory();
- jndi.bind("sf", sf);
- return jndi;
- }
-
@Test
public void testConnectionLeak() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
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 2881ebf..d4ae694 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
@@ -25,6 +25,7 @@ import java.util.Map;
import javax.net.SocketFactory;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.impl.JndiRegistry;
import org.junit.Test;
@@ -35,20 +36,14 @@ public class FtpBadLoginInProducerConnectionLeakTest extends FtpServerTestSuppor
*/
private Map<Integer, boolean[]> socketAudits = new HashMap<>();
+ @BindToRegistry("sf")
+ private SocketFactory sf = new AuditingSocketFactory();
+
private String getFtpUrl() {
return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber&maximumReconnectAttempts=3"
+ "&throwExceptionOnConnectFailed=false&ftpClient.socketFactory=#sf";
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
-
- SocketFactory sf = new AuditingSocketFactory();
- jndi.bind("sf", sf);
- return jndi;
- }
-
@Test
public void testConnectionLeak() throws Exception {
for (String filename : new String[] {"claus.txt", "grzegorz.txt"}) {
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 151df3b..a44f24f 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
@@ -24,6 +24,7 @@ import java.util.Map;
import javax.net.SocketFactory;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
@@ -39,6 +40,9 @@ public class FtpBadLoginMockNoopConnectionLeakTest extends FtpServerTestSupport
* Mapping of socket hashcode to two element tab ([connect() called, close() called])
*/
private Map<Integer, boolean[]> socketAudits = new HashMap<>();
+
+ @BindToRegistry("sf")
+ private SocketFactory sf = new AuditingSocketFactory();
private String getFtpUrl() {
return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremeber&maximumReconnectAttempts=3"
@@ -60,15 +64,6 @@ public class FtpBadLoginMockNoopConnectionLeakTest extends FtpServerTestSupport
});
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
-
- SocketFactory sf = new AuditingSocketFactory();
- jndi.bind("sf", sf);
- return jndi;
- }
-
@Test
public void testConnectionLeak() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
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 434b663..a0449ce 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.NotifyBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.JndiRegistry;
@@ -34,13 +35,11 @@ public class FtpConsumerIdempotentMemoryRefTest extends FtpServerTestSupport {
+ "/idempotent?password=admin&binary=false&idempotent=true&idempotentRepository=#myRepo&idempotentKey=${file:onlyname}&delete=true";
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
+ @BindToRegistry("myRepo")
+ public MemoryIdempotentRepository addRepo() throws Exception {
repo = new MemoryIdempotentRepository();
repo.setCacheSize(5);
- jndi.bind("myRepo", repo);
- return jndi;
+ return repo;
}
@Test
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 bf9ea47..6a5844a 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
@@ -28,19 +29,15 @@ import org.junit.Test;
public class FtpConsumerIdempotentRefTest extends FtpServerTestSupport {
private static boolean invoked;
+
+ @BindToRegistry("myRepo")
+ private MyIdempotentRepository myIdempotentRepo = new MyIdempotentRepository();
private String getFtpUrl() {
return "ftp://admin@localhost:" + getPort()
+ "/idempotent?password=admin&binary=false&idempotent=true&idempotentRepository=#myRepo&delete=true";
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myRepo", new MyIdempotentRepository());
- return jndi;
- }
-
@Test
public void testIdempotent() throws Exception {
// consume the file the first time
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 c0cd2c0..f3a55da 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
@@ -20,6 +20,7 @@ import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
@@ -34,6 +35,9 @@ public class FtpConsumerMoveExpressionTest extends FtpServerTestSupport {
private String getFtpUrl() {
return "ftp://admin@localhost:" + getPort() + "/filelanguage?password=admin&consumer.delay=5000";
}
+
+ @BindToRegistry("myguidgenerator")
+ private MyGuidGenerator guid = new MyGuidGenerator();
@Override
@Before
@@ -41,13 +45,6 @@ public class FtpConsumerMoveExpressionTest extends FtpServerTestSupport {
super.setUp();
deleteDirectory("target/filelanguage");
}
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myguidgenerator", new MyGuidGenerator());
- return jndi;
- }
@Test
public void testMoveUsingExpression() throws Exception {
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 2975067..7f27217 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileEndpoint;
@@ -26,15 +27,8 @@ import org.junit.Test;
public class FtpConsumerProcessStrategyTest extends FtpServerTestSupport {
- private MyStrategy myStrategy;
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- myStrategy = new MyStrategy();
- jndi.bind("myStrategy", myStrategy);
- return jndi;
- }
+ @BindToRegistry("myStrategy")
+ private MyStrategy myStrategy = new MyStrategy();
private String getFtpUrl() {
return "ftp://admin@localhost:" + getPort() + "/" + FTP_ROOT_DIR + "?password=admin&processStrategy=#myStrategy";
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 9410b5f..598a6e6 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
@@ -19,6 +19,7 @@ package org.apache.camel.component.file.remote;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Consumer;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
@@ -34,19 +35,15 @@ import org.junit.Test;
public class FtpConsumerThrowExceptionOnLoginFailedTest extends FtpServerTestSupport {
private CountDownLatch latch = new CountDownLatch(1);
+
+ @BindToRegistry("myPoll")
+ private MyPoll poll = new MyPoll();
private String getFtpUrl() {
return "ftp://dummy@localhost:" + getPort() + "/badlogin?password=cantremember"
+ "&throwExceptionOnConnectFailed=true&maximumReconnectAttempts=0&pollStrategy=#myPoll&autoCreate=false";
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myPoll", new MyPoll());
- return jndi;
- }
-
@Test
public void testBadLogin() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(0);
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 949ee88..52abb93 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
@@ -39,14 +40,8 @@ public class FtpConsumerUsingFTPClientConfigTest extends FtpServerTestSupport {
prepareFtpServer();
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myConfig", createConfig());
- return jndi;
- }
-
- private FTPClientConfig createConfig() {
+ @BindToRegistry("myConfig")
+ public FTPClientConfig createConfig() {
FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
config.setServerTimeZoneId("Europe/Paris");
return config;
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 b5f62d2..a4823ee 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
@@ -20,6 +20,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.impl.JndiRegistry;
import org.junit.Before;
import org.junit.Test;
@@ -32,6 +33,9 @@ public class FtpProducerExpressionTest extends FtpServerTestSupport {
private String getFtpUrl() {
return "ftp://admin@localhost:" + getPort() + "/filelanguage?password=admin";
}
+
+ @BindToRegistry("myguidgenerator")
+ private MyGuidGenerator guid = new MyGuidGenerator();
@Override
@Before
@@ -40,13 +44,6 @@ public class FtpProducerExpressionTest extends FtpServerTestSupport {
deleteDirectory("target/filelanguage");
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myguidgenerator", new MyGuidGenerator());
- return jndi;
- }
-
@Test
public void testProduceBeanByExpression() throws Exception {
template.sendBody(getFtpUrl() + "&fileName=${bean:myguidgenerator}.bak", "Hello World");
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 71f4481..500af13 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
@@ -18,18 +18,15 @@ package org.apache.camel.component.file.remote;
import java.io.File;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.converter.IOConverter;
import org.apache.camel.impl.JndiRegistry;
import org.junit.Test;
public class FtpProducerMultipleSiteCommandTest extends FtpServerTestSupport {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("site", "help site\nhelp site");
- return jndi;
- }
+ @BindToRegistry("site")
+ private String site = "help site\nhelp site";
private String getFtpUrl() {
return "ftp://admin@localhost:" + getPort() + "/site?password=admin&siteCommand=#site";
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSoTimeoutTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSoTimeoutTest.java
index 8e696b4..39bc95a 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSoTimeoutTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSoTimeoutTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.file.remote;
import java.net.ServerSocket;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.CamelExecutionException;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
@@ -81,13 +82,11 @@ public class FtpSoTimeoutTest extends CamelTestSupport {
};
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+ @BindToRegistry("myftpclient")
+ public FTPClient createFtpClient() throws Exception {
FTPClient ftpClient = new FTPClient();
ftpClient.setDefaultTimeout(300);
- JndiRegistry registry = super.createRegistry();
- registry.bind("myftpclient", ftpClient);
- return registry;
+ return ftpClient;
}
// --- Tests
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 51a4c91..d939e7f 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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote.sftp;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileEndpoint;
@@ -26,15 +27,8 @@ import org.junit.Test;
public class SftpConsumerProcessStrategyTest extends SftpServerTestSupport {
- private MyStrategy myStrategy;
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- myStrategy = new MyStrategy();
- jndi.bind("myStrategy", myStrategy);
- return jndi;
- }
+ @BindToRegistry("myStrategy")
+ private MyStrategy myStrategy = new MyStrategy();
@Test
public void testSftpConsume() throws Exception {
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 3978164..bb4257d 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
@@ -22,6 +22,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -60,14 +61,16 @@ public class SftpKeyConsumeTest extends SftpServerTestSupport {
return output.toByteArray();
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry registry = super.createRegistry();
+ @BindToRegistry("privateKey")
+ public byte[] addPrivateKey() throws Exception {
- registry.bind("privateKey", getBytesFromFile("./src/test/resources/id_rsa"));
- registry.bind("knownHosts", getBytesFromFile("./src/test/resources/known_hosts"));
+ return getBytesFromFile("./src/test/resources/id_rsa");
+ }
+
+ @BindToRegistry("knownHosts")
+ public byte[] addKnownHosts() throws Exception {
- return registry;
+ return getBytesFromFile("./src/test/resources/id_rsa");
}
@Override
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 16623e5..da724a2 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
@@ -17,6 +17,8 @@
package org.apache.camel.component.file.remote.sftp;
import com.jcraft.jsch.ProxyHTTP;
+
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -77,13 +79,11 @@ public class SftpSimpleConsumeThroughProxyTest extends SftpServerTestSupport {
};
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
+ @BindToRegistry("proxy")
+ public ProxyHTTP createProxy() throws Exception {
final ProxyHTTP proxyHTTP = new ProxyHTTP("localhost", proxyPort);
proxyHTTP.setUserPasswd("user", "password");
- jndi.bind("proxy", proxyHTTP);
- return jndi;
+ return proxyHTTP;
}
}
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 415f5ec..07147d6 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
@@ -19,6 +19,8 @@ package org.apache.camel.component.file.remote.sftp;
import java.io.File;
import com.jcraft.jsch.ProxyHTTP;
+
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.test.AvailablePortFinder;
@@ -107,14 +109,12 @@ public class SftpSimpleProduceThroughProxyTest extends SftpServerTestSupport {
proxyServer.stop();
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
+ @BindToRegistry("proxy")
+ public ProxyHTTP createProxy() throws Exception {
final ProxyHTTP proxyHTTP = new ProxyHTTP("localhost", proxyPort);
proxyHTTP.setUserPasswd("user", "password");
- jndi.bind("proxy", proxyHTTP);
- return jndi;
+ return proxyHTTP;
}
}