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/31 06:42:26 UTC
[camel] 01/03: CAMEL-13801 - camel3 - Use @BindToRegistry wherever
possible, Camel-Restlet
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 b9b872d989c948b6c6a1a0a8e01adaa5791bb59d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jul 31 08:37:36 2019 +0200
CAMEL-13801 - camel3 - Use @BindToRegistry wherever possible, Camel-Restlet
---
.../restlet/RestRestletCustomDataFormatInvalidTest.java | 11 ++++-------
.../camel/component/restlet/RestRestletGetTest.java | 9 +++------
.../camel/component/restlet/RestRestletRouterIdTest.java | 9 ++-------
.../restlet/RestletHttpsWithSSLContextParametersTest.java | 10 ++++------
.../camel/component/restlet/RestletProducerSSLTest.java | 15 ++++-----------
.../component/restlet/RestletProducerSessionTest.java | 15 +++++++--------
6 files changed, 24 insertions(+), 45 deletions(-)
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletCustomDataFormatInvalidTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletCustomDataFormatInvalidTest.java
index 3ecd926..83fa837 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletCustomDataFormatInvalidTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletCustomDataFormatInvalidTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.restlet;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jackson.JacksonDataFormat;
import org.apache.camel.impl.JndiRegistry;
@@ -24,18 +25,14 @@ import org.junit.Test;
public class RestRestletCustomDataFormatInvalidTest extends RestletTestSupport {
+ @BindToRegistry("bla")
+ private JacksonDataFormat df = new JacksonDataFormat();
+
@Override
public boolean isUseRouteBuilder() {
return false;
}
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("bla", new JacksonDataFormat());
- return jndi;
- }
-
@Test
public void testCustom() throws Exception {
context.addRoutes(new RouteBuilder() {
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletGetTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletGetTest.java
index 4b15ada..344aca1 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletGetTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletGetTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.restlet;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
@@ -25,12 +26,8 @@ import org.junit.Test;
public class RestRestletGetTest extends RestletTestSupport {
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndi = super.createRegistry();
- jndi.bind("myBinding", new DefaultRestletBinding());
- return jndi;
- }
+ @BindToRegistry("myBinding")
+ private DefaultRestletBinding binding = new DefaultRestletBinding();
@Test
public void testRestletProducerGet() throws Exception {
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletRouterIdTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletRouterIdTest.java
index ad18815..68250bd 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletRouterIdTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletRouterIdTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.restlet;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.RoutesBuilder;
@@ -31,18 +32,12 @@ import org.junit.Test;
public class RestRestletRouterIdTest extends CamelTestSupport {
+ @BindToRegistry("setId")
private static final Processor SET_ROUTE_ID_AS_BODY =
exchange -> exchange.getIn().setBody(exchange.getFromRouteId());
private int port = AvailablePortFinder.getNextAvailable(6000);
@Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry r = super.createRegistry();
- r.bind("setId", SET_ROUTE_ID_AS_BODY);
- return r;
- }
-
- @Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletHttpsWithSSLContextParametersTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletHttpsWithSSLContextParametersTest.java
index de4e9a4..5c24f85 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletHttpsWithSSLContextParametersTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletHttpsWithSSLContextParametersTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.restlet;
import java.net.URL;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
@@ -35,8 +36,8 @@ public class RestletHttpsWithSSLContextParametersTest extends RestletTestSupport
private static final String REQUEST_MESSAGE =
"<mail><body>HelloWorld!</body><subject>test</subject><to>x@y.net</to></mail>";
- @Override
- protected JndiRegistry createRegistry() throws Exception {
+ @BindToRegistry("mySSLContextParameters")
+ public SSLContextParameters loadSSLContextParams() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").getPath().toString());
ksp.setPassword("changeit");
@@ -48,10 +49,7 @@ public class RestletHttpsWithSSLContextParametersTest extends RestletTestSupport
SSLContextParameters sslContextParameters = new SSLContextParameters();
sslContextParameters.setKeyManagers(kmp);
- JndiRegistry registry = super.createRegistry();
- registry.bind("mySSLContextParameters", sslContextParameters);
-
- return registry;
+ return sslContextParameters;
}
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerSSLTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerSSLTest.java
index da87f44..e3194da 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerSSLTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerSSLTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.restlet;
import java.io.File;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
@@ -31,17 +32,9 @@ import org.junit.Test;
public class RestletProducerSSLTest extends RestletTestSupport {
public static final String BODY = "some body";
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
-
- SSLContextParameters sslContextParameters = createSSLContext();
-
- JndiRegistry registry = super.createRegistry();
- registry.bind("mySSLContextParameters", sslContextParameters);
-
- return registry;
- }
+
+ @BindToRegistry("mySSLContextParameters")
+ private SSLContextParameters sslContextParameters = createSSLContext();
@Test
public void testRestletProducerComponentSSL() throws Exception {
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerSessionTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerSessionTest.java
index af12245..e072131 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerSessionTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerSessionTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.restlet;
import javax.servlet.http.HttpSession;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
@@ -29,6 +30,12 @@ import org.junit.Test;
public class RestletProducerSessionTest extends RestletTestSupport {
private String url = "restlet:http://127.0.0.1:" + portNum + "/session?restletMethod=POST";
+
+ @BindToRegistry("instanceCookieHandler")
+ private InstanceCookieHandler instanceCookieHandler = new InstanceCookieHandler();
+
+ @BindToRegistry("exchangeCookieHandler")
+ private ExchangeCookieHandler exchangeCookieHandler = new ExchangeCookieHandler();
@Test
public void testProducerNoSession() throws Exception {
@@ -55,14 +62,6 @@ public class RestletProducerSessionTest extends RestletTestSupport {
}
@Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndiRegistry = super.createRegistry();
- jndiRegistry.bind("instanceCookieHandler", new InstanceCookieHandler());
- jndiRegistry.bind("exchangeCookieHandler", new ExchangeCookieHandler());
- return jndiRegistry;
- }
-
- @Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override