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 2015/05/29 09:43:37 UTC
[1/3] camel git commit: CAMEL-8798: weaveAddLast throwing
UnsupportedOperation when route have a ChoiceDefinition
Repository: camel
Updated Branches:
refs/heads/camel-2.14.x 8fb0d78f6 -> f0443ae89
refs/heads/camel-2.15.x b604e1675 -> 97e039bb5
refs/heads/master 919673cbf -> b30d3c29f
CAMEL-8798: weaveAddLast throwing UnsupportedOperation when route have a ChoiceDefinition
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b30d3c29
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b30d3c29
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b30d3c29
Branch: refs/heads/master
Commit: b30d3c29f93b9f4a959d7717a134db3ab4d268d6
Parents: 919673c
Author: Claus Ibsen <da...@apache.org>
Authored: Fri May 29 09:42:14 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri May 29 09:42:14 2015 +0200
----------------------------------------------------------------------
.../camel/model/ProcessorDefinitionHelper.java | 42 ++++++++------
.../interceptor/AdviceWithWeaveLastCBRTest.java | 58 ++++++++++++++++++++
2 files changed, 82 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b30d3c29/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
index e11c384..63d0131 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
@@ -262,18 +262,21 @@ public final class ProcessorDefinitionHelper {
found.add((T) choice);
}
- for (WhenDefinition when : choice.getWhenClauses()) {
- if (type.isInstance(when)) {
- found.add((T) when);
+ // only look at when/otherwise if current < maxDeep (or max deep is disabled)
+ if (maxDeep < 0 || current < maxDeep) {
+ for (WhenDefinition when : choice.getWhenClauses()) {
+ if (type.isInstance(when)) {
+ found.add((T) when);
+ }
+ List<ProcessorDefinition<?>> children = when.getOutputs();
+ doFindType(children, type, found, ++current, maxDeep);
}
- List<ProcessorDefinition<?>> children = when.getOutputs();
- doFindType(children, type, found, ++current, maxDeep);
- }
- // otherwise is optional
- if (choice.getOtherwise() != null) {
- List<ProcessorDefinition<?>> children = choice.getOtherwise().getOutputs();
- doFindType(children, type, found, ++current, maxDeep);
+ // otherwise is optional
+ if (choice.getOtherwise() != null) {
+ List<ProcessorDefinition<?>> children = choice.getOtherwise().getOutputs();
+ doFindType(children, type, found, ++current, maxDeep);
+ }
}
// do not check children as we already did that
@@ -289,16 +292,19 @@ public final class ProcessorDefinitionHelper {
found.add((T) doTry);
}
- List<ProcessorDefinition<?>> doTryOut = doTry.getOutputsWithoutCatches();
- doFindType(doTryOut, type, found, ++current, maxDeep);
+ // only look at children if current < maxDeep (or max deep is disabled)
+ if (maxDeep < 0 || current < maxDeep) {
+ List<ProcessorDefinition<?>> doTryOut = doTry.getOutputsWithoutCatches();
+ doFindType(doTryOut, type, found, ++current, maxDeep);
- List<CatchDefinition> doTryCatch = doTry.getCatchClauses();
- for (CatchDefinition doCatch : doTryCatch) {
- doFindType(doCatch.getOutputs(), type, found, ++current, maxDeep);
- }
+ List<CatchDefinition> doTryCatch = doTry.getCatchClauses();
+ for (CatchDefinition doCatch : doTryCatch) {
+ doFindType(doCatch.getOutputs(), type, found, ++current, maxDeep);
+ }
- if (doTry.getFinallyClause() != null) {
- doFindType(doTry.getFinallyClause().getOutputs(), type, found, ++current, maxDeep);
+ if (doTry.getFinallyClause() != null) {
+ doFindType(doTry.getFinallyClause().getOutputs(), type, found, ++current, maxDeep);
+ }
}
// do not check children as we already did that
http://git-wip-us.apache.org/repos/asf/camel/blob/b30d3c29/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java b/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java
new file mode 100644
index 0000000..b47b256
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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.processor.interceptor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * Advice with tests
+ */
+public class AdviceWithWeaveLastCBRTest extends ContextTestSupport {
+
+ public void testWeaveAddLast() throws Exception {
+ context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // insert at the end of the existing route, the given piece of route
+ weaveAddLast().to("mock:last");
+ }
+ });
+
+ getMockEndpoint("mock:foo").expectedMessageCount(1);
+ getMockEndpoint("mock:bar").expectedMessageCount(0);
+ getMockEndpoint("mock:last").expectedMessageCount(1);
+
+ template.sendBodyAndHeader("direct:start", "Hello World", "foo", "yeah");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .choice()
+ .when().header("foo").to("mock:foo")
+ .otherwise().to("mock:bar");
+ }
+ };
+ }
+}
\ No newline at end of file
[2/3] camel git commit: CAMEL-8798: weaveAddLast throwing
UnsupportedOperation when route have a ChoiceDefinition
Posted by da...@apache.org.
CAMEL-8798: weaveAddLast throwing UnsupportedOperation when route have a ChoiceDefinition
Conflicts:
camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/97e039bb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/97e039bb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/97e039bb
Branch: refs/heads/camel-2.15.x
Commit: 97e039bb530602e471f045f60ea823571813b93d
Parents: b604e16
Author: Claus Ibsen <da...@apache.org>
Authored: Fri May 29 09:42:14 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri May 29 09:44:26 2015 +0200
----------------------------------------------------------------------
.../camel/model/ProcessorDefinitionHelper.java | 42 ++++++++------
.../interceptor/AdviceWithWeaveLastCBRTest.java | 58 ++++++++++++++++++++
2 files changed, 82 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/97e039bb/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
index 47cae82..27ff1ba 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
@@ -260,18 +260,21 @@ public final class ProcessorDefinitionHelper {
found.add((T)choice);
}
- for (WhenDefinition when : choice.getWhenClauses()) {
- if (type.isInstance(when)) {
- found.add((T)when);
+ // only look at children if current < maxDeep (or max deep is disabled)
+ if (maxDeep < 0 || current < maxDeep) {
+ for (WhenDefinition when : choice.getWhenClauses()) {
+ if (type.isInstance(when)) {
+ found.add((T) when);
+ }
+ List<ProcessorDefinition<?>> children = when.getOutputs();
+ doFindType(children, type, found, ++current, maxDeep);
}
- List<ProcessorDefinition<?>> children = when.getOutputs();
- doFindType(children, type, found, ++current, maxDeep);
- }
- // otherwise is optional
- if (choice.getOtherwise() != null) {
- List<ProcessorDefinition<?>> children = choice.getOtherwise().getOutputs();
- doFindType(children, type, found, ++current, maxDeep);
+ // otherwise is optional
+ if (choice.getOtherwise() != null) {
+ List<ProcessorDefinition<?>> children = choice.getOtherwise().getOutputs();
+ doFindType(children, type, found, ++current, maxDeep);
+ }
}
// do not check children as we already did that
@@ -287,16 +290,19 @@ public final class ProcessorDefinitionHelper {
found.add((T)doTry);
}
- List<ProcessorDefinition<?>> doTryOut = doTry.getOutputsWithoutCatches();
- doFindType(doTryOut, type, found, ++current, maxDeep);
+ // only look at children if current < maxDeep (or max deep is disabled)
+ if (maxDeep < 0 || current < maxDeep) {
+ List<ProcessorDefinition<?>> doTryOut = doTry.getOutputsWithoutCatches();
+ doFindType(doTryOut, type, found, ++current, maxDeep);
- List<CatchDefinition> doTryCatch = doTry.getCatchClauses();
- for (CatchDefinition doCatch : doTryCatch) {
- doFindType(doCatch.getOutputs(), type, found, ++current, maxDeep);
- }
+ List<CatchDefinition> doTryCatch = doTry.getCatchClauses();
+ for (CatchDefinition doCatch : doTryCatch) {
+ doFindType(doCatch.getOutputs(), type, found, ++current, maxDeep);
+ }
- if (doTry.getFinallyClause() != null) {
- doFindType(doTry.getFinallyClause().getOutputs(), type, found, ++current, maxDeep);
+ if (doTry.getFinallyClause() != null) {
+ doFindType(doTry.getFinallyClause().getOutputs(), type, found, ++current, maxDeep);
+ }
}
// do not check children as we already did that
http://git-wip-us.apache.org/repos/asf/camel/blob/97e039bb/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java b/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java
new file mode 100644
index 0000000..b47b256
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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.processor.interceptor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * Advice with tests
+ */
+public class AdviceWithWeaveLastCBRTest extends ContextTestSupport {
+
+ public void testWeaveAddLast() throws Exception {
+ context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // insert at the end of the existing route, the given piece of route
+ weaveAddLast().to("mock:last");
+ }
+ });
+
+ getMockEndpoint("mock:foo").expectedMessageCount(1);
+ getMockEndpoint("mock:bar").expectedMessageCount(0);
+ getMockEndpoint("mock:last").expectedMessageCount(1);
+
+ template.sendBodyAndHeader("direct:start", "Hello World", "foo", "yeah");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .choice()
+ .when().header("foo").to("mock:foo")
+ .otherwise().to("mock:bar");
+ }
+ };
+ }
+}
\ No newline at end of file
[3/3] camel git commit: CAMEL-8798: weaveAddLast throwing
UnsupportedOperation when route have a ChoiceDefinition
Posted by da...@apache.org.
CAMEL-8798: weaveAddLast throwing UnsupportedOperation when route have a ChoiceDefinition
Conflicts:
camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f0443ae8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f0443ae8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f0443ae8
Branch: refs/heads/camel-2.14.x
Commit: f0443ae89a13ba42d1af917238ab42e87a629c9b
Parents: 8fb0d78
Author: Claus Ibsen <da...@apache.org>
Authored: Fri May 29 09:42:14 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri May 29 09:48:20 2015 +0200
----------------------------------------------------------------------
.../camel/model/ProcessorDefinitionHelper.java | 42 ++++++++------
.../interceptor/AdviceWithWeaveLastCBRTest.java | 58 ++++++++++++++++++++
2 files changed, 82 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f0443ae8/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
index ff0b846..15a3919 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinitionHelper.java
@@ -261,18 +261,21 @@ public final class ProcessorDefinitionHelper {
found.add((T)choice);
}
- for (WhenDefinition when : choice.getWhenClauses()) {
- if (type.isInstance(when)) {
- found.add((T)when);
+ // only look at children if current < maxDeep (or max deep is disabled)
+ if (maxDeep < 0 || current < maxDeep) {
+ for (WhenDefinition when : choice.getWhenClauses()) {
+ if (type.isInstance(when)) {
+ found.add((T) when);
+ }
+ List<ProcessorDefinition<?>> children = when.getOutputs();
+ doFindType(children, type, found, ++current, maxDeep);
}
- List<ProcessorDefinition<?>> children = when.getOutputs();
- doFindType(children, type, found, ++current, maxDeep);
- }
- // otherwise is optional
- if (choice.getOtherwise() != null) {
- List<ProcessorDefinition<?>> children = choice.getOtherwise().getOutputs();
- doFindType(children, type, found, ++current, maxDeep);
+ // otherwise is optional
+ if (choice.getOtherwise() != null) {
+ List<ProcessorDefinition<?>> children = choice.getOtherwise().getOutputs();
+ doFindType(children, type, found, ++current, maxDeep);
+ }
}
// do not check children as we already did that
@@ -288,16 +291,19 @@ public final class ProcessorDefinitionHelper {
found.add((T)doTry);
}
- List<ProcessorDefinition<?>> doTryOut = doTry.getOutputsWithoutCatches();
- doFindType(doTryOut, type, found, ++current, maxDeep);
+ // only look at children if current < maxDeep (or max deep is disabled)
+ if (maxDeep < 0 || current < maxDeep) {
+ List<ProcessorDefinition<?>> doTryOut = doTry.getOutputsWithoutCatches();
+ doFindType(doTryOut, type, found, ++current, maxDeep);
- List<CatchDefinition> doTryCatch = doTry.getCatchClauses();
- for (CatchDefinition doCatch : doTryCatch) {
- doFindType(doCatch.getOutputs(), type, found, ++current, maxDeep);
- }
+ List<CatchDefinition> doTryCatch = doTry.getCatchClauses();
+ for (CatchDefinition doCatch : doTryCatch) {
+ doFindType(doCatch.getOutputs(), type, found, ++current, maxDeep);
+ }
- if (doTry.getFinallyClause() != null) {
- doFindType(doTry.getFinallyClause().getOutputs(), type, found, ++current, maxDeep);
+ if (doTry.getFinallyClause() != null) {
+ doFindType(doTry.getFinallyClause().getOutputs(), type, found, ++current, maxDeep);
+ }
}
// do not check children as we already did that
http://git-wip-us.apache.org/repos/asf/camel/blob/f0443ae8/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java b/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java
new file mode 100644
index 0000000..b47b256
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithWeaveLastCBRTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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.processor.interceptor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * Advice with tests
+ */
+public class AdviceWithWeaveLastCBRTest extends ContextTestSupport {
+
+ public void testWeaveAddLast() throws Exception {
+ context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // insert at the end of the existing route, the given piece of route
+ weaveAddLast().to("mock:last");
+ }
+ });
+
+ getMockEndpoint("mock:foo").expectedMessageCount(1);
+ getMockEndpoint("mock:bar").expectedMessageCount(0);
+ getMockEndpoint("mock:last").expectedMessageCount(1);
+
+ template.sendBodyAndHeader("direct:start", "Hello World", "foo", "yeah");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .choice()
+ .when().header("foo").to("mock:foo")
+ .otherwise().to("mock:bar");
+ }
+ };
+ }
+}
\ No newline at end of file