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/08/18 15:23:05 UTC

[1/6] git commit: CAMEL-7701 Fixed the CS errors and added the content-type header back as it could be used later

Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x ff702629f -> 8c4e34ff3
  refs/heads/camel-2.13.x 3cf66ca51 -> 2c88ba733


CAMEL-7701 Fixed the CS errors and added the content-type header back as it could be used later


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

Branch: refs/heads/camel-2.12.x
Commit: 8c4e34ff3da83531b35d99afb242cddc0f88a34a
Parents: bc5a615
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Aug 15 12:27:28 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Aug 18 21:21:50 2014 +0800

----------------------------------------------------------------------
 .../component/cxf/jaxrs/CxfRsProducer.java      |  16 +-
 .../cxf/jaxrs/DefaultCxfRsBinding.java          |   1 +
 .../component/cxf/jaxrs/CxfRsRelayTest.java     | 202 +++++++++----------
 .../component/cxf/jaxrs/UploadService.java      |  35 ----
 4 files changed, 108 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8c4e34ff/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
index 356e199..572e991 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
@@ -277,16 +277,20 @@ public class CxfRsProducer extends DefaultProducer {
         return answer;
     }
 
-    private Method findRightMethod(List<Class<?>> resourceClasses, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
+    private Method findRightMethod(List<Class<?>> resourceClasses, String methodName,
+                                   Class<?>[] parameterTypes) throws NoSuchMethodException {
         for (Class<?> clazz : resourceClasses) {
             try {
                 Method[] m = clazz.getMethods();
-                iterate_on_methods: for (Method method : m) {
-                    if (!method.getName().equals(methodName))
+            iterate_on_methods:
+                for (Method method : m) {
+                    if (!method.getName().equals(methodName)) {
                         continue;
+                    }
                     Class<?>[] params = method.getParameterTypes();
-                    if (params.length != parameterTypes.length)
+                    if (params.length != parameterTypes.length) {
                         continue;
+                    }
                     for (int i = 0; i < parameterTypes.length; i++) {
                         if (!params[i].isAssignableFrom(parameterTypes[i])) {
                             continue iterate_on_methods;
@@ -298,7 +302,9 @@ public class CxfRsProducer extends DefaultProducer {
                 // keep looking
             }
         }
-        throw new NoSuchMethodException("Cannot find method with name: " + methodName + " having parameters assignable from: " + arrayToString(parameterTypes));
+        throw new NoSuchMethodException("Cannot find method with name: " + methodName
+                                        + " having parameters assignable from: "
+                                        + arrayToString(parameterTypes));
     }
 
     private Class<?>[] getParameterTypes(Object[] objects) {

http://git-wip-us.apache.org/repos/asf/camel/blob/8c4e34ff/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 664ebe3..d72ceab 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
@@ -58,6 +58,7 @@ public class DefaultCxfRsBinding implements CxfRsBinding, HeaderFilterStrategyAw
         camelToCxfHeaderMap.put(Exchange.HTTP_URI, org.apache.cxf.message.Message.REQUEST_URI);
         camelToCxfHeaderMap.put(Exchange.HTTP_METHOD, org.apache.cxf.message.Message.HTTP_REQUEST_METHOD);
         camelToCxfHeaderMap.put(Exchange.HTTP_PATH, org.apache.cxf.message.Message.PATH_INFO);
+        camelToCxfHeaderMap.put(Exchange.CONTENT_TYPE, org.apache.cxf.message.Message.CONTENT_TYPE);
         camelToCxfHeaderMap.put(Exchange.HTTP_CHARACTER_ENCODING, org.apache.cxf.message.Message.ENCODING);
         camelToCxfHeaderMap.put(Exchange.HTTP_QUERY, org.apache.cxf.message.Message.QUERY_STRING);
         camelToCxfHeaderMap.put(Exchange.ACCEPT_CONTENT_TYPE, org.apache.cxf.message.Message.ACCEPT_CONTENT_TYPE);

http://git-wip-us.apache.org/repos/asf/camel/blob/8c4e34ff/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
index c6dbe91..1e05ff4 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
@@ -41,116 +41,106 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.junit.Test;
 
 public class CxfRsRelayTest extends TestSupport {
-	/**
-	 * A sample service "interface" (technically, it is a class since we will
-	 * use proxy-client. That interface exposes three methods over-loading each
-	 * other : we are testing the appropriate one will be chosen at runtime.
-	 * 
-	 */
-	@WebService
-	@Path("/rootpath")
-	@Consumes("multipart/form-data")
-	@Produces("application/xml")
-	public static class UploadService {
-		@WebMethod
-		@POST
-		@Path("/path1")
-		@Consumes("multipart/form-data")
-		public void upload(
-				@Multipart(value = "content", type = "application/octet-stream") java.lang.Number content,
-				@Multipart(value = "name", type = "text/plain") String name) {
-		}
+    /**
+     * A sample service "interface" (technically, it is a class since we will
+     * use proxy-client. That interface exposes three methods over-loading each
+     * other : we are testing the appropriate one will be chosen at runtime.
+     * 
+     */
+    @WebService
+    @Path("/rootpath")
+    @Consumes("multipart/form-data")
+    @Produces("application/xml")
+    public static class UploadService {
+        @WebMethod
+        @POST
+        @Path("/path1")
+        @Consumes("multipart/form-data")
+        public void upload(@Multipart(value = "content", type = "application/octet-stream") java.lang.Number content,
+                           @Multipart(value = "name", type = "text/plain") String name) {
+        }
 
-		@WebMethod
-		@GET
-		@Path("/path2")
-		@Consumes("text/plain")
-		private void upload() {
-		}
+        @WebMethod
+        @GET
+        @Path("/path2")
+        @Consumes("text/plain")
+        private void upload() {
+        }
 
-		@WebMethod
-		@POST
-		@Path("/path3")
-		@Consumes("multipart/form-data")
-		public void upload(
-				@Multipart(value = "content", type = "application/octet-stream") InputStream content,
-				@Multipart(value = "name", type = "text/plain") String name) {
-		}
+        @WebMethod
+        @POST
+        @Path("/path3")
+        @Consumes("multipart/form-data")
+        public void upload(@Multipart(value = "content", type = "application/octet-stream") InputStream content,
+                           @Multipart(value = "name", type = "text/plain") String name) {
+        }
 
-	}
+    }
 
-	private static final String SAMPLE_CONTENT_PATH = "/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml";
-	private static final String SAMPLE_NAME = "CxfRsSpringRelay.xml";
-	private static final CountDownLatch latch = new CountDownLatch(1);
-	private static String content;
-	private static String name;
+    private static final String SAMPLE_CONTENT_PATH = "/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml";
+    private static final String SAMPLE_NAME = "CxfRsSpringRelay.xml";
+    private static final CountDownLatch LATCH = new CountDownLatch(1);
+    private static String content;
+    private static String name;
 
-	/**
-	 * That test builds a route chaining two cxfrs endpoints. It shows a request
-	 * sent to the first one will be correctly transferred and consumed by the
-	 * other one.
-	 */
-	@Test
-	public void test() throws Exception {
-		final Main main = new Main();
-		try {
-			main.setApplicationContextUri("org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml");
-			main.start();
-			latch.await(10, TimeUnit.SECONDS);
-			assertEquals(SAMPLE_NAME, name);
-			StringWriter writer = new StringWriter();
-			IOUtils.copyAndCloseInput(
-					new InputStreamReader(CamelRouteBuilder.class
-							.getResourceAsStream(SAMPLE_CONTENT_PATH)), writer);
-			assertEquals(writer.toString(), content);
-		} finally {
-			main.stop();
-		}
-	}
+    /**
+     * That test builds a route chaining two cxfrs endpoints. It shows a request
+     * sent to the first one will be correctly transferred and consumed by the
+     * other one.
+     */
+    @Test
+    public void testJaxrsRelayRoute() throws Exception {
+        final Main main = new Main();
+        try {
+            main.setApplicationContextUri("org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml");
+            main.start();
+            LATCH.await(10, TimeUnit.SECONDS);
+            assertEquals(SAMPLE_NAME, name);
+            StringWriter writer = new StringWriter();
+            IOUtils.copyAndCloseInput(new InputStreamReader(CamelRouteBuilder.class
+                                          .getResourceAsStream(SAMPLE_CONTENT_PATH)), writer);
+            assertEquals(writer.toString(), content);
+        } finally {
+            main.stop();
+        }
+    }
 
-	/**
-	 * Route builder to be used with
-	 * org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
-	 * 
-	 */
-	public static class CamelRouteBuilder extends RouteBuilder {
-		@Override
-		public void configure() throws InterruptedException {
-			from("upload1").process(new Processor() {
-				@Override
-				public void process(Exchange arg0) throws Exception {
-					// arg0.getIn().removeHeader(Exchange.CONTENT_TYPE);
-				}
-			}).to("upload2Client");
-			from("upload2").process(new Processor() {
-				@Override
-				public void process(Exchange exchange) throws Exception {
-					// once the message arrives in the second endpoint, stores
-					// the message components and warns results can be compared
-					content = (exchange.getIn().getHeader("content", String.class));
-					name = (exchange.getIn().getHeader("name", String.class));
-					latch.countDown();
-				}
-			});
-			Thread t = new Thread(new Runnable() {
-				/**
-				 * Sends a request to the first endpoint in the route
-				 */
-				public void run() {
-					try {
-						JAXRSClientFactory
-								.create(getContext().getEndpoint("upload1", CxfRsEndpoint.class).getAddress(),
-										UploadService.class)
-								.upload(CamelRouteBuilder.class
-										.getResourceAsStream(SAMPLE_CONTENT_PATH),
-										SAMPLE_NAME);
-					} catch (Exception e) {
-						e.printStackTrace();
-						throw new RuntimeException(e);
-					}
-				}
-			});
-			t.start();
-		}
-	}
+    /**
+     * Route builder to be used with
+     * org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
+     * 
+     */
+    public static class CamelRouteBuilder extends RouteBuilder {
+        @Override
+        public void configure() throws InterruptedException {
+            from("upload1").removeHeader(Exchange.CONTENT_TYPE).to("upload2Client");
+            from("upload2").process(new Processor() {
+                @Override
+                public void process(Exchange exchange) throws Exception {
+                    // once the message arrives in the second endpoint, stores
+                    // the message components and warns results can be compared
+                    content = exchange.getIn().getHeader("content", String.class);
+                    name = exchange.getIn().getHeader("name", String.class);
+                    LATCH.countDown();
+                }
+            });
+            Thread t = new Thread(new Runnable() {
+                /**
+                 * Sends a request to the first endpoint in the route
+                 */
+                public void run() {
+                    try {
+                        JAXRSClientFactory.create(getContext().getEndpoint("upload1", CxfRsEndpoint.class)
+                                                      .getAddress(), UploadService.class)
+                            .upload(CamelRouteBuilder.class.getResourceAsStream(SAMPLE_CONTENT_PATH),
+                                    SAMPLE_NAME);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        throw new RuntimeException(e);
+                    }
+                }
+            });
+            t.start();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/8c4e34ff/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
deleted file mode 100644
index a9c65be..0000000
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.apache.camel.component.cxf.jaxrs;
-
-import javax.jws.WebMethod;
-import javax.jws.WebService;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.apache.cxf.jaxrs.ext.multipart.Multipart;
-
-@WebService
-@Path("/cms")
-@Consumes("multipart/form-data")
-@Produces("application/xml")
-public  class UploadService {
-	@WebMethod
-	@POST
-	@Path("/upload2")
-	@Consumes("multipart/form-data")
-	public void addVideo(
-			@Multipart(value = "contenu", type = "application/octet-stream") java.lang.Number video,
-			@Multipart(value = "nom", type = "text/plain") String nom) {
-	}
-
-	@WebMethod
-	@POST
-	@Path("/upload")
-	@Consumes("multipart/form-data")
-	public void addVideo(
-			@Multipart(value = "contenu", type = "application/octet-stream") java.io.InputStream video,
-			@Multipart(value = "nom", type = "text/plain") String nom) {
-	}
-
-}
\ No newline at end of file


[4/6] git commit: CAMEL-7701

Posted by ni...@apache.org.
CAMEL-7701

- more liberal choice of right method in proxy-client cxfrs
- remove Content-Type header propagation from Camel to  CXFRS


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

Branch: refs/heads/camel-2.13.x
Commit: cae28b2af1525b2e9254d77ce9021eb02820d6d6
Parents: 3cf66ca
Author: Benjamin BONNET <be...@m4x.org>
Authored: Thu Aug 14 23:55:31 2014 +0200
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Aug 18 21:22:28 2014 +0800

----------------------------------------------------------------------
 .../component/cxf/jaxrs/CxfRsProducer.java      |  23 +--
 .../cxf/jaxrs/DefaultCxfRsBinding.java          |   1 -
 .../component/cxf/jaxrs/CxfRsRelayTest.java     | 140 +++++++++++++++++++
 .../component/cxf/jaxrs/UploadService.java      |  35 +++++
 .../component/cxf/jaxrs/CxfRsSpringRelay.xml    |  28 ++++
 5 files changed, 218 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cae28b2a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
index d4bbca7..356e199 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
@@ -278,20 +278,27 @@ public class CxfRsProducer extends DefaultProducer {
     }
 
     private Method findRightMethod(List<Class<?>> resourceClasses, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
-        Method answer = null;
         for (Class<?> clazz : resourceClasses) {
             try {
-                answer = clazz.getMethod(methodName, parameterTypes);
-            } catch (NoSuchMethodException ex) {
-                // keep looking 
+                Method[] m = clazz.getMethods();
+                iterate_on_methods: for (Method method : m) {
+                    if (!method.getName().equals(methodName))
+                        continue;
+                    Class<?>[] params = method.getParameterTypes();
+                    if (params.length != parameterTypes.length)
+                        continue;
+                    for (int i = 0; i < parameterTypes.length; i++) {
+                        if (!params[i].isAssignableFrom(parameterTypes[i])) {
+                            continue iterate_on_methods;
+                        }
+                    }
+                    return method;
+                }
             } catch (SecurityException ex) {
                 // keep looking
             }
-            if (answer != null) {
-                return answer;
-            }
         }
-        throw new NoSuchMethodException("Cannot find method with name: " + methodName + " having parameters: " + arrayToString(parameterTypes));
+        throw new NoSuchMethodException("Cannot find method with name: " + methodName + " having parameters assignable from: " + arrayToString(parameterTypes));
     }
 
     private Class<?>[] getParameterTypes(Object[] objects) {

http://git-wip-us.apache.org/repos/asf/camel/blob/cae28b2a/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 d72ceab..664ebe3 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
@@ -58,7 +58,6 @@ public class DefaultCxfRsBinding implements CxfRsBinding, HeaderFilterStrategyAw
         camelToCxfHeaderMap.put(Exchange.HTTP_URI, org.apache.cxf.message.Message.REQUEST_URI);
         camelToCxfHeaderMap.put(Exchange.HTTP_METHOD, org.apache.cxf.message.Message.HTTP_REQUEST_METHOD);
         camelToCxfHeaderMap.put(Exchange.HTTP_PATH, org.apache.cxf.message.Message.PATH_INFO);
-        camelToCxfHeaderMap.put(Exchange.CONTENT_TYPE, org.apache.cxf.message.Message.CONTENT_TYPE);
         camelToCxfHeaderMap.put(Exchange.HTTP_CHARACTER_ENCODING, org.apache.cxf.message.Message.ENCODING);
         camelToCxfHeaderMap.put(Exchange.HTTP_QUERY, org.apache.cxf.message.Message.QUERY_STRING);
         camelToCxfHeaderMap.put(Exchange.ACCEPT_CONTENT_TYPE, org.apache.cxf.message.Message.ACCEPT_CONTENT_TYPE);

http://git-wip-us.apache.org/repos/asf/camel/blob/cae28b2a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
new file mode 100644
index 0000000..6c5c227
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
@@ -0,0 +1,140 @@
+package org.apache.camel.component.cxf.jaxrs;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.Main;
+import org.apache.camel.test.junit4.TestSupport;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+import org.apache.cxf.jaxrs.ext.multipart.Multipart;
+import org.junit.Test;
+
+public class CxfRsRelayTest extends TestSupport {
+	/**
+	 * A sample service "interface" (technically, it is a class since we will
+	 * use proxy-client. That interface exposes three methods over-loading each
+	 * other : we are testing the appropriate one will be chosen at runtime.
+	 * 
+	 */
+	@WebService
+	@Path("/rootpath")
+	@Consumes("multipart/form-data")
+	@Produces("application/xml")
+	public static class UploadService {
+		@WebMethod
+		@POST
+		@Path("/path1")
+		@Consumes("multipart/form-data")
+		public void upload(
+				@Multipart(value = "content", type = "application/octet-stream") java.lang.Number content,
+				@Multipart(value = "name", type = "text/plain") String name) {
+		}
+
+		@WebMethod
+		@GET
+		@Path("/path2")
+		@Consumes("text/plain")
+		private void upload() {
+		}
+
+		@WebMethod
+		@POST
+		@Path("/path3")
+		@Consumes("multipart/form-data")
+		public void upload(
+				@Multipart(value = "content", type = "application/octet-stream") InputStream content,
+				@Multipart(value = "name", type = "text/plain") String name) {
+		}
+
+	}
+
+	private static final String SAMPLE_CONTENT_PATH = "/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml";
+	private static final String SAMPLE_NAME = "CxfRsSpringRelay.xml";
+	private static final CountDownLatch latch = new CountDownLatch(1);
+	private static String content;
+	private static String name;
+
+	/**
+	 * That test builds a route chaining two cxfrs endpoints. It shows a request
+	 * sent to the first one will be correctly transferred and consumed by the
+	 * other one.
+	 */
+	@Test
+	public void test() throws Exception {
+		final Main main = new Main();
+		try {
+			main.setApplicationContextUri("org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml");
+			main.start();
+			latch.await(10, TimeUnit.SECONDS);
+			assertEquals(SAMPLE_NAME, name);
+			StringWriter writer = new StringWriter();
+			IOUtils.copyAndCloseInput(
+					new InputStreamReader(CamelRouteBuilder.class
+							.getResourceAsStream(SAMPLE_CONTENT_PATH)), writer);
+			assertEquals(writer.toString(), content);
+		} finally {
+			main.stop();
+		}
+	}
+
+	/**
+	 * Route builder to be used with
+	 * org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
+	 * 
+	 */
+	public static class CamelRouteBuilder extends RouteBuilder {
+		@Override
+		public void configure() throws InterruptedException {
+			from("upload1").process(new Processor() {
+				@Override
+				public void process(Exchange arg0) throws Exception {
+					// arg0.getIn().removeHeader(Exchange.CONTENT_TYPE);
+				}
+			}).to("upload2Client");
+			from("upload2").process(new Processor() {
+				@Override
+				public void process(Exchange exchange) throws Exception {
+					// once the message arrives in the second endpoint, stores
+					// the message components and warns results can be compared
+					content = (exchange.getIn().getHeader("content", String.class));
+					name = (exchange.getIn().getHeader("name", String.class));
+					latch.countDown();
+				}
+			});
+			Thread t = new Thread(new Runnable() {
+				/**
+				 * Sends a request to the first endpoint in the route
+				 */
+				public void run() {
+					try {
+						JAXRSClientFactory
+								.create(getContext().getEndpoint("upload1", CxfRsEndpoint.class).getAddress(),
+										UploadService.class)
+								.upload(CamelRouteBuilder.class
+										.getResourceAsStream(SAMPLE_CONTENT_PATH),
+										SAMPLE_NAME);
+					} catch (Exception e) {
+						e.printStackTrace();
+						throw new RuntimeException(e);
+					}
+				}
+			});
+			t.start();
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/cae28b2a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
new file mode 100644
index 0000000..a9c65be
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
@@ -0,0 +1,35 @@
+package org.apache.camel.component.cxf.jaxrs;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.cxf.jaxrs.ext.multipart.Multipart;
+
+@WebService
+@Path("/cms")
+@Consumes("multipart/form-data")
+@Produces("application/xml")
+public  class UploadService {
+	@WebMethod
+	@POST
+	@Path("/upload2")
+	@Consumes("multipart/form-data")
+	public void addVideo(
+			@Multipart(value = "contenu", type = "application/octet-stream") java.lang.Number video,
+			@Multipart(value = "nom", type = "text/plain") String nom) {
+	}
+
+	@WebMethod
+	@POST
+	@Path("/upload")
+	@Consumes("multipart/form-data")
+	public void addVideo(
+			@Multipart(value = "contenu", type = "application/octet-stream") java.io.InputStream video,
+			@Multipart(value = "nom", type = "text/plain") String nom) {
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/cae28b2a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
new file mode 100644
index 0000000..c5a844e
--- /dev/null
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
+	xmlns:cxf="http://camel.apache.org/schema/cxf" 
+	xsi:schemaLocation="http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
+                        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+	<bean id="builder"
+		class="org.apache.camel.component.cxf.jaxrs.CxfRsRelayTest.CamelRouteBuilder" />
+	<camel:camelContext id="cxfrs_context">
+		<camel:routeBuilder ref="builder" />
+		<camel:endpoint id="upload1"
+			uri="cxfrs:bean:rsServer1?bindingStyle=SimpleConsumer" />
+		<camel:endpoint id="upload2"
+			uri="cxfrs:bean:rsServer2?bindingStyle=SimpleConsumer" />
+		<camel:endpoint id="upload2Client"
+			uri="cxfrs:bean:rsClient2?httpClientAPI=false" />
+	</camel:camelContext>
+	<cxf:rsServer id="rsServer1" address="http://localhost:9002/rest"
+		serviceClass="org.apache.camel.component.cxf.jaxrs.CxfRsRelayTest.UploadService"
+		loggingFeatureEnabled="true" loggingSizeLimit="5000" />
+	<cxf:rsServer id="rsServer2" address="http://localhost:9002/rast"
+		serviceClass="org.apache.camel.component.cxf.jaxrs.CxfRsRelayTest.UploadService"
+		loggingFeatureEnabled="true" loggingSizeLimit="5000" />
+	<cxf:rsClient id="rsClient2" address="http://localhost:9002/rast"
+		serviceClass="org.apache.camel.component.cxf.jaxrs.CxfRsRelayTest.UploadService"
+		loggingFeatureEnabled="true" loggingSizeLimit="5000" />
+</beans>
\ No newline at end of file


[3/6] git commit: CAMEL-7701 added Apache file-header

Posted by ni...@apache.org.
CAMEL-7701 added Apache file-header


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

Branch: refs/heads/camel-2.12.x
Commit: bc5a615ffae945c2a36a304bb2a55461591505b9
Parents: d63a791
Author: Benjamin BONNET <be...@m4x.org>
Authored: Fri Aug 15 00:08:19 2014 +0200
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Aug 18 21:21:50 2014 +0800

----------------------------------------------------------------------
 .../camel/component/cxf/jaxrs/CxfRsRelayTest.java   | 16 ++++++++++++++++
 .../camel/component/cxf/jaxrs/CxfRsSpringRelay.xml  | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bc5a615f/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
index 6c5c227..c6dbe91 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
@@ -1,3 +1,19 @@
+/**
+ * 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 java.io.InputStream;

http://git-wip-us.apache.org/repos/asf/camel/blob/bc5a615f/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
index c5a844e..a7d5adc 100644
--- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
 <beans xmlns="http://www.springframework.org/schema/beans"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
 	xmlns:cxf="http://camel.apache.org/schema/cxf" 


[2/6] git commit: CAMEL-7701

Posted by ni...@apache.org.
CAMEL-7701

- more liberal choice of right method in proxy-client cxfrs
- remove Content-Type header propagation from Camel to  CXFRS


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

Branch: refs/heads/camel-2.12.x
Commit: d63a7916645ba56ee1282608a9f553ad4143a09c
Parents: ff70262
Author: Benjamin BONNET <be...@m4x.org>
Authored: Thu Aug 14 23:55:31 2014 +0200
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Aug 18 21:21:50 2014 +0800

----------------------------------------------------------------------
 .../component/cxf/jaxrs/CxfRsProducer.java      |  23 +--
 .../cxf/jaxrs/DefaultCxfRsBinding.java          |   1 -
 .../component/cxf/jaxrs/CxfRsRelayTest.java     | 140 +++++++++++++++++++
 .../component/cxf/jaxrs/UploadService.java      |  35 +++++
 .../component/cxf/jaxrs/CxfRsSpringRelay.xml    |  28 ++++
 5 files changed, 218 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d63a7916/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
index d4bbca7..356e199 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
@@ -278,20 +278,27 @@ public class CxfRsProducer extends DefaultProducer {
     }
 
     private Method findRightMethod(List<Class<?>> resourceClasses, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
-        Method answer = null;
         for (Class<?> clazz : resourceClasses) {
             try {
-                answer = clazz.getMethod(methodName, parameterTypes);
-            } catch (NoSuchMethodException ex) {
-                // keep looking 
+                Method[] m = clazz.getMethods();
+                iterate_on_methods: for (Method method : m) {
+                    if (!method.getName().equals(methodName))
+                        continue;
+                    Class<?>[] params = method.getParameterTypes();
+                    if (params.length != parameterTypes.length)
+                        continue;
+                    for (int i = 0; i < parameterTypes.length; i++) {
+                        if (!params[i].isAssignableFrom(parameterTypes[i])) {
+                            continue iterate_on_methods;
+                        }
+                    }
+                    return method;
+                }
             } catch (SecurityException ex) {
                 // keep looking
             }
-            if (answer != null) {
-                return answer;
-            }
         }
-        throw new NoSuchMethodException("Cannot find method with name: " + methodName + " having parameters: " + arrayToString(parameterTypes));
+        throw new NoSuchMethodException("Cannot find method with name: " + methodName + " having parameters assignable from: " + arrayToString(parameterTypes));
     }
 
     private Class<?>[] getParameterTypes(Object[] objects) {

http://git-wip-us.apache.org/repos/asf/camel/blob/d63a7916/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 d72ceab..664ebe3 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
@@ -58,7 +58,6 @@ public class DefaultCxfRsBinding implements CxfRsBinding, HeaderFilterStrategyAw
         camelToCxfHeaderMap.put(Exchange.HTTP_URI, org.apache.cxf.message.Message.REQUEST_URI);
         camelToCxfHeaderMap.put(Exchange.HTTP_METHOD, org.apache.cxf.message.Message.HTTP_REQUEST_METHOD);
         camelToCxfHeaderMap.put(Exchange.HTTP_PATH, org.apache.cxf.message.Message.PATH_INFO);
-        camelToCxfHeaderMap.put(Exchange.CONTENT_TYPE, org.apache.cxf.message.Message.CONTENT_TYPE);
         camelToCxfHeaderMap.put(Exchange.HTTP_CHARACTER_ENCODING, org.apache.cxf.message.Message.ENCODING);
         camelToCxfHeaderMap.put(Exchange.HTTP_QUERY, org.apache.cxf.message.Message.QUERY_STRING);
         camelToCxfHeaderMap.put(Exchange.ACCEPT_CONTENT_TYPE, org.apache.cxf.message.Message.ACCEPT_CONTENT_TYPE);

http://git-wip-us.apache.org/repos/asf/camel/blob/d63a7916/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
new file mode 100644
index 0000000..6c5c227
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
@@ -0,0 +1,140 @@
+package org.apache.camel.component.cxf.jaxrs;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.Main;
+import org.apache.camel.test.junit4.TestSupport;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+import org.apache.cxf.jaxrs.ext.multipart.Multipart;
+import org.junit.Test;
+
+public class CxfRsRelayTest extends TestSupport {
+	/**
+	 * A sample service "interface" (technically, it is a class since we will
+	 * use proxy-client. That interface exposes three methods over-loading each
+	 * other : we are testing the appropriate one will be chosen at runtime.
+	 * 
+	 */
+	@WebService
+	@Path("/rootpath")
+	@Consumes("multipart/form-data")
+	@Produces("application/xml")
+	public static class UploadService {
+		@WebMethod
+		@POST
+		@Path("/path1")
+		@Consumes("multipart/form-data")
+		public void upload(
+				@Multipart(value = "content", type = "application/octet-stream") java.lang.Number content,
+				@Multipart(value = "name", type = "text/plain") String name) {
+		}
+
+		@WebMethod
+		@GET
+		@Path("/path2")
+		@Consumes("text/plain")
+		private void upload() {
+		}
+
+		@WebMethod
+		@POST
+		@Path("/path3")
+		@Consumes("multipart/form-data")
+		public void upload(
+				@Multipart(value = "content", type = "application/octet-stream") InputStream content,
+				@Multipart(value = "name", type = "text/plain") String name) {
+		}
+
+	}
+
+	private static final String SAMPLE_CONTENT_PATH = "/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml";
+	private static final String SAMPLE_NAME = "CxfRsSpringRelay.xml";
+	private static final CountDownLatch latch = new CountDownLatch(1);
+	private static String content;
+	private static String name;
+
+	/**
+	 * That test builds a route chaining two cxfrs endpoints. It shows a request
+	 * sent to the first one will be correctly transferred and consumed by the
+	 * other one.
+	 */
+	@Test
+	public void test() throws Exception {
+		final Main main = new Main();
+		try {
+			main.setApplicationContextUri("org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml");
+			main.start();
+			latch.await(10, TimeUnit.SECONDS);
+			assertEquals(SAMPLE_NAME, name);
+			StringWriter writer = new StringWriter();
+			IOUtils.copyAndCloseInput(
+					new InputStreamReader(CamelRouteBuilder.class
+							.getResourceAsStream(SAMPLE_CONTENT_PATH)), writer);
+			assertEquals(writer.toString(), content);
+		} finally {
+			main.stop();
+		}
+	}
+
+	/**
+	 * Route builder to be used with
+	 * org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
+	 * 
+	 */
+	public static class CamelRouteBuilder extends RouteBuilder {
+		@Override
+		public void configure() throws InterruptedException {
+			from("upload1").process(new Processor() {
+				@Override
+				public void process(Exchange arg0) throws Exception {
+					// arg0.getIn().removeHeader(Exchange.CONTENT_TYPE);
+				}
+			}).to("upload2Client");
+			from("upload2").process(new Processor() {
+				@Override
+				public void process(Exchange exchange) throws Exception {
+					// once the message arrives in the second endpoint, stores
+					// the message components and warns results can be compared
+					content = (exchange.getIn().getHeader("content", String.class));
+					name = (exchange.getIn().getHeader("name", String.class));
+					latch.countDown();
+				}
+			});
+			Thread t = new Thread(new Runnable() {
+				/**
+				 * Sends a request to the first endpoint in the route
+				 */
+				public void run() {
+					try {
+						JAXRSClientFactory
+								.create(getContext().getEndpoint("upload1", CxfRsEndpoint.class).getAddress(),
+										UploadService.class)
+								.upload(CamelRouteBuilder.class
+										.getResourceAsStream(SAMPLE_CONTENT_PATH),
+										SAMPLE_NAME);
+					} catch (Exception e) {
+						e.printStackTrace();
+						throw new RuntimeException(e);
+					}
+				}
+			});
+			t.start();
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d63a7916/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
new file mode 100644
index 0000000..a9c65be
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
@@ -0,0 +1,35 @@
+package org.apache.camel.component.cxf.jaxrs;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.cxf.jaxrs.ext.multipart.Multipart;
+
+@WebService
+@Path("/cms")
+@Consumes("multipart/form-data")
+@Produces("application/xml")
+public  class UploadService {
+	@WebMethod
+	@POST
+	@Path("/upload2")
+	@Consumes("multipart/form-data")
+	public void addVideo(
+			@Multipart(value = "contenu", type = "application/octet-stream") java.lang.Number video,
+			@Multipart(value = "nom", type = "text/plain") String nom) {
+	}
+
+	@WebMethod
+	@POST
+	@Path("/upload")
+	@Consumes("multipart/form-data")
+	public void addVideo(
+			@Multipart(value = "contenu", type = "application/octet-stream") java.io.InputStream video,
+			@Multipart(value = "nom", type = "text/plain") String nom) {
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/d63a7916/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
new file mode 100644
index 0000000..c5a844e
--- /dev/null
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
+	xmlns:cxf="http://camel.apache.org/schema/cxf" 
+	xsi:schemaLocation="http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
+                        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+	<bean id="builder"
+		class="org.apache.camel.component.cxf.jaxrs.CxfRsRelayTest.CamelRouteBuilder" />
+	<camel:camelContext id="cxfrs_context">
+		<camel:routeBuilder ref="builder" />
+		<camel:endpoint id="upload1"
+			uri="cxfrs:bean:rsServer1?bindingStyle=SimpleConsumer" />
+		<camel:endpoint id="upload2"
+			uri="cxfrs:bean:rsServer2?bindingStyle=SimpleConsumer" />
+		<camel:endpoint id="upload2Client"
+			uri="cxfrs:bean:rsClient2?httpClientAPI=false" />
+	</camel:camelContext>
+	<cxf:rsServer id="rsServer1" address="http://localhost:9002/rest"
+		serviceClass="org.apache.camel.component.cxf.jaxrs.CxfRsRelayTest.UploadService"
+		loggingFeatureEnabled="true" loggingSizeLimit="5000" />
+	<cxf:rsServer id="rsServer2" address="http://localhost:9002/rast"
+		serviceClass="org.apache.camel.component.cxf.jaxrs.CxfRsRelayTest.UploadService"
+		loggingFeatureEnabled="true" loggingSizeLimit="5000" />
+	<cxf:rsClient id="rsClient2" address="http://localhost:9002/rast"
+		serviceClass="org.apache.camel.component.cxf.jaxrs.CxfRsRelayTest.UploadService"
+		loggingFeatureEnabled="true" loggingSizeLimit="5000" />
+</beans>
\ No newline at end of file


[6/6] git commit: CAMEL-7701 added Apache file-header

Posted by ni...@apache.org.
CAMEL-7701 added Apache file-header


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

Branch: refs/heads/camel-2.13.x
Commit: f73b9d46595e7fd9e21146d4ce536e6ae9cac02d
Parents: cae28b2
Author: Benjamin BONNET <be...@m4x.org>
Authored: Fri Aug 15 00:08:19 2014 +0200
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Aug 18 21:22:28 2014 +0800

----------------------------------------------------------------------
 .../camel/component/cxf/jaxrs/CxfRsRelayTest.java   | 16 ++++++++++++++++
 .../camel/component/cxf/jaxrs/CxfRsSpringRelay.xml  | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f73b9d46/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
index 6c5c227..c6dbe91 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
@@ -1,3 +1,19 @@
+/**
+ * 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 java.io.InputStream;

http://git-wip-us.apache.org/repos/asf/camel/blob/f73b9d46/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
index c5a844e..a7d5adc 100644
--- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
 <beans xmlns="http://www.springframework.org/schema/beans"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
 	xmlns:cxf="http://camel.apache.org/schema/cxf" 


[5/6] git commit: CAMEL-7701 Fixed the CS errors and added the content-type header back as it could be used later

Posted by ni...@apache.org.
CAMEL-7701 Fixed the CS errors and added the content-type header back as it could be used later


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

Branch: refs/heads/camel-2.13.x
Commit: 2c88ba733f74077142c5009ab45e886a9fc07782
Parents: f73b9d4
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Aug 15 12:27:28 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Aug 18 21:22:28 2014 +0800

----------------------------------------------------------------------
 .../component/cxf/jaxrs/CxfRsProducer.java      |  16 +-
 .../cxf/jaxrs/DefaultCxfRsBinding.java          |   1 +
 .../component/cxf/jaxrs/CxfRsRelayTest.java     | 202 +++++++++----------
 .../component/cxf/jaxrs/UploadService.java      |  35 ----
 4 files changed, 108 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2c88ba73/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
index 356e199..572e991 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
@@ -277,16 +277,20 @@ public class CxfRsProducer extends DefaultProducer {
         return answer;
     }
 
-    private Method findRightMethod(List<Class<?>> resourceClasses, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
+    private Method findRightMethod(List<Class<?>> resourceClasses, String methodName,
+                                   Class<?>[] parameterTypes) throws NoSuchMethodException {
         for (Class<?> clazz : resourceClasses) {
             try {
                 Method[] m = clazz.getMethods();
-                iterate_on_methods: for (Method method : m) {
-                    if (!method.getName().equals(methodName))
+            iterate_on_methods:
+                for (Method method : m) {
+                    if (!method.getName().equals(methodName)) {
                         continue;
+                    }
                     Class<?>[] params = method.getParameterTypes();
-                    if (params.length != parameterTypes.length)
+                    if (params.length != parameterTypes.length) {
                         continue;
+                    }
                     for (int i = 0; i < parameterTypes.length; i++) {
                         if (!params[i].isAssignableFrom(parameterTypes[i])) {
                             continue iterate_on_methods;
@@ -298,7 +302,9 @@ public class CxfRsProducer extends DefaultProducer {
                 // keep looking
             }
         }
-        throw new NoSuchMethodException("Cannot find method with name: " + methodName + " having parameters assignable from: " + arrayToString(parameterTypes));
+        throw new NoSuchMethodException("Cannot find method with name: " + methodName
+                                        + " having parameters assignable from: "
+                                        + arrayToString(parameterTypes));
     }
 
     private Class<?>[] getParameterTypes(Object[] objects) {

http://git-wip-us.apache.org/repos/asf/camel/blob/2c88ba73/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 664ebe3..d72ceab 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
@@ -58,6 +58,7 @@ public class DefaultCxfRsBinding implements CxfRsBinding, HeaderFilterStrategyAw
         camelToCxfHeaderMap.put(Exchange.HTTP_URI, org.apache.cxf.message.Message.REQUEST_URI);
         camelToCxfHeaderMap.put(Exchange.HTTP_METHOD, org.apache.cxf.message.Message.HTTP_REQUEST_METHOD);
         camelToCxfHeaderMap.put(Exchange.HTTP_PATH, org.apache.cxf.message.Message.PATH_INFO);
+        camelToCxfHeaderMap.put(Exchange.CONTENT_TYPE, org.apache.cxf.message.Message.CONTENT_TYPE);
         camelToCxfHeaderMap.put(Exchange.HTTP_CHARACTER_ENCODING, org.apache.cxf.message.Message.ENCODING);
         camelToCxfHeaderMap.put(Exchange.HTTP_QUERY, org.apache.cxf.message.Message.QUERY_STRING);
         camelToCxfHeaderMap.put(Exchange.ACCEPT_CONTENT_TYPE, org.apache.cxf.message.Message.ACCEPT_CONTENT_TYPE);

http://git-wip-us.apache.org/repos/asf/camel/blob/2c88ba73/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
index c6dbe91..1e05ff4 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRelayTest.java
@@ -41,116 +41,106 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.junit.Test;
 
 public class CxfRsRelayTest extends TestSupport {
-	/**
-	 * A sample service "interface" (technically, it is a class since we will
-	 * use proxy-client. That interface exposes three methods over-loading each
-	 * other : we are testing the appropriate one will be chosen at runtime.
-	 * 
-	 */
-	@WebService
-	@Path("/rootpath")
-	@Consumes("multipart/form-data")
-	@Produces("application/xml")
-	public static class UploadService {
-		@WebMethod
-		@POST
-		@Path("/path1")
-		@Consumes("multipart/form-data")
-		public void upload(
-				@Multipart(value = "content", type = "application/octet-stream") java.lang.Number content,
-				@Multipart(value = "name", type = "text/plain") String name) {
-		}
+    /**
+     * A sample service "interface" (technically, it is a class since we will
+     * use proxy-client. That interface exposes three methods over-loading each
+     * other : we are testing the appropriate one will be chosen at runtime.
+     * 
+     */
+    @WebService
+    @Path("/rootpath")
+    @Consumes("multipart/form-data")
+    @Produces("application/xml")
+    public static class UploadService {
+        @WebMethod
+        @POST
+        @Path("/path1")
+        @Consumes("multipart/form-data")
+        public void upload(@Multipart(value = "content", type = "application/octet-stream") java.lang.Number content,
+                           @Multipart(value = "name", type = "text/plain") String name) {
+        }
 
-		@WebMethod
-		@GET
-		@Path("/path2")
-		@Consumes("text/plain")
-		private void upload() {
-		}
+        @WebMethod
+        @GET
+        @Path("/path2")
+        @Consumes("text/plain")
+        private void upload() {
+        }
 
-		@WebMethod
-		@POST
-		@Path("/path3")
-		@Consumes("multipart/form-data")
-		public void upload(
-				@Multipart(value = "content", type = "application/octet-stream") InputStream content,
-				@Multipart(value = "name", type = "text/plain") String name) {
-		}
+        @WebMethod
+        @POST
+        @Path("/path3")
+        @Consumes("multipart/form-data")
+        public void upload(@Multipart(value = "content", type = "application/octet-stream") InputStream content,
+                           @Multipart(value = "name", type = "text/plain") String name) {
+        }
 
-	}
+    }
 
-	private static final String SAMPLE_CONTENT_PATH = "/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml";
-	private static final String SAMPLE_NAME = "CxfRsSpringRelay.xml";
-	private static final CountDownLatch latch = new CountDownLatch(1);
-	private static String content;
-	private static String name;
+    private static final String SAMPLE_CONTENT_PATH = "/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml";
+    private static final String SAMPLE_NAME = "CxfRsSpringRelay.xml";
+    private static final CountDownLatch LATCH = new CountDownLatch(1);
+    private static String content;
+    private static String name;
 
-	/**
-	 * That test builds a route chaining two cxfrs endpoints. It shows a request
-	 * sent to the first one will be correctly transferred and consumed by the
-	 * other one.
-	 */
-	@Test
-	public void test() throws Exception {
-		final Main main = new Main();
-		try {
-			main.setApplicationContextUri("org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml");
-			main.start();
-			latch.await(10, TimeUnit.SECONDS);
-			assertEquals(SAMPLE_NAME, name);
-			StringWriter writer = new StringWriter();
-			IOUtils.copyAndCloseInput(
-					new InputStreamReader(CamelRouteBuilder.class
-							.getResourceAsStream(SAMPLE_CONTENT_PATH)), writer);
-			assertEquals(writer.toString(), content);
-		} finally {
-			main.stop();
-		}
-	}
+    /**
+     * That test builds a route chaining two cxfrs endpoints. It shows a request
+     * sent to the first one will be correctly transferred and consumed by the
+     * other one.
+     */
+    @Test
+    public void testJaxrsRelayRoute() throws Exception {
+        final Main main = new Main();
+        try {
+            main.setApplicationContextUri("org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml");
+            main.start();
+            LATCH.await(10, TimeUnit.SECONDS);
+            assertEquals(SAMPLE_NAME, name);
+            StringWriter writer = new StringWriter();
+            IOUtils.copyAndCloseInput(new InputStreamReader(CamelRouteBuilder.class
+                                          .getResourceAsStream(SAMPLE_CONTENT_PATH)), writer);
+            assertEquals(writer.toString(), content);
+        } finally {
+            main.stop();
+        }
+    }
 
-	/**
-	 * Route builder to be used with
-	 * org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
-	 * 
-	 */
-	public static class CamelRouteBuilder extends RouteBuilder {
-		@Override
-		public void configure() throws InterruptedException {
-			from("upload1").process(new Processor() {
-				@Override
-				public void process(Exchange arg0) throws Exception {
-					// arg0.getIn().removeHeader(Exchange.CONTENT_TYPE);
-				}
-			}).to("upload2Client");
-			from("upload2").process(new Processor() {
-				@Override
-				public void process(Exchange exchange) throws Exception {
-					// once the message arrives in the second endpoint, stores
-					// the message components and warns results can be compared
-					content = (exchange.getIn().getHeader("content", String.class));
-					name = (exchange.getIn().getHeader("name", String.class));
-					latch.countDown();
-				}
-			});
-			Thread t = new Thread(new Runnable() {
-				/**
-				 * Sends a request to the first endpoint in the route
-				 */
-				public void run() {
-					try {
-						JAXRSClientFactory
-								.create(getContext().getEndpoint("upload1", CxfRsEndpoint.class).getAddress(),
-										UploadService.class)
-								.upload(CamelRouteBuilder.class
-										.getResourceAsStream(SAMPLE_CONTENT_PATH),
-										SAMPLE_NAME);
-					} catch (Exception e) {
-						e.printStackTrace();
-						throw new RuntimeException(e);
-					}
-				}
-			});
-			t.start();
-		}
-	}
+    /**
+     * Route builder to be used with
+     * org/apache/camel/component/cxf/jaxrs/CxfRsSpringRelay.xml
+     * 
+     */
+    public static class CamelRouteBuilder extends RouteBuilder {
+        @Override
+        public void configure() throws InterruptedException {
+            from("upload1").removeHeader(Exchange.CONTENT_TYPE).to("upload2Client");
+            from("upload2").process(new Processor() {
+                @Override
+                public void process(Exchange exchange) throws Exception {
+                    // once the message arrives in the second endpoint, stores
+                    // the message components and warns results can be compared
+                    content = exchange.getIn().getHeader("content", String.class);
+                    name = exchange.getIn().getHeader("name", String.class);
+                    LATCH.countDown();
+                }
+            });
+            Thread t = new Thread(new Runnable() {
+                /**
+                 * Sends a request to the first endpoint in the route
+                 */
+                public void run() {
+                    try {
+                        JAXRSClientFactory.create(getContext().getEndpoint("upload1", CxfRsEndpoint.class)
+                                                      .getAddress(), UploadService.class)
+                            .upload(CamelRouteBuilder.class.getResourceAsStream(SAMPLE_CONTENT_PATH),
+                                    SAMPLE_NAME);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        throw new RuntimeException(e);
+                    }
+                }
+            });
+            t.start();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/2c88ba73/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
deleted file mode 100644
index a9c65be..0000000
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/UploadService.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.apache.camel.component.cxf.jaxrs;
-
-import javax.jws.WebMethod;
-import javax.jws.WebService;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.apache.cxf.jaxrs.ext.multipart.Multipart;
-
-@WebService
-@Path("/cms")
-@Consumes("multipart/form-data")
-@Produces("application/xml")
-public  class UploadService {
-	@WebMethod
-	@POST
-	@Path("/upload2")
-	@Consumes("multipart/form-data")
-	public void addVideo(
-			@Multipart(value = "contenu", type = "application/octet-stream") java.lang.Number video,
-			@Multipart(value = "nom", type = "text/plain") String nom) {
-	}
-
-	@WebMethod
-	@POST
-	@Path("/upload")
-	@Consumes("multipart/form-data")
-	public void addVideo(
-			@Multipart(value = "contenu", type = "application/octet-stream") java.io.InputStream video,
-			@Multipart(value = "nom", type = "text/plain") String nom) {
-	}
-
-}
\ No newline at end of file