You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2018/10/12 07:55:26 UTC
[camel] 12/43: [CAMEL-12818] Remove deprecated stuff from
camel-netty4
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit cdbbb25606dfc32de69012ca8cfa840e9d3636d6
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon Sep 24 09:37:54 2018 +0200
[CAMEL-12818] Remove deprecated stuff from camel-netty4
---
.../camel/component/netty4/NettyConfiguration.java | 30 ++++++++++++++++------
.../netty4/NettyServerBootstrapConfiguration.java | 1 -
.../component/netty4/NettyCustomCodecTest.java | 2 +-
.../NettyCustomPipelineFactoryAsynchTest.java | 10 ++++----
.../netty4/NettySSLClientCertHeadersTest.java | 4 +--
.../netty4/NettySSLConsumerClientModeTest.java | 2 +-
.../camel/component/netty4/NettySSLTest.java | 4 +--
.../component/netty4/NettySingleCodecTest.java | 4 +--
.../netty4/UnsharableCodecsConflicts2Test.java | 2 +-
.../netty4/UnsharableCodecsConflictsTest.java | 4 +--
10 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
index 924e4d5..ad37b05 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.netty4;
import java.io.File;
import java.net.URI;
+import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -34,9 +35,11 @@ import org.apache.camel.LoggingLevel;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
+import org.apache.camel.util.CamelContextHelper;
import org.apache.camel.util.EndpointHelper;
import org.apache.camel.util.IntrospectionSupport;
import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -186,15 +189,9 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem
passphrase = component.getAndRemoveOrResolveReferenceParameter(parameters, "passphrase", String.class, passphrase);
keyStoreFormat = component.getAndRemoveOrResolveReferenceParameter(parameters, "keyStoreFormat", String.class, keyStoreFormat == null ? "JKS" : keyStoreFormat);
securityProvider = component.getAndRemoveOrResolveReferenceParameter(parameters, "securityProvider", String.class, securityProvider == null ? "SunX509" : securityProvider);
- keyStoreFile = component.getAndRemoveOrResolveReferenceParameter(parameters, "keyStoreFile", File.class, keyStoreFile);
- trustStoreFile = component.getAndRemoveOrResolveReferenceParameter(parameters, "trustStoreFile", File.class, trustStoreFile);
- keyStoreResource = component.getAndRemoveOrResolveReferenceParameter(parameters, "keyStoreResource", String.class, keyStoreResource);
- trustStoreResource = component.getAndRemoveOrResolveReferenceParameter(parameters, "trustStoreResource", String.class, trustStoreResource);
- // clientPipelineFactory is @deprecated and to be removed
- clientInitializerFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "clientPipelineFactory", ClientInitializerFactory.class, clientInitializerFactory);
+ keyStoreResource = uriRef(component, parameters, "keyStoreResource", keyStoreResource);
+ trustStoreResource = uriRef(component, parameters, "trustStoreResource", trustStoreResource);
clientInitializerFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "clientInitializerFactory", ClientInitializerFactory.class, clientInitializerFactory);
- // serverPipelineFactory is @deprecated and to be removed
- serverInitializerFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "serverPipelineFactory", ServerInitializerFactory.class, serverInitializerFactory);
serverInitializerFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "serverInitializerFactory", ServerInitializerFactory.class, serverInitializerFactory);
// set custom encoders and decoders first
@@ -252,6 +249,23 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem
}
}
+ private String uriRef(NettyComponent component, Map<String, Object> parameters, String key, String defaultValue) {
+ Object value = parameters.remove(key);
+ if (value == null) {
+ value = defaultValue;
+ } else if (value instanceof String && EndpointHelper.isReferenceParameter((String) value)) {
+ String name = StringHelper.replaceAll((String) value, "#", "");
+ value = CamelContextHelper.mandatoryLookup(component.getCamelContext(), name);
+ }
+ if (value instanceof File) {
+ return "file:" + value.toString();
+ } else if (value != null) {
+ return value.toString();
+ } else {
+ return null;
+ }
+ }
+
public String getCharsetName() {
if (encoding == null) {
return null;
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
index 2e9c7af..337aa82 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.netty4;
-import java.io.File;
import java.util.Map;
import io.netty.channel.EventLoopGroup;
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomCodecTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomCodecTest.java
index 57722fb..ec25d0f 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomCodecTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomCodecTest.java
@@ -24,7 +24,7 @@ import org.junit.Test;
public class NettyCustomCodecTest extends BaseNettyTest {
private String uri = "netty4:tcp://localhost:{{port}}?disconnect=true&sync=false"
- + "&allowDefaultCodec=false&decoders=#myCustomDecoder,#myCustomDecoder2&encoder=#myCustomEncoder";
+ + "&allowDefaultCodec=false&decoders=#myCustomDecoder,#myCustomDecoder2&encoders=#myCustomEncoder";
// use reaadble bytes
private byte[] data = new byte[]{65, 66, 67, 68, 69, 70, 71, 72, 73, 0, 0};
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
index aeebba5..d9c4e78 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
@@ -39,7 +39,7 @@ public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest {
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
- registry.bind("cpf", new TestClientChannelPipelineFactory(null));
+ registry.bind("cpf", new TestClientChannelInitializerFactory(null));
registry.bind("spf", new TestServerChannelPipelineFactory(null));
return registry;
}
@@ -60,7 +60,7 @@ public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest {
}
@Test
- public void testCustomClientPipelineFactory() throws Exception {
+ public void testCustomClientInitializerFactory() throws Exception {
String response = (String) template.requestBody(
"netty4:tcp://localhost:{{port}}?clientInitializerFactory=#cpf&textline=true",
"Forest Gump describing Vietnam...");
@@ -70,11 +70,11 @@ public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest {
assertEquals(true, serverInvoked);
}
- public class TestClientChannelPipelineFactory extends ClientInitializerFactory {
+ public class TestClientChannelInitializerFactory extends ClientInitializerFactory {
private int maxLineSize = 1024;
private NettyProducer producer;
- public TestClientChannelPipelineFactory(NettyProducer producer) {
+ public TestClientChannelInitializerFactory(NettyProducer producer) {
this.producer = producer;
}
@@ -91,7 +91,7 @@ public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest {
@Override
public ClientInitializerFactory createPipelineFactory(NettyProducer producer) {
- return new TestClientChannelPipelineFactory(producer);
+ return new TestClientChannelInitializerFactory(producer);
}
}
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClientCertHeadersTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClientCertHeadersTest.java
index 5d4eb34..31bb662 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClientCertHeadersTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClientCertHeadersTest.java
@@ -55,7 +55,7 @@ public class NettySSLClientCertHeadersTest extends BaseNettyTest {
context.addRoutes(new RouteBuilder() {
public void configure() {
// needClientAuth=true so we can get the client certificate details
- from("netty4:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreFile=#ksf&trustStoreFile=#tsf"
+ from("netty4:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreResource=#ksf&trustStoreResource=#tsf"
+ "&needClientAuth=true&sslClientCertHeaders=true")
.to("mock:input")
.transform().constant("Bye World");
@@ -64,7 +64,7 @@ public class NettySSLClientCertHeadersTest extends BaseNettyTest {
context.start();
String response = template.requestBody(
- "netty4:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreFile=#ksf&trustStoreFile=#tsf",
+ "netty4:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreResource=#ksf&trustStoreResource=#tsf",
"Hello World", String.class);
assertEquals("Bye World", response);
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLConsumerClientModeTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLConsumerClientModeTest.java
index c8859cd..784b889 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLConsumerClientModeTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLConsumerClientModeTest.java
@@ -96,7 +96,7 @@ public class NettySSLConsumerClientModeTest extends BaseNettyTest {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("netty4:tcp://localhost:{{port}}?textline=true&clientMode=true&ssl=true&passphrase=changeit&keyStoreFile=#ksf&trustStoreFile=#tsf").id("sslclient")
+ from("netty4:tcp://localhost:{{port}}?textline=true&clientMode=true&ssl=true&passphrase=changeit&keyStoreResource=#ksf&trustStoreResource=#tsf").id("sslclient")
.process(new Processor() {
public void process(final Exchange exchange) {
String body = exchange.getIn().getBody(String.class);
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLTest.java
index 349ca01..b91af6d 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLTest.java
@@ -52,7 +52,7 @@ public class NettySSLTest extends BaseNettyTest {
context.addRoutes(new RouteBuilder() {
public void configure() {
// needClientAuth=true so we can get the client certificate details
- from("netty4:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreFile=#ksf&trustStoreFile=#tsf&needClientAuth=true")
+ from("netty4:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreResource=#ksf&trustStoreResource=#tsf&needClientAuth=true")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
SSLSession session = exchange.getIn().getHeader(NettyConstants.NETTY_SSL_SESSION, SSLSession.class);
@@ -71,7 +71,7 @@ public class NettySSLTest extends BaseNettyTest {
context.start();
String response = template.requestBody(
- "netty4:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreFile=#ksf&trustStoreFile=#tsf",
+ "netty4:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreResource=#ksf&trustStoreResource=#tsf",
"Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);
assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
}
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java
index 64f55e4..4c5436b 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java
@@ -53,9 +53,9 @@ public class NettySingleCodecTest extends BaseNettyTest {
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
- from("direct:single-codec").to("netty4:tcp://localhost:{{port}}?encoder=#encoder&sync=false");
+ from("direct:single-codec").to("netty4:tcp://localhost:{{port}}?encoders=#encoder&sync=false");
- from("netty4:tcp://localhost:{{port}}?decoder=#decoder&sync=false").to("mock:single-codec");
+ from("netty4:tcp://localhost:{{port}}?decoders=#decoder&sync=false").to("mock:single-codec");
}
};
}
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/UnsharableCodecsConflicts2Test.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/UnsharableCodecsConflicts2Test.java
index 15fa6c8..05aa655 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/UnsharableCodecsConflicts2Test.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/UnsharableCodecsConflicts2Test.java
@@ -85,7 +85,7 @@ public class UnsharableCodecsConflicts2Test extends BaseNettyTest {
public void configure() throws Exception {
port = getPort();
- from("netty4:tcp://localhost:{{port}}?decoder=#length-decoder&sync=false")
+ from("netty4:tcp://localhost:{{port}}?decoders=#length-decoder&sync=false")
.process(processor)
.to("mock:result");
}
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/UnsharableCodecsConflictsTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/UnsharableCodecsConflictsTest.java
index f054cac..8f1c9d0 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/UnsharableCodecsConflictsTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/UnsharableCodecsConflictsTest.java
@@ -89,10 +89,10 @@ public class UnsharableCodecsConflictsTest extends BaseNettyTest {
port1 = getPort();
port2 = getNextPort();
- from("netty4:tcp://localhost:" + port1 + "?decoder=#length-decoder&sync=false")
+ from("netty4:tcp://localhost:" + port1 + "?decoders=#length-decoder&sync=false")
.process(processor);
- from("netty4:tcp://localhost:" + port2 + "?decoder=#length-decoder2&sync=false")
+ from("netty4:tcp://localhost:" + port2 + "?decoders=#length-decoder2&sync=false")
.process(processor)
.to("mock:result");
}