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 2016/01/14 17:32:43 UTC

[1/2] camel git commit: Fix erroneous logging when mapTemplate.size()==1

Repository: camel
Updated Branches:
  refs/heads/master bfb0a8f0f -> f5116063b


Fix erroneous logging when mapTemplate.size()==1

If mapTemplate.size()==1, the previous logic would still output the "Cannot determine which one to use" message.  Minor issue, but the structure of the internal if statements would leave room for silly logic errors if other code were inserted without thinking hard about all the logical combinations.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f5116063
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f5116063
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f5116063

Branch: refs/heads/master
Commit: f5116063bcfac751ca89aea308cfa611687c2194
Parents: b46df1f
Author: cjnygard <cj...@users.noreply.github.com>
Authored: Tue Jan 12 12:16:26 2016 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jan 14 16:31:00 2016 +0000

----------------------------------------------------------------------
 .../spring/spi/TransactionErrorHandlerBuilder.java    | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f5116063/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
index 27ab662..d3cad1b 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
@@ -76,12 +76,11 @@ public class TransactionErrorHandlerBuilder extends DefaultErrorHandlerBuilder {
 
             if (transactionTemplate == null) {
                 Map<String, TransactionTemplate> mapTemplate = routeContext.lookupByType(TransactionTemplate.class);
-                if (mapTemplate != null && mapTemplate.size() == 1) {
-                    transactionTemplate = mapTemplate.values().iterator().next();
-                }
                 if (mapTemplate == null || mapTemplate.isEmpty()) {
                     LOG.trace("No TransactionTemplate found in registry.");
-                } else {
+                } else if (mapTemplate.size() == 1) {
+                    transactionTemplate = mapTemplate.values().iterator().next();
+                }else {
                     LOG.debug("Found {} TransactionTemplate in registry. Cannot determine which one to use. "
                               + "Please configure a TransactionTemplate on the TransactionErrorHandlerBuilder", mapTemplate.size());
                 }
@@ -89,12 +88,11 @@ public class TransactionErrorHandlerBuilder extends DefaultErrorHandlerBuilder {
 
             if (transactionTemplate == null) {
                 Map<String, PlatformTransactionManager> mapManager = routeContext.lookupByType(PlatformTransactionManager.class);
-                if (mapManager != null && mapManager.size() == 1) {
-                    transactionTemplate = new TransactionTemplate(mapManager.values().iterator().next());
-                }
                 if (mapManager == null || mapManager.isEmpty()) {
                     LOG.trace("No PlatformTransactionManager found in registry.");
-                } else {
+                } else if (mapManager.size() == 1) {
+                    transactionTemplate = new TransactionTemplate(mapManager.values().iterator().next());
+                }else {
                     LOG.debug("Found {} PlatformTransactionManager in registry. Cannot determine which one to use for TransactionTemplate. "
                               + "Please configure a TransactionTemplate on the TransactionErrorHandlerBuilder", mapManager.size());
                 }


[2/2] camel git commit: Fix camel-netty4-http unit tests that use 0.0.0.0 as target address

Posted by da...@apache.org.
Fix camel-netty4-http unit tests that use 0.0.0.0 as target address

This fixes test failures that occur on Mac OS X.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b46df1fd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b46df1fd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b46df1fd

Branch: refs/heads/master
Commit: b46df1fd0ca95cc2033879c295cc1b8a4ec33876
Parents: bfb0a8f
Author: Andreas Veithen <ve...@google.com>
Authored: Sun Jan 10 10:11:57 2016 +0000
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jan 14 16:31:00 2016 +0000

----------------------------------------------------------------------
 .../component/netty4/http/NettyHttpCompressTest.java    |  2 +-
 .../component/netty4/http/NettyHttpContentTypeTest.java | 12 ++++++------
 .../netty4/http/NettyHttpProducerBridgeTest.java        |  4 ++--
 .../netty4/http/NettyHttpProducerQueryParamTest.java    |  2 +-
 .../netty4/http/NettyMixedCaseHttpPathTest.java         |  2 +-
 .../netty4/http/NettyProxyMixedCasePathTest.java        |  6 +++---
 .../netty4/http/NettyRecipientListHttpBaseTest.java     |  2 +-
 .../component/netty4/http/NettyRouteSimpleTest.java     |  2 +-
 8 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b46df1fd/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpCompressTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpCompressTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpCompressTest.java
index 1697c75..92481ec 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpCompressTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpCompressTest.java
@@ -49,7 +49,7 @@ public class NettyHttpCompressTest extends BaseNettyTest {
         Map<String, Object> headers = new HashMap<String, Object>();
         headers.put("content-type", "text/plain; charset=\"UTF-8\"");
         headers.put("Accept-Encoding", "compress, gzip");
-        String out = template.requestBodyAndHeaders("netty4-http:http://0.0.0.0:9001/foo?decoders=#myDecoders", data,
+        String out = template.requestBodyAndHeaders("netty4-http:http://localhost:9001/foo?decoders=#myDecoders", data,
                 headers, String.class);
         // The decoded out has some space to clean up.
         assertEquals("Bye World", out.trim());

http://git-wip-us.apache.org/repos/asf/camel/blob/b46df1fd/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpContentTypeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpContentTypeTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpContentTypeTest.java
index 6a9fbcb..c56a1b6 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpContentTypeTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpContentTypeTest.java
@@ -29,11 +29,11 @@ public class NettyHttpContentTypeTest extends BaseNettyTest {
         getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain; charset=\"iso-8859-1\"");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_CHARACTER_ENCODING, "iso-8859-1");
-        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://0.0.0.0:" + getPort() + "/foo");
+        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://localhost:" + getPort() + "/foo");
         getMockEndpoint("mock:input").expectedPropertyReceived(Exchange.CHARSET_NAME, "iso-8859-1");
 
         byte[] data = "Hello World".getBytes(Charset.forName("iso-8859-1"));
-        String out = template.requestBodyAndHeader("netty4-http:http://0.0.0.0:{{port}}/foo", data,
+        String out = template.requestBodyAndHeader("netty4-http:http://localhost:{{port}}/foo", data,
                 "content-type", "text/plain; charset=\"iso-8859-1\"", String.class);
         assertEquals("Bye World", out);
 
@@ -45,11 +45,11 @@ public class NettyHttpContentTypeTest extends BaseNettyTest {
         getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain;charset=\"iso-8859-1\";action=\"http://somewhere.com/foo\"");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_CHARACTER_ENCODING, "iso-8859-1");
-        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://0.0.0.0:" + getPort() + "/foo");
+        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://localhost:" + getPort() + "/foo");
         getMockEndpoint("mock:input").expectedPropertyReceived(Exchange.CHARSET_NAME, "iso-8859-1");
 
         byte[] data = "Hello World".getBytes(Charset.forName("iso-8859-1"));
-        String out = template.requestBodyAndHeader("netty4-http:http://0.0.0.0:{{port}}/foo", data,
+        String out = template.requestBodyAndHeader("netty4-http:http://localhost:{{port}}/foo", data,
                 "content-type", "text/plain;charset=\"iso-8859-1\";action=\"http://somewhere.com/foo\"", String.class);
         assertEquals("Bye World", out);
 
@@ -61,11 +61,11 @@ public class NettyHttpContentTypeTest extends BaseNettyTest {
         getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.CONTENT_TYPE, "application/soap+xml;charset=\"utf-8\";action=\"http://somewhere.com/foo\"");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_CHARACTER_ENCODING, "utf-8");
-        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://0.0.0.0:" + getPort() + "/foo");
+        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://localhost:" + getPort() + "/foo");
         getMockEndpoint("mock:input").expectedPropertyReceived(Exchange.CHARSET_NAME, "utf-8");
 
         byte[] data = "Hello World".getBytes(Charset.forName("utf-8"));
-        String out = template.requestBodyAndHeader("netty4-http:http://0.0.0.0:{{port}}/foo", data,
+        String out = template.requestBodyAndHeader("netty4-http:http://localhost:{{port}}/foo", data,
                 "content-type", "application/soap+xml;charset=\"utf-8\";action=\"http://somewhere.com/foo\"", String.class);
         assertEquals("Bye World", out);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b46df1fd/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerBridgeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerBridgeTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerBridgeTest.java
index 8592817..ecee0c5 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerBridgeTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerBridgeTest.java
@@ -26,7 +26,7 @@ public class NettyHttpProducerBridgeTest extends BaseNettyTest {
 
     @Test
     public void testProxy() throws Exception {
-        String reply = template.requestBody("netty4-http:http://0.0.0.0:" + port1 + "/foo", "World", String.class);
+        String reply = template.requestBody("netty4-http:http://localhost:" + port1 + "/foo", "World", String.class);
         assertEquals("Bye World", reply);
     }
 
@@ -39,7 +39,7 @@ public class NettyHttpProducerBridgeTest extends BaseNettyTest {
                 port2 = getNextPort();
 
                 from("netty4-http:http://0.0.0.0:" + port1 + "/foo")
-                        .to("netty4-http:http://0.0.0.0:" + port2 + "/bar?bridgeEndpoint=true&throwExceptionOnFailure=false");
+                        .to("netty4-http:http://localhost:" + port2 + "/bar?bridgeEndpoint=true&throwExceptionOnFailure=false");
 
                 from("netty4-http:http://0.0.0.0:" + port2 + "/bar")
                         .transform().simple("Bye ${body}");

http://git-wip-us.apache.org/repos/asf/camel/blob/b46df1fd/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerQueryParamTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerQueryParamTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerQueryParamTest.java
index 4bfee57..82da3b6 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerQueryParamTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpProducerQueryParamTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class NettyHttpProducerQueryParamTest extends BaseNettyTest {
 
-    private String url = "netty4-http:http://0.0.0.0:" + getPort() + "/cheese?urlDecodeHeaders=true";
+    private String url = "netty4-http:http://localhost:" + getPort() + "/cheese?urlDecodeHeaders=true";
 
     @Test
     public void testQueryParameters() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/b46df1fd/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyMixedCaseHttpPathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyMixedCaseHttpPathTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyMixedCaseHttpPathTest.java
index 6d17045..e9a1a6a 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyMixedCaseHttpPathTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyMixedCaseHttpPathTest.java
@@ -26,7 +26,7 @@ public class NettyMixedCaseHttpPathTest extends BaseNettyTest {
     public void testMixedCase() throws Exception {
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_PATH, "/HelloWorld");
 
-        String out = template.requestBody("netty4-http:http://0.0.0.0:{{port}}/SHoppING/HelloWorld", "Camel", String.class);
+        String out = template.requestBody("netty4-http:http://localhost:{{port}}/SHoppING/HelloWorld", "Camel", String.class);
         assertEquals("Bye Camel", out);
 
         assertMockEndpointsSatisfied();

http://git-wip-us.apache.org/repos/asf/camel/blob/b46df1fd/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java
index f4cbfa7..ae50b91 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java
@@ -23,10 +23,10 @@ public class NettyProxyMixedCasePathTest extends BaseNettyTest {
 
     @Test
     public void testMixedCase() throws Exception {
-        String out = template.requestBody("netty4-http:http://0.0.0.0:{{port}}/Shopping", "Camel", String.class);
+        String out = template.requestBody("netty4-http:http://localhost:{{port}}/Shopping", "Camel", String.class);
         assertEquals("Bye Camel", out);
 
-        out = template.requestBody("netty4-http:http://0.0.0.0:{{port}}/shopping", "World", String.class);
+        out = template.requestBody("netty4-http:http://localhost:{{port}}/shopping", "World", String.class);
         assertEquals("Bye World", out);
     }
 
@@ -35,7 +35,7 @@ public class NettyProxyMixedCasePathTest extends BaseNettyTest {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("netty4-http:http://0.0.0.0:{{port}}/Shopping").to("netty4-http:http://0.0.0.0:{{port}}/ws/svc/Shopping");
+                from("netty4-http:http://0.0.0.0:{{port}}/Shopping").to("netty4-http:http://localhost:{{port}}/ws/svc/Shopping");
 
                 from("netty4-http:http://0.0.0.0:{{port}}/ws/svc/Shopping").transform(body().prepend("Bye "));
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/b46df1fd/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRecipientListHttpBaseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRecipientListHttpBaseTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRecipientListHttpBaseTest.java
index 7ca68b8..81c157b 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRecipientListHttpBaseTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRecipientListHttpBaseTest.java
@@ -45,7 +45,7 @@ public class NettyRecipientListHttpBaseTest extends BaseNettyTest {
                     .transform(body().prepend("Bye "));
 
                 from("direct:start")
-                    .recipientList().constant("netty4-http:http://0.0.0.0:{{port}}");
+                    .recipientList().constant("netty4-http:http://localhost:{{port}}");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/b46df1fd/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRouteSimpleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRouteSimpleTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRouteSimpleTest.java
index da7abf5..a7ce942 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRouteSimpleTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyRouteSimpleTest.java
@@ -41,7 +41,7 @@ public class NettyRouteSimpleTest extends BaseNettyTest {
             public void configure() throws Exception {
                 from("netty4-http:http://0.0.0.0:{{port}}/foo")
                     .to("mock:input1")
-                    .to("netty4-http:http://0.0.0.0:" + port2 + "/bar");
+                    .to("netty4-http:http://localhost:" + port2 + "/bar");
                 from("netty4-http:http://0.0.0.0:" + port2 + "/bar")
                     .to("mock:input2")
                     .transform().constant("Bye World");