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 2014/11/01 15:56:53 UTC
[1/6] git commit: CAMEL-7986: Add duplicate check when adding routes
that are using auto assigned names,
which could clash with end user assigned names using same naming pattern.
Repository: camel
Updated Branches:
refs/heads/camel-2.13.x d2bf0f874 -> 76d7d6e59
refs/heads/camel-2.14.x 5d579ad83 -> eca9b3d5e
refs/heads/master f2b9f8b1f -> d581c4a47
CAMEL-7986: Add duplicate check when adding routes that are using auto assigned names, which could clash with end user assigned names using same naming pattern.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a196ce0f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a196ce0f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a196ce0f
Branch: refs/heads/master
Commit: a196ce0f5b9d045a838533d06a1162eb35b4d178
Parents: f2b9f8b
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Nov 1 15:23:53 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Nov 1 15:23:53 2014 +0100
----------------------------------------------------------------------
.../apache/camel/impl/DefaultCamelContext.java | 9 ++-
.../camel/model/RouteDefinitionHelper.java | 24 +++++++-
.../issues/RouteIdAutoAssignClashIssue.java | 63 ++++++++++++++++++++
.../SpringRouteIdAutoAssignClashIssue.java | 33 ++++++++++
.../issues/RouteIdAutoAssignClashIssue.xml | 40 +++++++++++++
5 files changed, 163 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a196ce0f/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index ee204ad..ffe4b59 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -761,9 +761,12 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
}
public synchronized void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception {
- String id = routeDefinition.idOrCreate(nodeIdFactory);
- stopRoute(id);
- removeRoute(id);
+ String id = routeDefinition.getId();
+ if (id != null) {
+ // remove existing route
+ stopRoute(id);
+ removeRoute(id);
+ }
this.routeDefinitions.remove(routeDefinition);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/a196ce0f/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
index 5c67d57..da218e1 100644
--- a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
@@ -19,6 +19,7 @@ package org.apache.camel.model;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -118,10 +119,10 @@ public final class RouteDefinitionHelper {
* @throws Exception is thrown if error force assign ids to the routes
*/
public static void forceAssignIds(CamelContext context, List<RouteDefinition> routes) throws Exception {
- for (RouteDefinition route : routes) {
- // force id on the route
- route.idOrCreate(context.getNodeIdFactory());
+ // handle custom assigned id's first, and then afterwards assign auto generated ids
+ Set<String> customIds = new HashSet<>();
+ for (RouteDefinition route : routes) {
// if there was a custom id assigned, then make sure to support property placeholders
if (route.hasCustomIdAssigned()) {
String id = route.getId();
@@ -130,6 +131,23 @@ public final class RouteDefinitionHelper {
if (!route.getId().equals(id)) {
route.setId(id);
}
+ customIds.add(id);
+ }
+ }
+
+ // auto assign route ids
+ for (RouteDefinition route : routes) {
+ if (route.getId() == null) {
+ // keep assigning id's until we find a free name
+ boolean done = false;
+ String id = null;
+ while (!done) {
+ id = context.getNodeIdFactory().createId(route);
+ done = !customIds.contains(id);
+ }
+ route.setId(id);
+ route.setCustomId(false);
+ customIds.add(route.getId());
}
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/a196ce0f/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java b/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java
new file mode 100644
index 0000000..6cfdeb7
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java
@@ -0,0 +1,63 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RouteIdAutoAssignClashIssue extends ContextTestSupport {
+
+ public void testRouteIdAutoAssignClash() throws Exception {
+ getMockEndpoint("mock:start1").expectedBodiesReceived("Hello World");
+ getMockEndpoint("mock:start2").expectedBodiesReceived("Bye World");
+ getMockEndpoint("mock:start").expectedBodiesReceived("Hi Camel");
+
+ template.sendBody("direct:start1", "Hello World");
+ template.sendBody("direct:start2", "Bye World");
+ template.sendBody("direct:start", "Hi Camel");
+
+ assertMockEndpointsSatisfied();
+
+ assertEquals(3, context.getRouteDefinitions().size());
+ assertEquals(3, context.getRoutes().size());
+
+ assertNotNull(context.getRoute("route1"));
+ assertNotNull(context.getRoute("route2"));
+ // we will auto assign the route as route3
+ assertNotNull(context.getRoute("route3"));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // use route1, route2 to clash with Camel's auto assigning
+ from("direct:start1").routeId("route1")
+ .to("mock:start1");
+
+ // use route1, route2 to clash with Camel's auto assigning
+ from("direct:start2").routeId("route2")
+ .to("mock:start2");
+
+ // no assigned route id which should be auto assigned
+ from("direct:start")
+ .to("mock:start");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a196ce0f/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java
new file mode 100644
index 0000000..5092f23
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java
@@ -0,0 +1,33 @@
+/**
+ * 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.spring.issues;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.issues.RouteIdAutoAssignClashIssue;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ *
+ */
+public class SpringRouteIdAutoAssignClashIssue extends RouteIdAutoAssignClashIssue {
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this, "org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a196ce0f/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml
new file mode 100644
index 0000000..313bb59
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml
@@ -0,0 +1,40 @@
+<?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"
+ xsi:schemaLocation="
+ 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
+ ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <route id="route1">
+ <from uri="direct:start1"/>
+ <to uri="mock:start1"/>
+ </route>
+ <route id="route2">
+ <from uri="direct:start2"/>
+ <to uri="mock:start2"/>
+ </route>
+ <route>
+ <from uri="direct:start"/>
+ <to uri="mock:start"/>
+ </route>
+ </camelContext>
+
+</beans>
[2/6] git commit: CAMEL-7990: IdempotentConsumer - If no messageId
should allow Camel error handler to react
Posted by da...@apache.org.
CAMEL-7990: IdempotentConsumer - If no messageId should allow Camel error handler to react
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d581c4a4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d581c4a4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d581c4a4
Branch: refs/heads/master
Commit: d581c4a4725fdcec34b49455591371355ef36e55
Parents: a196ce0
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Nov 1 15:42:54 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Nov 1 15:46:55 2014 +0100
----------------------------------------------------------------------
.../idempotent/IdempotentConsumer.java | 4 +-
.../IdempotentConsumerNoMessageIdTest.java | 62 +++++++++++++++-----
2 files changed, 51 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d581c4a4/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java b/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
index 100a660..d3afe7a 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
@@ -80,7 +80,9 @@ public class IdempotentConsumer extends ServiceSupport implements AsyncProcessor
public boolean process(Exchange exchange, AsyncCallback callback) {
final String messageId = messageIdExpression.evaluate(exchange, String.class);
if (messageId == null) {
- throw new NoMessageIdException(exchange, messageIdExpression);
+ exchange.setException(new NoMessageIdException(exchange, messageIdExpression));
+ callback.done(true);
+ return true;
}
boolean newKey;
http://git-wip-us.apache.org/repos/asf/camel/blob/d581c4a4/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java b/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
index fbac601..06d738b 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
@@ -16,35 +16,69 @@
*/
package org.apache.camel.processor;
-import org.apache.camel.CamelExecutionException;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.processor.idempotent.MemoryIdempotentRepository;
-import org.apache.camel.processor.idempotent.NoMessageIdException;
/**
* @version
*/
public class IdempotentConsumerNoMessageIdTest extends ContextTestSupport {
+ protected Endpoint startEndpoint;
+ protected MockEndpoint resultEndpoint;
- public void testNoMessageId() throws Exception {
- try {
- template.sendBody("direct:start", "Hello World");
- fail("Should have thrown an exception");
- } catch (CamelExecutionException e) {
- assertIsInstanceOf(NoMessageIdException.class, e.getCause());
- }
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
}
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
+ public void testNoMessageId() throws Exception {
+ context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
+ errorHandler(deadLetterChannel("mock:dead"));
+
from("direct:start").idempotentConsumer(
header("messageId"), MemoryIdempotentRepository.memoryIdempotentRepository(200)
).to("mock:result");
}
- };
+ });
+ context.start();
+
+ resultEndpoint.expectedBodiesReceived("one", "two");
+
+ getMockEndpoint("mock:dead").expectedBodiesReceived("Hello World");
+
+ sendMessage("1", "one");
+ template.sendBody("direct:start", "Hello World");
+ sendMessage("2", "two");
+ sendMessage("1", "one");
+
+ assertMockEndpointsSatisfied();
}
-}
\ No newline at end of file
+
+ protected void sendMessage(final Object messageId, final Object body) {
+ template.send(startEndpoint, new Processor() {
+ public void process(Exchange exchange) {
+ // now lets fire in a message
+ Message in = exchange.getIn();
+ in.setBody(body);
+ in.setHeader("messageId", messageId);
+ }
+ });
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ startEndpoint = resolveMandatoryEndpoint("direct:start");
+ resultEndpoint = getMockEndpoint("mock:result");
+ }
+
+}
[4/6] git commit: CAMEL-7990: IdempotentConsumer - If no messageId
should allow Camel error handler to react
Posted by da...@apache.org.
CAMEL-7990: IdempotentConsumer - If no messageId should allow Camel error handler to react
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/eca9b3d5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/eca9b3d5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/eca9b3d5
Branch: refs/heads/camel-2.14.x
Commit: eca9b3d5ead0cacf6d84257975bcb2d2bbb47ecd
Parents: 8e4c684
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Nov 1 15:42:54 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Nov 1 15:56:23 2014 +0100
----------------------------------------------------------------------
.../idempotent/IdempotentConsumer.java | 4 +-
.../IdempotentConsumerNoMessageIdTest.java | 62 +++++++++++++++-----
2 files changed, 51 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/eca9b3d5/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java b/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
index 100a660..d3afe7a 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
@@ -80,7 +80,9 @@ public class IdempotentConsumer extends ServiceSupport implements AsyncProcessor
public boolean process(Exchange exchange, AsyncCallback callback) {
final String messageId = messageIdExpression.evaluate(exchange, String.class);
if (messageId == null) {
- throw new NoMessageIdException(exchange, messageIdExpression);
+ exchange.setException(new NoMessageIdException(exchange, messageIdExpression));
+ callback.done(true);
+ return true;
}
boolean newKey;
http://git-wip-us.apache.org/repos/asf/camel/blob/eca9b3d5/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java b/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
index fbac601..06d738b 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
@@ -16,35 +16,69 @@
*/
package org.apache.camel.processor;
-import org.apache.camel.CamelExecutionException;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.processor.idempotent.MemoryIdempotentRepository;
-import org.apache.camel.processor.idempotent.NoMessageIdException;
/**
* @version
*/
public class IdempotentConsumerNoMessageIdTest extends ContextTestSupport {
+ protected Endpoint startEndpoint;
+ protected MockEndpoint resultEndpoint;
- public void testNoMessageId() throws Exception {
- try {
- template.sendBody("direct:start", "Hello World");
- fail("Should have thrown an exception");
- } catch (CamelExecutionException e) {
- assertIsInstanceOf(NoMessageIdException.class, e.getCause());
- }
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
}
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
+ public void testNoMessageId() throws Exception {
+ context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
+ errorHandler(deadLetterChannel("mock:dead"));
+
from("direct:start").idempotentConsumer(
header("messageId"), MemoryIdempotentRepository.memoryIdempotentRepository(200)
).to("mock:result");
}
- };
+ });
+ context.start();
+
+ resultEndpoint.expectedBodiesReceived("one", "two");
+
+ getMockEndpoint("mock:dead").expectedBodiesReceived("Hello World");
+
+ sendMessage("1", "one");
+ template.sendBody("direct:start", "Hello World");
+ sendMessage("2", "two");
+ sendMessage("1", "one");
+
+ assertMockEndpointsSatisfied();
}
-}
\ No newline at end of file
+
+ protected void sendMessage(final Object messageId, final Object body) {
+ template.send(startEndpoint, new Processor() {
+ public void process(Exchange exchange) {
+ // now lets fire in a message
+ Message in = exchange.getIn();
+ in.setBody(body);
+ in.setHeader("messageId", messageId);
+ }
+ });
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ startEndpoint = resolveMandatoryEndpoint("direct:start");
+ resultEndpoint = getMockEndpoint("mock:result");
+ }
+
+}
[6/6] git commit: CAMEL-7990: IdempotentConsumer - If no messageId
should allow Camel error handler to react
Posted by da...@apache.org.
CAMEL-7990: IdempotentConsumer - If no messageId should allow Camel error handler to react
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/76d7d6e5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/76d7d6e5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/76d7d6e5
Branch: refs/heads/camel-2.13.x
Commit: 76d7d6e599c636b424d470aed61d54c7a4595f19
Parents: 2aab7c3
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Nov 1 15:42:54 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Nov 1 15:56:38 2014 +0100
----------------------------------------------------------------------
.../idempotent/IdempotentConsumer.java | 4 +-
.../IdempotentConsumerNoMessageIdTest.java | 62 +++++++++++++++-----
2 files changed, 51 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/76d7d6e5/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java b/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
index d2cbc42..dcc466d 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/idempotent/IdempotentConsumer.java
@@ -70,7 +70,9 @@ public class IdempotentConsumer extends ServiceSupport implements AsyncProcessor
public boolean process(Exchange exchange, AsyncCallback callback) {
final String messageId = messageIdExpression.evaluate(exchange, String.class);
if (messageId == null) {
- throw new NoMessageIdException(exchange, messageIdExpression);
+ exchange.setException(new NoMessageIdException(exchange, messageIdExpression));
+ callback.done(true);
+ return true;
}
boolean newKey;
http://git-wip-us.apache.org/repos/asf/camel/blob/76d7d6e5/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java b/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
index fbac601..06d738b 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerNoMessageIdTest.java
@@ -16,35 +16,69 @@
*/
package org.apache.camel.processor;
-import org.apache.camel.CamelExecutionException;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.processor.idempotent.MemoryIdempotentRepository;
-import org.apache.camel.processor.idempotent.NoMessageIdException;
/**
* @version
*/
public class IdempotentConsumerNoMessageIdTest extends ContextTestSupport {
+ protected Endpoint startEndpoint;
+ protected MockEndpoint resultEndpoint;
- public void testNoMessageId() throws Exception {
- try {
- template.sendBody("direct:start", "Hello World");
- fail("Should have thrown an exception");
- } catch (CamelExecutionException e) {
- assertIsInstanceOf(NoMessageIdException.class, e.getCause());
- }
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
}
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
+ public void testNoMessageId() throws Exception {
+ context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
+ errorHandler(deadLetterChannel("mock:dead"));
+
from("direct:start").idempotentConsumer(
header("messageId"), MemoryIdempotentRepository.memoryIdempotentRepository(200)
).to("mock:result");
}
- };
+ });
+ context.start();
+
+ resultEndpoint.expectedBodiesReceived("one", "two");
+
+ getMockEndpoint("mock:dead").expectedBodiesReceived("Hello World");
+
+ sendMessage("1", "one");
+ template.sendBody("direct:start", "Hello World");
+ sendMessage("2", "two");
+ sendMessage("1", "one");
+
+ assertMockEndpointsSatisfied();
}
-}
\ No newline at end of file
+
+ protected void sendMessage(final Object messageId, final Object body) {
+ template.send(startEndpoint, new Processor() {
+ public void process(Exchange exchange) {
+ // now lets fire in a message
+ Message in = exchange.getIn();
+ in.setBody(body);
+ in.setHeader("messageId", messageId);
+ }
+ });
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ startEndpoint = resolveMandatoryEndpoint("direct:start");
+ resultEndpoint = getMockEndpoint("mock:result");
+ }
+
+}
[5/6] git commit: CAMEL-7986: Add duplicate check when adding routes
that are using auto assigned names,
which could clash with end user assigned names using same naming pattern.
Posted by da...@apache.org.
CAMEL-7986: Add duplicate check when adding routes that are using auto assigned names, which could clash with end user assigned names using same naming pattern.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2aab7c39
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2aab7c39
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2aab7c39
Branch: refs/heads/camel-2.13.x
Commit: 2aab7c39131297f42003ca2e2c19055a515489d0
Parents: d2bf0f8
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Nov 1 15:23:53 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Nov 1 15:56:32 2014 +0100
----------------------------------------------------------------------
.../apache/camel/impl/DefaultCamelContext.java | 9 ++-
.../camel/model/RouteDefinitionHelper.java | 24 +++++++-
.../issues/RouteIdAutoAssignClashIssue.java | 63 ++++++++++++++++++++
.../SpringRouteIdAutoAssignClashIssue.java | 33 ++++++++++
.../issues/RouteIdAutoAssignClashIssue.xml | 40 +++++++++++++
5 files changed, 163 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2aab7c39/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index 9ade095..865c1ef 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -749,9 +749,12 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
}
public synchronized void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception {
- String id = routeDefinition.idOrCreate(nodeIdFactory);
- stopRoute(id);
- removeRoute(id);
+ String id = routeDefinition.getId();
+ if (id != null) {
+ // remove existing route
+ stopRoute(id);
+ removeRoute(id);
+ }
this.routeDefinitions.remove(routeDefinition);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/2aab7c39/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
index 5c67d57..da218e1 100644
--- a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
@@ -19,6 +19,7 @@ package org.apache.camel.model;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -118,10 +119,10 @@ public final class RouteDefinitionHelper {
* @throws Exception is thrown if error force assign ids to the routes
*/
public static void forceAssignIds(CamelContext context, List<RouteDefinition> routes) throws Exception {
- for (RouteDefinition route : routes) {
- // force id on the route
- route.idOrCreate(context.getNodeIdFactory());
+ // handle custom assigned id's first, and then afterwards assign auto generated ids
+ Set<String> customIds = new HashSet<>();
+ for (RouteDefinition route : routes) {
// if there was a custom id assigned, then make sure to support property placeholders
if (route.hasCustomIdAssigned()) {
String id = route.getId();
@@ -130,6 +131,23 @@ public final class RouteDefinitionHelper {
if (!route.getId().equals(id)) {
route.setId(id);
}
+ customIds.add(id);
+ }
+ }
+
+ // auto assign route ids
+ for (RouteDefinition route : routes) {
+ if (route.getId() == null) {
+ // keep assigning id's until we find a free name
+ boolean done = false;
+ String id = null;
+ while (!done) {
+ id = context.getNodeIdFactory().createId(route);
+ done = !customIds.contains(id);
+ }
+ route.setId(id);
+ route.setCustomId(false);
+ customIds.add(route.getId());
}
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/2aab7c39/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java b/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java
new file mode 100644
index 0000000..6cfdeb7
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java
@@ -0,0 +1,63 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RouteIdAutoAssignClashIssue extends ContextTestSupport {
+
+ public void testRouteIdAutoAssignClash() throws Exception {
+ getMockEndpoint("mock:start1").expectedBodiesReceived("Hello World");
+ getMockEndpoint("mock:start2").expectedBodiesReceived("Bye World");
+ getMockEndpoint("mock:start").expectedBodiesReceived("Hi Camel");
+
+ template.sendBody("direct:start1", "Hello World");
+ template.sendBody("direct:start2", "Bye World");
+ template.sendBody("direct:start", "Hi Camel");
+
+ assertMockEndpointsSatisfied();
+
+ assertEquals(3, context.getRouteDefinitions().size());
+ assertEquals(3, context.getRoutes().size());
+
+ assertNotNull(context.getRoute("route1"));
+ assertNotNull(context.getRoute("route2"));
+ // we will auto assign the route as route3
+ assertNotNull(context.getRoute("route3"));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // use route1, route2 to clash with Camel's auto assigning
+ from("direct:start1").routeId("route1")
+ .to("mock:start1");
+
+ // use route1, route2 to clash with Camel's auto assigning
+ from("direct:start2").routeId("route2")
+ .to("mock:start2");
+
+ // no assigned route id which should be auto assigned
+ from("direct:start")
+ .to("mock:start");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2aab7c39/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java
new file mode 100644
index 0000000..5092f23
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java
@@ -0,0 +1,33 @@
+/**
+ * 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.spring.issues;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.issues.RouteIdAutoAssignClashIssue;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ *
+ */
+public class SpringRouteIdAutoAssignClashIssue extends RouteIdAutoAssignClashIssue {
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this, "org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2aab7c39/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml
new file mode 100644
index 0000000..313bb59
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml
@@ -0,0 +1,40 @@
+<?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"
+ xsi:schemaLocation="
+ 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
+ ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <route id="route1">
+ <from uri="direct:start1"/>
+ <to uri="mock:start1"/>
+ </route>
+ <route id="route2">
+ <from uri="direct:start2"/>
+ <to uri="mock:start2"/>
+ </route>
+ <route>
+ <from uri="direct:start"/>
+ <to uri="mock:start"/>
+ </route>
+ </camelContext>
+
+</beans>
[3/6] git commit: CAMEL-7986: Add duplicate check when adding routes
that are using auto assigned names,
which could clash with end user assigned names using same naming pattern.
Posted by da...@apache.org.
CAMEL-7986: Add duplicate check when adding routes that are using auto assigned names, which could clash with end user assigned names using same naming pattern.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8e4c6845
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8e4c6845
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8e4c6845
Branch: refs/heads/camel-2.14.x
Commit: 8e4c684559cabff456a3db636d4be4648014dbbc
Parents: 5d579ad
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Nov 1 15:23:53 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Nov 1 15:56:18 2014 +0100
----------------------------------------------------------------------
.../apache/camel/impl/DefaultCamelContext.java | 9 ++-
.../camel/model/RouteDefinitionHelper.java | 24 +++++++-
.../issues/RouteIdAutoAssignClashIssue.java | 63 ++++++++++++++++++++
.../SpringRouteIdAutoAssignClashIssue.java | 33 ++++++++++
.../issues/RouteIdAutoAssignClashIssue.xml | 40 +++++++++++++
5 files changed, 163 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8e4c6845/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index ee204ad..ffe4b59 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -761,9 +761,12 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
}
public synchronized void removeRouteDefinition(RouteDefinition routeDefinition) throws Exception {
- String id = routeDefinition.idOrCreate(nodeIdFactory);
- stopRoute(id);
- removeRoute(id);
+ String id = routeDefinition.getId();
+ if (id != null) {
+ // remove existing route
+ stopRoute(id);
+ removeRoute(id);
+ }
this.routeDefinitions.remove(routeDefinition);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/8e4c6845/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
index 5c67d57..da218e1 100644
--- a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
@@ -19,6 +19,7 @@ package org.apache.camel.model;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -118,10 +119,10 @@ public final class RouteDefinitionHelper {
* @throws Exception is thrown if error force assign ids to the routes
*/
public static void forceAssignIds(CamelContext context, List<RouteDefinition> routes) throws Exception {
- for (RouteDefinition route : routes) {
- // force id on the route
- route.idOrCreate(context.getNodeIdFactory());
+ // handle custom assigned id's first, and then afterwards assign auto generated ids
+ Set<String> customIds = new HashSet<>();
+ for (RouteDefinition route : routes) {
// if there was a custom id assigned, then make sure to support property placeholders
if (route.hasCustomIdAssigned()) {
String id = route.getId();
@@ -130,6 +131,23 @@ public final class RouteDefinitionHelper {
if (!route.getId().equals(id)) {
route.setId(id);
}
+ customIds.add(id);
+ }
+ }
+
+ // auto assign route ids
+ for (RouteDefinition route : routes) {
+ if (route.getId() == null) {
+ // keep assigning id's until we find a free name
+ boolean done = false;
+ String id = null;
+ while (!done) {
+ id = context.getNodeIdFactory().createId(route);
+ done = !customIds.contains(id);
+ }
+ route.setId(id);
+ route.setCustomId(false);
+ customIds.add(route.getId());
}
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/8e4c6845/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java b/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java
new file mode 100644
index 0000000..6cfdeb7
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/issues/RouteIdAutoAssignClashIssue.java
@@ -0,0 +1,63 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RouteIdAutoAssignClashIssue extends ContextTestSupport {
+
+ public void testRouteIdAutoAssignClash() throws Exception {
+ getMockEndpoint("mock:start1").expectedBodiesReceived("Hello World");
+ getMockEndpoint("mock:start2").expectedBodiesReceived("Bye World");
+ getMockEndpoint("mock:start").expectedBodiesReceived("Hi Camel");
+
+ template.sendBody("direct:start1", "Hello World");
+ template.sendBody("direct:start2", "Bye World");
+ template.sendBody("direct:start", "Hi Camel");
+
+ assertMockEndpointsSatisfied();
+
+ assertEquals(3, context.getRouteDefinitions().size());
+ assertEquals(3, context.getRoutes().size());
+
+ assertNotNull(context.getRoute("route1"));
+ assertNotNull(context.getRoute("route2"));
+ // we will auto assign the route as route3
+ assertNotNull(context.getRoute("route3"));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // use route1, route2 to clash with Camel's auto assigning
+ from("direct:start1").routeId("route1")
+ .to("mock:start1");
+
+ // use route1, route2 to clash with Camel's auto assigning
+ from("direct:start2").routeId("route2")
+ .to("mock:start2");
+
+ // no assigned route id which should be auto assigned
+ from("direct:start")
+ .to("mock:start");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8e4c6845/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java
new file mode 100644
index 0000000..5092f23
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringRouteIdAutoAssignClashIssue.java
@@ -0,0 +1,33 @@
+/**
+ * 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.spring.issues;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.issues.RouteIdAutoAssignClashIssue;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ *
+ */
+public class SpringRouteIdAutoAssignClashIssue extends RouteIdAutoAssignClashIssue {
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this, "org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8e4c6845/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml
new file mode 100644
index 0000000..313bb59
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RouteIdAutoAssignClashIssue.xml
@@ -0,0 +1,40 @@
+<?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"
+ xsi:schemaLocation="
+ 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
+ ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <route id="route1">
+ <from uri="direct:start1"/>
+ <to uri="mock:start1"/>
+ </route>
+ <route id="route2">
+ <from uri="direct:start2"/>
+ <to uri="mock:start2"/>
+ </route>
+ <route>
+ <from uri="direct:start"/>
+ <to uri="mock:start"/>
+ </route>
+ </camelContext>
+
+</beans>