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 2013/09/29 10:28:52 UTC
[1/4] git commit: CAMEL-6792: Added getMockEndpoint method to not
auto create. Thanks to James Carman for the patch.
Updated Branches:
refs/heads/camel-2.11.x f79a58a94 -> 2176e5885
refs/heads/camel-2.12.x aca1edfad -> ed2c71a4c
CAMEL-6792: Added getMockEndpoint method to not auto create. Thanks to James Carman for the patch.
Conflicts:
components/camel-test/src/test/java/org/apache/camel/test/CamelTestSupportTest.java
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2176e588
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2176e588
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2176e588
Branch: refs/heads/camel-2.11.x
Commit: 2176e5885d693e17ec66208e604eff1f9140b55d
Parents: 5dbe9ce
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Sep 29 10:25:27 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Sep 29 10:28:39 2013 +0200
----------------------------------------------------------------------
.../camel/test/junit4/CamelTestSupport.java | 24 +++++++++++++++++++-
.../apache/camel/testng/CamelTestSupport.java | 24 +++++++++++++++++++-
2 files changed, 46 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2176e588/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java b/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
index 9702810..b648dd6 100644
--- a/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
+++ b/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
@@ -30,6 +30,7 @@ import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Message;
+import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
@@ -535,7 +536,28 @@ public abstract class CamelTestSupport extends TestSupport {
* @return the mandatory mock endpoint or an exception is thrown if it could not be resolved
*/
protected MockEndpoint getMockEndpoint(String uri) {
- return resolveMandatoryEndpoint(uri, MockEndpoint.class);
+ return getMockEndpoint(uri, true);
+ }
+
+ /**
+ * Resolves the {@link MockEndpoint} using a URI of the form <code>mock:someName</code>, optionally
+ * creating it if it does not exist.
+ *
+ * @param uri the URI which typically starts with "mock:" and has some name
+ * @param create whether or not to allow the endpoint to be created if it doesn't exist
+ * @return the mock endpoint or an {@link NoSuchEndpointException} is thrown if it could not be resolved
+ * @throws NoSuchEndpointException is the mock endpoint does not exists
+ */
+ protected MockEndpoint getMockEndpoint(String uri, boolean create) throws NoSuchEndpointException {
+ if (create) {
+ return resolveMandatoryEndpoint(uri, MockEndpoint.class);
+ } else {
+ Endpoint endpoint = context.hasEndpoint(uri);
+ if (endpoint instanceof MockEndpoint) {
+ return (MockEndpoint) endpoint;
+ }
+ throw new NoSuchEndpointException(String.format("MockEndpoint %s does not exist.", uri));
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/camel/blob/2176e588/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java b/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
index a4b2e46..33d42e2 100644
--- a/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
+++ b/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
@@ -30,6 +30,7 @@ import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Message;
+import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
@@ -512,7 +513,28 @@ public abstract class CamelTestSupport extends TestSupport {
* @return the mandatory mock endpoint or an exception is thrown if it could not be resolved
*/
protected MockEndpoint getMockEndpoint(String uri) {
- return resolveMandatoryEndpoint(uri, MockEndpoint.class);
+ return getMockEndpoint(uri, true);
+ }
+
+ /**
+ * Resolves the {@link MockEndpoint} using a URI of the form <code>mock:someName</code>, optionally
+ * creating it if it does not exist.
+ *
+ * @param uri the URI which typically starts with "mock:" and has some name
+ * @param create whether or not to allow the endpoint to be created if it doesn't exist
+ * @return the mock endpoint or an {@link NoSuchEndpointException} is thrown if it could not be resolved
+ * @throws NoSuchEndpointException is the mock endpoint does not exists
+ */
+ protected MockEndpoint getMockEndpoint(String uri, boolean create) throws NoSuchEndpointException {
+ if (create) {
+ return resolveMandatoryEndpoint(uri, MockEndpoint.class);
+ } else {
+ Endpoint endpoint = context.hasEndpoint(uri);
+ if (endpoint instanceof MockEndpoint) {
+ return (MockEndpoint) endpoint;
+ }
+ throw new NoSuchEndpointException(String.format("MockEndpoint %s does not exist.", uri));
+ }
}
/**
[4/4] git commit: CAMEL-6792: Added getMockEndpoint method to not
auto create. Thanks to James Carman for the patch.
Posted by da...@apache.org.
CAMEL-6792: Added getMockEndpoint method to not auto create. Thanks to James Carman for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ed2c71a4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ed2c71a4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ed2c71a4
Branch: refs/heads/camel-2.12.x
Commit: ed2c71a4c6aeac09905ccbf4bf1eaf99ed436e45
Parents: 1f9e641
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Sep 29 10:25:27 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Sep 29 10:28:49 2013 +0200
----------------------------------------------------------------------
.../camel/test/junit4/CamelTestSupport.java | 24 +++++++++++++++++++-
.../apache/camel/test/CamelTestSupportTest.java | 18 +++++++++++++++
.../apache/camel/testng/CamelTestSupport.java | 24 +++++++++++++++++++-
3 files changed, 64 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ed2c71a4/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java b/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
index 24e6deb..22774d9 100644
--- a/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
+++ b/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
@@ -31,6 +31,7 @@ import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Message;
+import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
@@ -555,7 +556,28 @@ public abstract class CamelTestSupport extends TestSupport {
* @return the mandatory mock endpoint or an exception is thrown if it could not be resolved
*/
protected MockEndpoint getMockEndpoint(String uri) {
- return resolveMandatoryEndpoint(uri, MockEndpoint.class);
+ return getMockEndpoint(uri, true);
+ }
+
+ /**
+ * Resolves the {@link MockEndpoint} using a URI of the form <code>mock:someName</code>, optionally
+ * creating it if it does not exist.
+ *
+ * @param uri the URI which typically starts with "mock:" and has some name
+ * @param create whether or not to allow the endpoint to be created if it doesn't exist
+ * @return the mock endpoint or an {@link NoSuchEndpointException} is thrown if it could not be resolved
+ * @throws NoSuchEndpointException is the mock endpoint does not exists
+ */
+ protected MockEndpoint getMockEndpoint(String uri, boolean create) throws NoSuchEndpointException {
+ if (create) {
+ return resolveMandatoryEndpoint(uri, MockEndpoint.class);
+ } else {
+ Endpoint endpoint = context.hasEndpoint(uri);
+ if (endpoint instanceof MockEndpoint) {
+ return (MockEndpoint) endpoint;
+ }
+ throw new NoSuchEndpointException(String.format("MockEndpoint %s does not exist.", uri));
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/camel/blob/ed2c71a4/components/camel-test/src/test/java/org/apache/camel/test/CamelTestSupportTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test/src/test/java/org/apache/camel/test/CamelTestSupportTest.java b/components/camel-test/src/test/java/org/apache/camel/test/CamelTestSupportTest.java
index f046e90..cfa0cc5 100644
--- a/components/camel-test/src/test/java/org/apache/camel/test/CamelTestSupportTest.java
+++ b/components/camel-test/src/test/java/org/apache/camel/test/CamelTestSupportTest.java
@@ -17,7 +17,9 @@
package org.apache.camel.test;
+import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Before;
import org.junit.Test;
@@ -40,6 +42,22 @@ public class CamelTestSupportTest extends CamelTestSupport {
assertMockEndpointsSatisfied();
}
+ @Test(expected = NoSuchEndpointException.class)
+ public void exceptionThrownWhenEndpointNotFoundAndNoCreate() {
+ getMockEndpoint("mock:bogus", false);
+ }
+
+ @Test(expected = NoSuchEndpointException.class)
+ public void exceptionThrownWhenEndpointNotAMockEndpoint() {
+ getMockEndpoint("direct:something", false);
+ }
+
+ @Test
+ public void autoCreateNoneExisting() {
+ MockEndpoint mock = getMockEndpoint("mock:bogus2", true);
+ assertNotNull(mock);
+ }
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
http://git-wip-us.apache.org/repos/asf/camel/blob/ed2c71a4/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java b/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
index a4b2e46..33d42e2 100644
--- a/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
+++ b/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
@@ -30,6 +30,7 @@ import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Message;
+import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
@@ -512,7 +513,28 @@ public abstract class CamelTestSupport extends TestSupport {
* @return the mandatory mock endpoint or an exception is thrown if it could not be resolved
*/
protected MockEndpoint getMockEndpoint(String uri) {
- return resolveMandatoryEndpoint(uri, MockEndpoint.class);
+ return getMockEndpoint(uri, true);
+ }
+
+ /**
+ * Resolves the {@link MockEndpoint} using a URI of the form <code>mock:someName</code>, optionally
+ * creating it if it does not exist.
+ *
+ * @param uri the URI which typically starts with "mock:" and has some name
+ * @param create whether or not to allow the endpoint to be created if it doesn't exist
+ * @return the mock endpoint or an {@link NoSuchEndpointException} is thrown if it could not be resolved
+ * @throws NoSuchEndpointException is the mock endpoint does not exists
+ */
+ protected MockEndpoint getMockEndpoint(String uri, boolean create) throws NoSuchEndpointException {
+ if (create) {
+ return resolveMandatoryEndpoint(uri, MockEndpoint.class);
+ } else {
+ Endpoint endpoint = context.hasEndpoint(uri);
+ if (endpoint instanceof MockEndpoint) {
+ return (MockEndpoint) endpoint;
+ }
+ throw new NoSuchEndpointException(String.format("MockEndpoint %s does not exist.", uri));
+ }
}
/**
[3/4] git commit: CAMEL-6781: IntrospectionSupport.setProperty
ClassCastException if you have overloaded methods. Thanks to Franz Forsthofer
for the patch.
Posted by da...@apache.org.
CAMEL-6781: IntrospectionSupport.setProperty ClassCastException if you have overloaded methods. Thanks to Franz Forsthofer for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1f9e6415
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1f9e6415
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1f9e6415
Branch: refs/heads/camel-2.12.x
Commit: 1f9e6415b40d4bfc91871e2c76cdce2d34eff89b
Parents: aca1edf
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Sep 29 10:14:59 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Sep 29 10:28:49 2013 +0200
----------------------------------------------------------------------
.../java/org/apache/camel/util/IntrospectionSupport.java | 8 ++++++--
.../impl/DefaultComponentReferencePropertiesTest.java | 11 ++++++++---
2 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1f9e6415/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
index 3d6d6d0..e6864b7 100755
--- a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
@@ -496,9 +496,13 @@ public final class IntrospectionSupport {
Object ref = value;
// try and lookup the reference based on the method
if (context != null && refName != null && ref == null) {
- ref = CamelContextHelper.lookup(context, refName.replaceAll("#", ""), parameterType);
+ ref = CamelContextHelper.lookup(context, refName.replaceAll("#", ""));
if (ref == null) {
- continue; // try the next method if nothing was found
+ // try the next method if nothing was found
+ continue;
+ } else if (!parameterType.isAssignableFrom(ref.getClass())) {
+ // setter method has not the correct type
+ continue;
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/1f9e6415/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java
index bbec07c..1821991 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.impl;
+import java.util.List;
import java.util.Map;
import org.apache.camel.CamelContext;
@@ -58,6 +59,10 @@ public class DefaultComponentReferencePropertiesTest extends ContextTestSupport
return null;
}
+ public void setExpression(List<?> expressions) {
+ // do nothing
+ }
+
public void setExpression(Expression expression) {
this.expression = expression;
}
@@ -104,14 +109,14 @@ public class DefaultComponentReferencePropertiesTest extends ContextTestSupport
assertEquals("", remaining);
assertEquals(1, parameters.size());
assertEquals("Christian", parameters.get("name"));
-
+
return null;
}
-
+
};
component.createEndpoint("foo://?name=Christian");
}
-
+
public void testOnlyStringSetter() throws Exception {
MyComponent component = new MyComponent(context);
MyEndpoint endpoint = (MyEndpoint) component.createEndpoint("foo://?name=Claus");
[2/4] git commit: CAMEL-6781: IntrospectionSupport.setProperty
ClassCastException if you have overloaded methods. Thanks to Franz Forsthofer
for the patch.
Posted by da...@apache.org.
CAMEL-6781: IntrospectionSupport.setProperty ClassCastException if you have overloaded methods. Thanks to Franz Forsthofer for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5dbe9ce3
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5dbe9ce3
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5dbe9ce3
Branch: refs/heads/camel-2.11.x
Commit: 5dbe9ce3748de800364dc2d8f6fe738b14c2b888
Parents: f79a58a
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Sep 29 10:14:59 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Sep 29 10:28:39 2013 +0200
----------------------------------------------------------------------
.../java/org/apache/camel/util/IntrospectionSupport.java | 8 ++++++--
.../impl/DefaultComponentReferencePropertiesTest.java | 11 ++++++++---
2 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/5dbe9ce3/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
index 22bb389..a7ae39f 100755
--- a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
@@ -477,9 +477,13 @@ public final class IntrospectionSupport {
Object ref = value;
// try and lookup the reference based on the method
if (context != null && refName != null && ref == null) {
- ref = CamelContextHelper.lookup(context, refName.replaceAll("#", ""), parameterType);
+ ref = CamelContextHelper.lookup(context, refName.replaceAll("#", ""));
if (ref == null) {
- continue; // try the next method if nothing was found
+ // try the next method if nothing was found
+ continue;
+ } else if (!parameterType.isAssignableFrom(ref.getClass())) {
+ // setter method has not the correct type
+ continue;
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/5dbe9ce3/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java
index bbec07c..1821991 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.impl;
+import java.util.List;
import java.util.Map;
import org.apache.camel.CamelContext;
@@ -58,6 +59,10 @@ public class DefaultComponentReferencePropertiesTest extends ContextTestSupport
return null;
}
+ public void setExpression(List<?> expressions) {
+ // do nothing
+ }
+
public void setExpression(Expression expression) {
this.expression = expression;
}
@@ -104,14 +109,14 @@ public class DefaultComponentReferencePropertiesTest extends ContextTestSupport
assertEquals("", remaining);
assertEquals(1, parameters.size());
assertEquals("Christian", parameters.get("name"));
-
+
return null;
}
-
+
};
component.createEndpoint("foo://?name=Christian");
}
-
+
public void testOnlyStringSetter() throws Exception {
MyComponent component = new MyComponent(context);
MyEndpoint endpoint = (MyEndpoint) component.createEndpoint("foo://?name=Claus");