You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/11/12 10:15:30 UTC

[1/5] camel git commit: Fixed a CS error of camel-apt

Repository: camel
Updated Branches:
  refs/heads/master f3b10c550 -> 9378d293e


Fixed a CS error of camel-apt


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

Branch: refs/heads/master
Commit: 4c363a1bee919e1cee47ffc2fc24cf47cec51d5b
Parents: f3b10c5
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Nov 12 16:12:13 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Nov 12 17:14:37 2014 +0800

----------------------------------------------------------------------
 tooling/apt/src/main/java/org/apache/camel/tools/apt/IOHelper.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4c363a1b/tooling/apt/src/main/java/org/apache/camel/tools/apt/IOHelper.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/IOHelper.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/IOHelper.java
index e6c764a..d4c1717 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/IOHelper.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/IOHelper.java
@@ -22,7 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 
-class IOHelper {
+final class IOHelper {
 
     private IOHelper() {
     }


[2/5] camel git commit: Fixed the CS error of camel-karaf-component

Posted by ni...@apache.org.
Fixed the CS error of camel-karaf-component


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

Branch: refs/heads/master
Commit: 49ab630dd0ca1ce51475038d3bb6d857bebef833
Parents: 4c5ae14
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Nov 12 16:13:05 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Nov 12 17:14:38 2014 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/camel/karaf/commands/ComponentList.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/49ab630d/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ComponentList.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ComponentList.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ComponentList.java
index 1c196a3..43d1a69 100644
--- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ComponentList.java
+++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ComponentList.java
@@ -51,7 +51,7 @@ public class ComponentList extends CamelCommandSupport {
 
     @Option(name = "--verbose", aliases = "-v", description = "Verbose output which shows more information",
             required = false, multiValued = false, valueToShowInHelp = "false")
-    boolean verbose = false;
+    boolean verbose;
 
     protected Object doExecute() throws Exception {
         List<Map<String, String>> components = camelController.listComponents(name);


[5/5] camel git commit: Fixed the CS errors of camel-core

Posted by ni...@apache.org.
Fixed the CS errors of camel-core


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

Branch: refs/heads/master
Commit: 4c5ae14aeae90d6e7b7244fd689bee50db3369d6
Parents: 4c363a1
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Nov 12 16:12:36 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Nov 12 17:14:38 2014 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/camel/component/mock/MockEndpoint.java | 5 +++--
 .../org/apache/camel/component/validator/ValidatorEndpoint.java | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4c5ae14a/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
index 4cb60e9..71e127e 100644
--- a/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
@@ -93,6 +93,9 @@ public class MockEndpoint extends DefaultEndpoint implements BrowsableEndpoint {
     // must be volatile so changes is visible between the thread which performs the assertions
     // and the threads which process the exchanges when routing messages in Camel
     protected volatile Processor reporter;
+    
+    @UriParam(defaultValue = "true")
+    protected boolean copyOnExchange = true;
 
     private volatile Processor defaultProcessor;
     private volatile Map<Integer, Processor> processors;
@@ -110,8 +113,6 @@ public class MockEndpoint extends DefaultEndpoint implements BrowsableEndpoint {
 
     @UriPath(description = "Name of mock endpoint")
     private String name;
-    @UriParam(defaultValue = "true")
-    protected boolean copyOnExchange = true;
     @UriParam
     private volatile int expectedCount;
     @UriParam

http://git-wip-us.apache.org/repos/asf/camel/blob/4c5ae14a/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorEndpoint.java
index 89a6f73..8e260ba 100644
--- a/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/validator/ValidatorEndpoint.java
@@ -20,7 +20,6 @@ import java.io.InputStream;
 import javax.xml.XMLConstants;
 import javax.xml.validation.SchemaFactory;
 
-import org.apache.camel.spi.UriPath;
 import org.w3c.dom.ls.LSResourceResolver;
 
 import org.apache.camel.Component;
@@ -34,6 +33,7 @@ import org.apache.camel.processor.validation.ValidatingProcessor;
 import org.apache.camel.processor.validation.ValidatorErrorHandler;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ResourceHelper;
 import org.slf4j.Logger;


[4/5] camel git commit: CAMEL-8036 JettyComponent should not setup the security handler more than once

Posted by ni...@apache.org.
CAMEL-8036 JettyComponent should not setup the security handler more than once


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

Branch: refs/heads/master
Commit: 9378d293ed0862a8a4e0a699f16e75777647346d
Parents: 11a0549
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Nov 12 17:14:10 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Nov 12 17:14:38 2014 +0800

----------------------------------------------------------------------
 .../org/apache/camel/component/jetty/JettyHttpComponent.java  | 7 +++++--
 .../component/jetty/HttpBasicAuthComponentConfiguredTest.java | 6 ++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9378d293/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 71c3f1e..f2a10ce 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -1075,8 +1075,11 @@ public class JettyHttpComponent extends HttpComponent implements RestConsumerFac
         if (handlers != null && !handlers.isEmpty()) {
             for (Handler handler : handlers) {
                 if (handler instanceof HandlerWrapper) {
-                    ((HandlerWrapper) handler).setHandler(server.getHandler());
-                    server.setHandler(handler);
+                    // avoid setting the security handler more than once
+                    if (!handler.equals(server.getHandler())) {
+                        ((HandlerWrapper) handler).setHandler(server.getHandler());
+                        server.setHandler(handler);
+                    }
                 } else {
                     HandlerCollection handlerCollection = new HandlerCollection();
                     handlerCollection.addHandler(server.getHandler());

http://git-wip-us.apache.org/repos/asf/camel/blob/9378d293/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
index a34ffa9..18fccfc 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
@@ -71,6 +71,9 @@ public class HttpBasicAuthComponentConfiguredTest extends BaseJettyTest {
     public void testHttpBasicAuth() throws Exception {
         String out = template.requestBody("http://localhost:{{port}}/test", "Hello World", String.class);
         assertEquals("Bye World", out);
+        
+        out = template.requestBody("http://localhost:{{port}}/anotherTest", "Hello World", String.class);
+        assertEquals("See you later", out);
     }
 
     @Override
@@ -97,6 +100,9 @@ public class HttpBasicAuthComponentConfiguredTest extends BaseJettyTest {
                         }
                     })
                     .transform(constant("Bye World"));
+                
+                from("jetty://http://localhost:{{port}}/anotherTest?handlers=myAuthHandler")
+                    .transform(constant("See you later"));
             }
         };
     }


[3/5] camel git commit: CAMEL-8035 CXFRS sets the exchange charset if the content type provides one.

Posted by ni...@apache.org.
CAMEL-8035 CXFRS sets the exchange charset if the content type provides one.


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

Branch: refs/heads/master
Commit: 11a0549893720a7a71652bcec74e8d1a75faffcb
Parents: 49ab630
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Nov 12 17:04:18 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Nov 12 17:14:38 2014 +0800

----------------------------------------------------------------------
 .../cxf/jaxrs/DefaultCxfRsBinding.java          | 18 ++++++++
 .../cxf/jaxrs/DefaultCxfRsBindingTest.java      | 45 ++++++++++++++++++++
 2 files changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/11a05498/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
index 867536f..82a2ed7 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
@@ -18,6 +18,7 @@
 package org.apache.camel.component.cxf.jaxrs;
 
 import java.lang.reflect.Method;
+import java.nio.charset.Charset;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -32,6 +33,8 @@ import org.apache.camel.component.cxf.common.message.CxfConstants;
 import org.apache.camel.component.cxf.util.CxfUtils;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.cxf.helpers.HttpHeaderHelper;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.OperationResourceInfoStack;
 import org.apache.cxf.message.MessageContentsList;
@@ -106,6 +109,9 @@ public class DefaultCxfRsBinding implements CxfRsBinding, HeaderFilterStrategyAw
         // TODO use header filter strategy and cxfToCamelHeaderMap
         CxfUtils.copyHttpHeadersFromCxfToCamel(cxfMessage, camelMessage);
         
+        // setup the charset from content-type header
+        setCharsetWithContentType(camelExchange);
+        
         //copy the protocol header
         copyProtocolHeader(cxfMessage, camelMessage, camelMessage.getExchange());
         
@@ -129,6 +135,18 @@ public class DefaultCxfRsBinding implements CxfRsBinding, HeaderFilterStrategyAw
             camelExchange.getIn().getHeaders().put(Exchange.AUTHENTICATION, subject);
         }
     }
+    
+    protected void setCharsetWithContentType(Exchange camelExchange) {
+        // setup the charset from content-type header
+        String contentTypeHeader = ExchangeHelper.getContentType(camelExchange);
+        if (contentTypeHeader != null) {
+            String charset = HttpHeaderHelper.findCharset(contentTypeHeader);
+            String normalizedEncoding = HttpHeaderHelper.mapCharset(charset, Charset.forName("UTF-8").name());
+            if (normalizedEncoding != null) {
+                camelExchange.setProperty(Exchange.CHARSET_NAME, normalizedEncoding);
+            }
+        }
+    }
 
     
     public MultivaluedMap<String, String> bindCamelHeadersToRequestHeaders(Map<String, Object> camelHeaders,

http://git-wip-us.apache.org/repos/asf/camel/blob/11a05498/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBindingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBindingTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBindingTest.java
new file mode 100644
index 0000000..40ddb47
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBindingTest.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.jaxrs;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.util.IOHelper;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DefaultCxfRsBindingTest extends Assert {
+    private DefaultCamelContext context = new DefaultCamelContext();
+    
+    @Test
+    public void testSetCharsetWithContentType() {
+        DefaultCxfRsBinding cxfRsBinding = new DefaultCxfRsBinding();
+        Exchange exchange = new DefaultExchange(context);
+        exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "text/xml;charset=ISO-8859-1");
+        cxfRsBinding.setCharsetWithContentType(exchange);
+        
+        String charset = IOHelper.getCharsetName(exchange);
+        assertEquals("Get a wrong charset", "ISO-8859-1", charset);
+        
+        exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "text/xml");
+        cxfRsBinding.setCharsetWithContentType(exchange);
+        charset = IOHelper.getCharsetName(exchange);
+        assertEquals("Get a worng charset name", "UTF-8", charset);
+    }
+
+}