camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [5/5] git commit: CAMEL-6806: Fixed bean component when having 2+ custom annotated methods to not pick the single non annotated method if exists, but should be ambigious instead. Thanks to Larry Han for patch.
Date Thu, 03 Oct 2013 10:54:33 GMT
CAMEL-6806: Fixed bean component when having 2+ custom annotated methods to not pick the single
non annotated method if exists, but should be ambigious instead. Thanks to Larry Han for patch.


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

Branch: refs/heads/camel-2.11.x
Commit: 4b92dcb83e52e51eecb8c259fa8a966816ac6c07
Parents: fb51560
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Oct 3 12:53:36 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Oct 3 12:54:05 2013 +0200

----------------------------------------------------------------------
 .../apache/camel/component/bean/BeanInfo.java   |  2 +-
 .../component/bean/BeanHandlerMethodTest.java   | 33 ++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4b92dcb8/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 583d6ad..ac84909 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -514,7 +514,7 @@ public class BeanInfo {
         if (noParameters && localOperationsWithNoBody.size() == 1) {
             // if there was a method name configured and it has no parameters, then use the
method with no body (eg no parameters)
             return localOperationsWithNoBody.get(0);
-        } else if (!noParameters && localOperationsWithBody.size() == 1) {
+        } else if (!noParameters && localOperationsWithBody.size() == 1 &&
localOperationsWithCustomAnnotation.isEmpty()) {
             // if there is one method with body then use that one
             return localOperationsWithBody.get(0);
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/4b92dcb8/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
index 8313e83..c0300dc 100644
--- a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
@@ -20,6 +20,7 @@ import org.apache.camel.Body;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Handler;
+import org.apache.camel.Header;
 import org.apache.camel.impl.DefaultExchange;
 
 /**
@@ -83,6 +84,19 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
         }
     }
 
+    public void testNoHandlerAmbigious() throws Exception {
+        BeanInfo info = new BeanInfo(context, MyNoHandlerBean.class);
+
+        Exchange exchange = new DefaultExchange(context);
+        MyNoHandlerBean pojo = new MyNoHandlerBean();
+        try {
+            info.createInvocation(pojo, exchange);
+            fail("Should throw exception");
+        } catch (AmbiguousMethodCallException e) {
+            assertEquals(3, e.getMethods().size());
+        }
+    }
+
     public static class MyNoDummyBean {
 
         public String hello(@Body String hi) {
@@ -138,6 +152,25 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
 
     }
 
+    public static class MyNoHandlerBean {
+
+        public String hello(@Body String input, @Header("name") String name, @Header("age")
int age) {
+            fail("Should not invoke me");
+            return null;
+        }
+
+        public String greeting(@Body String input, @Header("name") String name) {
+            fail("Should not invoke me");
+            return null;
+        }
+
+        public String bye(String input) {
+            fail("Should not invoke me");
+            return null;
+        }
+
+    }
+
     public static class MyReallyDummyBean {
 
         @Handler


Mime
View raw message