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/30 10:46:53 UTC
[camel] 02/03: CAMEL-13801 - Fixed CS for camel-netty4-http
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 4e1434826a432689016f27c9acfea9643af88b30
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jul 30 12:43:47 2019 +0200
CAMEL-13801 - Fixed CS for camel-netty4-http
---
...tpBasicAuthCustomSecurityAuthenticatorTest.java | 10 ++--
...pEndpointUriCustomHeaderFilterStrategyTest.java | 18 ++++---
.../http/NettyHttpFilterCamelHeadersTest.java | 6 +--
.../NettyHttpHeaderFilterStrategyRemovalTest.java | 8 ++--
.../netty4/http/NettyHttpProducerSessionTest.java | 56 ++++++++++------------
5 files changed, 43 insertions(+), 55 deletions(-)
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBasicAuthCustomSecurityAuthenticatorTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBasicAuthCustomSecurityAuthenticatorTest.java
index 42e2383..09ebbd7 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBasicAuthCustomSecurityAuthenticatorTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBasicAuthCustomSecurityAuthenticatorTest.java
@@ -27,8 +27,8 @@ import org.junit.Test;
public class NettyHttpBasicAuthCustomSecurityAuthenticatorTest extends BaseNettyTest {
- @BindToRegistry("myAuthenticator")
- private MyAuthenticator auth = new MyAuthenticator();
+ @BindToRegistry("myAuthenticator")
+ private MyAuthenticator auth = new MyAuthenticator();
@Test
public void testBasicAuth() throws Exception {
@@ -40,7 +40,8 @@ public class NettyHttpBasicAuthCustomSecurityAuthenticatorTest extends BaseNetty
assertEquals(401, cause.getStatusCode());
}
- // wait a little bit before next as the connection was closed when denied
+ // wait a little bit before next as the connection was closed when
+ // denied
Thread.sleep(500);
getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
@@ -58,8 +59,7 @@ public class NettyHttpBasicAuthCustomSecurityAuthenticatorTest extends BaseNetty
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("netty4-http:http://0.0.0.0:{{port}}/foo?securityConfiguration.realm=foo&securityConfiguration.securityAuthenticator=#myAuthenticator")
- .to("mock:input")
+ from("netty4-http:http://0.0.0.0:{{port}}/foo?securityConfiguration.realm=foo&securityConfiguration.securityAuthenticator=#myAuthenticator").to("mock:input")
.transform().constant("Bye World");
}
};
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpEndpointUriCustomHeaderFilterStrategyTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpEndpointUriCustomHeaderFilterStrategyTest.java
index 93c17a2..4e70726 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpEndpointUriCustomHeaderFilterStrategyTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpEndpointUriCustomHeaderFilterStrategyTest.java
@@ -26,9 +26,9 @@ import org.junit.Test;
public class NettyHttpEndpointUriCustomHeaderFilterStrategyTest extends BaseNettyTest {
- @BindToRegistry("customHeaderFilterStrategy")
- private CustomHeaderFilterStrategy customHeaderFilterStrategy = new CustomHeaderFilterStrategy();
-
+ @BindToRegistry("customHeaderFilterStrategy")
+ private CustomHeaderFilterStrategy customHeaderFilterStrategy = new CustomHeaderFilterStrategy();
+
@Test
public void testEndpointUriWithCustomHeaderStrategy() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:outbound");
@@ -48,21 +48,19 @@ public class NettyHttpEndpointUriCustomHeaderFilterStrategyTest extends BaseNett
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("direct:request")
- .setHeader("Date", constant("31-03-2014"))
+ from("direct:request").setHeader("Date", constant("31-03-2014"))
.to("netty4-http:http://localhost:{{port}}/myapp/mytest?headerFilterStrategy=#customHeaderFilterStrategy");
- from("netty4-http:http://localhost:{{port}}/myapp/mytest")
- .to("mock:outbound")
- .setHeader("sub-date", constant("31-05-2014"));
+ from("netty4-http:http://localhost:{{port}}/myapp/mytest").to("mock:outbound").setHeader("sub-date", constant("31-05-2014"));
}
};
}
private class CustomHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
CustomHeaderFilterStrategy() {
- // allow all outbound headers to pass through but only filter out below inbound header
+ // allow all outbound headers to pass through but only filter out
+ // below inbound header
getInFilter().add("sub-date");
- }
+ }
}
}
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpFilterCamelHeadersTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpFilterCamelHeadersTest.java
index ee03f78..c7f8e48 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpFilterCamelHeadersTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpFilterCamelHeadersTest.java
@@ -26,9 +26,9 @@ import org.apache.camel.impl.JndiRegistry;
import org.junit.Test;
public class NettyHttpFilterCamelHeadersTest extends BaseNettyTest {
-
- @BindToRegistry("foo")
- private MyFooBean bean = new MyFooBean();
+
+ @BindToRegistry("foo")
+ private MyFooBean bean = new MyFooBean();
@Test
public void testFilterCamelHeaders() throws Exception {
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderFilterStrategyRemovalTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderFilterStrategyRemovalTest.java
index 5ae0561..5060c64 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderFilterStrategyRemovalTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeaderFilterStrategyRemovalTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.netty4.http;
import static java.util.Collections.singleton;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -26,10 +27,8 @@ import org.junit.Test;
import static org.apache.camel.Exchange.HTTP_QUERY;
-import org.apache.camel.BindToRegistry;
-
public class NettyHttpHeaderFilterStrategyRemovalTest extends BaseNettyTest {
-
+
@BindToRegistry("headerFilterStrategy")
NettyHttpHeaderFilterStrategy headerFilterStrategy = new NettyHttpHeaderFilterStrategy();
@@ -65,8 +64,7 @@ public class NettyHttpHeaderFilterStrategyRemovalTest extends BaseNettyTest {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("netty4-http:http://0.0.0.0:{{port}}/")
- .to(mockEndpoint);
+ from("netty4-http:http://0.0.0.0:{{port}}/").to(mockEndpoint);
}
};
}
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerSessionTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerSessionTest.java
index 8501bc5..95e3dc4 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerSessionTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerSessionTest.java
@@ -30,12 +30,12 @@ import org.junit.Test;
public class NettyHttpProducerSessionTest extends BaseNettyTest {
- @BindToRegistry("instanceCookieHandler")
- private InstanceCookieHandler instanceCookieHandler = new InstanceCookieHandler();
-
- @BindToRegistry("exchangeCookieHandler")
- private ExchangeCookieHandler exchangeCookieHandler = new ExchangeCookieHandler();
-
+ @BindToRegistry("instanceCookieHandler")
+ private InstanceCookieHandler instanceCookieHandler = new InstanceCookieHandler();
+
+ @BindToRegistry("exchangeCookieHandler")
+ private ExchangeCookieHandler exchangeCookieHandler = new ExchangeCookieHandler();
+
@Test
public void testNoSession() throws Exception {
getMockEndpoint("mock:result").expectedBodiesReceived("New New World", "New New World");
@@ -65,36 +65,28 @@ public class NettyHttpProducerSessionTest extends BaseNettyTest {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("direct:start")
- .toF("netty4-http:http://127.0.0.1:%d/session", getPort())
- .toF("netty4-http:http://127.0.0.1:%d/session", getPort())
- .to("mock:result");
+ from("direct:start").toF("netty4-http:http://127.0.0.1:%d/session", getPort()).toF("netty4-http:http://127.0.0.1:%d/session", getPort()).to("mock:result");
- from("direct:instance")
- .toF("netty4-http:http://127.0.0.1:%d/session?cookieHandler=#instanceCookieHandler", getPort())
- .toF("netty4-http:http://127.0.0.1:%d/session?cookieHandler=#instanceCookieHandler", getPort())
- .to("mock:result");
+ from("direct:instance").toF("netty4-http:http://127.0.0.1:%d/session?cookieHandler=#instanceCookieHandler", getPort())
+ .toF("netty4-http:http://127.0.0.1:%d/session?cookieHandler=#instanceCookieHandler", getPort()).to("mock:result");
- from("direct:exchange")
- .toF("netty4-http:http://127.0.0.1:%d/session?cookieHandler=#exchangeCookieHandler", getPort())
- .toF("netty4-http:http://127.0.0.1:%d/session?cookieHandler=#exchangeCookieHandler", getPort())
- .to("mock:result");
+ from("direct:exchange").toF("netty4-http:http://127.0.0.1:%d/session?cookieHandler=#exchangeCookieHandler", getPort())
+ .toF("netty4-http:http://127.0.0.1:%d/session?cookieHandler=#exchangeCookieHandler", getPort()).to("mock:result");
- fromF("jetty:http://127.0.0.1:%d/session?sessionSupport=true", getPort())
- .process(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- HttpMessage message = exchange.getIn(HttpMessage.class);
- HttpSession session = message.getRequest().getSession();
- String body = message.getBody(String.class);
- if ("bar".equals(session.getAttribute("foo"))) {
- message.setBody("Old " + body);
- } else {
- session.setAttribute("foo", "bar");
- message.setBody("New " + body);
- }
+ fromF("jetty:http://127.0.0.1:%d/session?sessionSupport=true", getPort()).process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ HttpMessage message = exchange.getIn(HttpMessage.class);
+ HttpSession session = message.getRequest().getSession();
+ String body = message.getBody(String.class);
+ if ("bar".equals(session.getAttribute("foo"))) {
+ message.setBody("Old " + body);
+ } else {
+ session.setAttribute("foo", "bar");
+ message.setBody("New " + body);
}
- });
+ }
+ });
}
};
}