Repository: camel Updated Branches: refs/heads/camel-2.16.x 2890a2f26 -> 7e8171e0a refs/heads/master 7ff8012a8 -> c2f902451
CAMEL-9215: WireTap in Java DSL should allow end to go back to previous type. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c2f90245 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c2f90245 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c2f90245 Branch: refs/heads/master Commit: c2f90245150920d72578c844cce63e6e55aa9a09 Parents: 7ff8012 Author: Claus Ibsen <davscl...@apache.org> Authored: Mon Oct 12 18:49:34 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Oct 12 18:49:34 2015 +0200 ---------------------------------------------------------------------- .../apache/camel/model/WireTapDefinition.java | 27 ++++++----- .../OnExceptionWireTapNewExchangeBodyTest.java | 48 ++++++++++++++++++++ 2 files changed, 61 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/c2f90245/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java b/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java index 22a1e22..a8116d4 100644 --- a/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java @@ -30,7 +30,6 @@ import javax.xml.bind.annotation.XmlTransient; import org.apache.camel.ExchangePattern; import org.apache.camel.Expression; import org.apache.camel.Processor; -import org.apache.camel.model.language.ExpressionDefinition; import org.apache.camel.processor.CamelInternalProcessor; import org.apache.camel.processor.SendDynamicProcessor; import org.apache.camel.processor.WireTapProcessor; @@ -153,7 +152,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * for sending tapped exchanges * @return the builder */ - public WireTapDefinition executorService(ExecutorService executorService) { + public WireTapDefinition<Type> executorService(ExecutorService executorService) { setExecutorService(executorService); return this; } @@ -165,7 +164,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * to use as thread pool for sending tapped exchanges * @return the builder */ - public WireTapDefinition executorServiceRef(String executorServiceRef) { + public WireTapDefinition<Type> executorServiceRef(String executorServiceRef) { setExecutorServiceRef(executorServiceRef); return this; } @@ -175,7 +174,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * * @return the builder */ - public WireTapDefinition copy() { + public WireTapDefinition<Type> copy() { setCopy(true); return this; } @@ -187,7 +186,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * if it is false camel will not copy the original exchange * @return the builder */ - public WireTapDefinition copy(boolean copy) { + public WireTapDefinition<Type> copy(boolean copy) { setCopy(copy); return this; } @@ -196,7 +195,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * @deprecated will be removed in Camel 3.0 Instead use {@link #newExchangeBody(org.apache.camel.Expression)} */ @Deprecated - public WireTapDefinition newExchange(Expression expression) { + public WireTapDefinition<Type> newExchange(Expression expression) { return newExchangeBody(expression); } @@ -207,7 +206,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * @return the builder * @see #newExchangeHeader(String, org.apache.camel.Expression) */ - public WireTapDefinition newExchangeBody(Expression expression) { + public WireTapDefinition<Type> newExchangeBody(Expression expression) { setNewExchangeExpression(new ExpressionSubElementDefinition(expression)); return this; } @@ -219,7 +218,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * be used for preparing the new exchange to send * @return the builder */ - public WireTapDefinition newExchangeRef(String ref) { + public WireTapDefinition<Type> newExchangeRef(String ref) { setNewExchangeProcessorRef(ref); return this; } @@ -231,7 +230,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * @return the builder * @see #newExchangeHeader(String, org.apache.camel.Expression) */ - public WireTapDefinition newExchange(Processor processor) { + public WireTapDefinition<Type> newExchange(Processor processor) { setNewExchangeProcessor(processor); return this; } @@ -246,7 +245,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * @param expression the expression setting the header value * @return the builder */ - public WireTapDefinition newExchangeHeader(String headerName, Expression expression) { + public WireTapDefinition<Type> newExchangeHeader(String headerName, Expression expression) { headers.add(new SetHeaderDefinition(headerName, expression)); return this; } @@ -259,7 +258,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * @param onPrepare the processor * @return the builder */ - public WireTapDefinition onPrepare(Processor onPrepare) { + public WireTapDefinition<Type> onPrepare(Processor onPrepare) { setOnPrepare(onPrepare); return this; } @@ -272,7 +271,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * @param onPrepareRef reference to the processor to lookup in the {@link org.apache.camel.spi.Registry} * @return the builder */ - public WireTapDefinition onPrepareRef(String onPrepareRef) { + public WireTapDefinition<Type> onPrepareRef(String onPrepareRef) { setOnPrepareRef(onPrepareRef); return this; } @@ -285,7 +284,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * @return the builder */ @Override - public WireTapDefinition cacheSize(int cacheSize) { + public WireTapDefinition<Type> cacheSize(int cacheSize) { setCacheSize(cacheSize); return this; } @@ -296,7 +295,7 @@ public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends T * @return the builder */ @Override - public WireTapDefinition ignoreInvalidEndpoint() { + public WireTapDefinition<Type> ignoreInvalidEndpoint() { setIgnoreInvalidEndpoint(true); return this; } http://git-wip-us.apache.org/repos/asf/camel/blob/c2f90245/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionWireTapNewExchangeBodyTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionWireTapNewExchangeBodyTest.java b/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionWireTapNewExchangeBodyTest.java new file mode 100644 index 0000000..5c5c3d3 --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionWireTapNewExchangeBodyTest.java @@ -0,0 +1,48 @@ +/** + * 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.onexception; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; + +public class OnExceptionWireTapNewExchangeBodyTest extends ContextTestSupport { + + public void testOnExceptionWireTapNewExchangeBody() throws Exception { + getMockEndpoint("mock:tap").expectedBodiesReceived("Error due Forced"); + getMockEndpoint("mock:ignore").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + onException(IllegalArgumentException.class) + .wireTap("mock:tap").newExchangeBody(simple("Error due ${exception.message}")).end() + .handled(true) + .to("mock:ignore"); + + from("direct:start") + .throwException(new IllegalArgumentException("Forced")); + } + }; + } +}