This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-13755 in repository https://gitbox.apache.org/repos/asf/camel.git
commit e76b1672f7e1d4d8ad963832ab81cb1d2c0f24a4 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat Jul 20 12:05:00 2019 +0200 CAMEL-13755: camel3 - Remove fault from camel-core/message and let it be component specific for camel-cxf and camel-spring-ws as its only used by SOAP-WS --- .../component/cxf/CxfCustomizedExceptionTest.java | 8 ++- .../cxf/CxfSpringCustomizedExceptionTest.java | 12 +++- .../cxf/CxfCustomizedExceptionContext.xml | 34 ++++++------ .../SplitterAndExceptionRouteTwistIssueTest.java | 2 - .../jms/issues/BruceHandlingBeanExceptionTest.java | 10 +--- .../mina2/Mina2TransferExchangeOptionTest.java | 9 +-- .../mina2/Mina2VMTransferExchangeOptionTest.java | 9 +-- .../netty4/NettyTransferExchangeOptionTest.java | 9 +-- .../spring/processor/SpringSetFaultBodyTest.java | 46 ---------------- .../spring/processor/SpringSetFaultBodyTest.xml | 37 ------------- .../apache/camel/model/SetFaultBodyDefinition.java | 64 ---------------------- .../org/apache/camel/reifier/ProcessorReifier.java | 1 - .../modules/ROOT/pages/language-component.adoc | 2 +- 13 files changed, 45 insertions(+), 198 deletions(-) diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java index 3ffbb8f..8bb9a66 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java @@ -110,7 +110,13 @@ public class CxfCustomizedExceptionTest extends CamelTestSupport { .to(serviceURI); // END SNIPPET: onException // START SNIPPET: ThrowFault - from(routerEndpointURI).setFaultBody(constant(SOAP_FAULT)); + from(routerEndpointURI).process(new Processor() { + @Override + public void process(Exchange exchange) throws Exception { + exchange.getMessage().setFault(true); + exchange.getMessage().setBody(SOAP_FAULT); + } + }); // END SNIPPET: ThrowFault } }; diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSpringCustomizedExceptionTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSpringCustomizedExceptionTest.java index 81a7099..b00300a 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSpringCustomizedExceptionTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSpringCustomizedExceptionTest.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.cxf; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; @@ -94,10 +96,14 @@ public class CxfSpringCustomizedExceptionTest extends CamelTestSupport { return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CxfCustomizedExceptionContext.xml"); } - public static class SOAPFaultFactory { - public SoapFault getSoapFault() { - return SOAP_FAULT; + public static class SOAPFaultProcessor implements Processor { + + @Override + public void process(Exchange exchange) throws Exception { + exchange.getMessage().setFault(true); + exchange.getMessage().setBody(SOAP_FAULT); } } + } diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfCustomizedExceptionContext.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfCustomizedExceptionContext.xml index 9397439..6886963 100644 --- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfCustomizedExceptionContext.xml +++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfCustomizedExceptionContext.xml @@ -25,21 +25,23 @@ "> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> - <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> - <endpoint id="to1" uri="cxf://http://localhost:${CXFTestSupport.port1}/CxfSpringCustomizedExceptionTest/router?serviceClass=org.apache.camel.component.cxf.HelloService"/> - <endpoint id="from1" uri="cxf://http://localhost:${CXFTestSupport.port1}/CxfSpringCustomizedExceptionTest/router?serviceClass=org.apache.camel.component.cxf.HelloService"/> - <route> - <from uri="direct:start" /> - <to uri="ref:to1"/> - </route> - <route> - <from uri="ref:from1"/> - <setFaultBody> - <method beanType="org.apache.camel.component.cxf.CxfSpringCustomizedExceptionTest$SOAPFaultFactory"/> - </setFaultBody> - <!-- Need to add output endpoint to get route loaded --> - <to uri="log:mylog"/> - </route> - </camelContext> + <bean id="myProcessor" class="org.apache.camel.component.cxf.CxfSpringCustomizedExceptionTest$SOAPFaultProcessor"/> + + <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> + <endpoint id="to1" + uri="cxf://http://localhost:${CXFTestSupport.port1}/CxfSpringCustomizedExceptionTest/router?serviceClass=org.apache.camel.component.cxf.HelloService"/> + <endpoint id="from1" + uri="cxf://http://localhost:${CXFTestSupport.port1}/CxfSpringCustomizedExceptionTest/router?serviceClass=org.apache.camel.component.cxf.HelloService"/> + <route> + <from uri="direct:start"/> + <to uri="ref:to1"/> + </route> + <route> + <from uri="ref:from1"/> + <process ref="myProcessor"/> + <!-- Need to add output endpoint to get route loaded --> + <to uri="log:mylog"/> + </route> + </camelContext> </beans> \ No newline at end of file diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/SplitterAndExceptionRouteTwistIssueTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/SplitterAndExceptionRouteTwistIssueTest.java index e712e2e..6510095 100644 --- a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/SplitterAndExceptionRouteTwistIssueTest.java +++ b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/SplitterAndExceptionRouteTwistIssueTest.java @@ -107,7 +107,6 @@ public class SplitterAndExceptionRouteTwistIssueTest extends CamelTestSupport { ); from("direct:error") - .handleFault() .convertBodyTo(String.class, "UTF-8") .process(new Processor() { @Override @@ -127,7 +126,6 @@ public class SplitterAndExceptionRouteTwistIssueTest extends CamelTestSupport { from("direct:error2") - .handleFault() .convertBodyTo(String.class, "UTF-8") .process(new Processor() { @Override diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/BruceHandlingBeanExceptionTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/BruceHandlingBeanExceptionTest.java index 1007150..47617c8 100644 --- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/BruceHandlingBeanExceptionTest.java +++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/BruceHandlingBeanExceptionTest.java @@ -27,7 +27,7 @@ import org.junit.Test; import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge; /** - * Unit test for request-reply with jms where processing the input could cause: OK, FAULT or Exception + * Unit test for request-reply with jms where processing the input could cause: OK or Exception */ public class BruceHandlingBeanExceptionTest extends CamelTestSupport { @@ -38,12 +38,6 @@ public class BruceHandlingBeanExceptionTest extends CamelTestSupport { } @Test - public void testSendFailure() throws Exception { - Object out = template.requestBody("activemq:queue:fault", "Hello World"); - assertEquals("This is a fault message", out); - } - - @Test public void testSendError() throws Exception { Object out = template.requestBody("activemq:queue:error", "Hello World"); IllegalArgumentException e = assertIsInstanceOf(IllegalArgumentException.class, out); @@ -65,8 +59,6 @@ public class BruceHandlingBeanExceptionTest extends CamelTestSupport { public void configure() throws Exception { from("activemq:queue:ok").transform(constant("Bye World")); - from("activemq:queue:fault").setFaultBody(constant("This is a fault message")); - from("activemq:queue:error?transferException=true").bean(MyExceptionBean.class); } }; diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TransferExchangeOptionTest.java b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TransferExchangeOptionTest.java index d0d864c..3ce215d 100644 --- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TransferExchangeOptionTest.java +++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TransferExchangeOptionTest.java @@ -66,19 +66,17 @@ public class Mina2TransferExchangeOptionTest extends BaseMina2Test { return exchange; } - private void assertExchange(Exchange exchange, boolean hasFault) { - if (!hasFault) { + private void assertExchange(Exchange exchange, boolean hasException) { + if (!hasException) { Message out = exchange.getOut(); assertNotNull(out); - assertFalse(out.isFault()); assertEquals("Goodbye!", out.getBody()); assertEquals("cheddar", out.getHeader("cheese")); } else { Message fault = exchange.getOut(); assertNotNull(fault); - assertTrue(fault.isFault()); assertNotNull(fault.getBody()); - assertTrue("Should get the InterrupteException exception", fault.getBody() instanceof InterruptedException); + assertTrue("Should get the InterruptedException exception", fault.getBody() instanceof InterruptedException); assertEquals("nihao", fault.getHeader("hello")); } @@ -118,7 +116,6 @@ public class Mina2TransferExchangeOptionTest extends BaseMina2Test { Boolean setException = (Boolean) e.getProperty("setException"); if (setException) { - e.getOut().setFault(true); e.getOut().setBody(new InterruptedException()); e.getOut().setHeader("hello", "nihao"); } else { diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2VMTransferExchangeOptionTest.java b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2VMTransferExchangeOptionTest.java index e249ac4..3ba21b0 100644 --- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2VMTransferExchangeOptionTest.java +++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2VMTransferExchangeOptionTest.java @@ -61,19 +61,17 @@ public class Mina2VMTransferExchangeOptionTest extends BaseMina2Test { return exchange; } - private void assertExchange(Exchange exchange, boolean hasFault) { - if (!hasFault) { + private void assertExchange(Exchange exchange, boolean hasException) { + if (!hasException) { Message out = exchange.getOut(); assertNotNull(out); - assertFalse(out.isFault()); assertEquals("Goodbye!", out.getBody()); assertEquals("cheddar", out.getHeader("cheese")); } else { Message fault = exchange.getOut(); assertNotNull(fault); - assertTrue(fault.isFault()); assertNotNull(fault.getBody()); - assertTrue("Should get the InterrupteException exception", fault.getBody() instanceof InterruptedException); + assertTrue("Should get the InterruptedException exception", fault.getBody() instanceof InterruptedException); assertEquals("nihao", fault.getHeader("hello")); } @@ -105,7 +103,6 @@ public class Mina2VMTransferExchangeOptionTest extends BaseMina2Test { Boolean setException = (Boolean) e.getProperty("setException"); if (setException) { - e.getOut().setFault(true); e.getOut().setBody(new InterruptedException()); e.getOut().setHeader("hello", "nihao"); } else { diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTransferExchangeOptionTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTransferExchangeOptionTest.java index 3dd9556..2de14f7 100644 --- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTransferExchangeOptionTest.java +++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTransferExchangeOptionTest.java @@ -64,19 +64,17 @@ public class NettyTransferExchangeOptionTest extends BaseNettyTest { return exchange; } - private void assertExchange(Exchange exchange, boolean hasFault) { - if (!hasFault) { + private void assertExchange(Exchange exchange, boolean hasException) { + if (!hasException) { Message out = exchange.getOut(); assertNotNull(out); - assertFalse(out.isFault()); assertEquals("Goodbye!", out.getBody()); assertEquals("cheddar", out.getHeader("cheese")); } else { Message fault = exchange.getOut(); assertNotNull(fault); - assertTrue(fault.isFault()); assertNotNull(fault.getBody()); - assertTrue("Should get the InterrupteException exception", fault.getBody() instanceof InterruptedException); + assertTrue("Should get the InterruptedException exception", fault.getBody() instanceof InterruptedException); assertEquals("nihao", fault.getHeader("hello")); } @@ -106,7 +104,6 @@ public class NettyTransferExchangeOptionTest extends BaseNettyTest { Boolean setException = (Boolean) e.getProperty("setException"); if (setException) { - e.getOut().setFault(true); e.getOut().setBody(new InterruptedException()); e.getOut().setHeader("hello", "nihao"); } else { diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetFaultBodyTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetFaultBodyTest.java deleted file mode 100644 index d5396a7..0000000 --- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetFaultBodyTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.processor; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.spring.SpringTestSupport; -import org.junit.Test; -import org.springframework.context.support.AbstractXmlApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class SpringSetFaultBodyTest extends SpringTestSupport { - - @Override - protected AbstractXmlApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("org/apache/camel/spring/processor/SpringSetFaultBodyTest.xml"); - } - - @Test - public void testSetFaultBody() throws Exception { - Exchange out = template.request("direct:start", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setBody("Hello World"); - } - }); - - assertNotNull(out); - assertEquals("Bye World", out.getIn().getBody()); - assertTrue("Should be a fault body", out.getIn().isFault()); - } -} diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetFaultBodyTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetFaultBodyTest.xml deleted file mode 100644 index 97ff1da..0000000 --- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSetFaultBodyTest.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?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> - <from uri="direct:start"/> - <setFaultBody> - <constant>Bye World</constant> - </setFaultBody> - </route> - - </camelContext> -</beans> diff --git a/core/camel-core/src/main/java/org/apache/camel/model/SetFaultBodyDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/SetFaultBodyDefinition.java deleted file mode 100644 index d5090a2..0000000 --- a/core/camel-core/src/main/java/org/apache/camel/model/SetFaultBodyDefinition.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.model; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; - -import org.apache.camel.Expression; -import org.apache.camel.model.language.ExpressionDefinition; -import org.apache.camel.spi.Metadata; - -/** - * Sets the contents of a fault message's body - */ -@Metadata(label = "eip,transformation") -@XmlRootElement(name = "setFaultBody") -@XmlAccessorType(XmlAccessType.FIELD) -public class SetFaultBodyDefinition extends ExpressionNode { - - public SetFaultBodyDefinition() { - } - - public SetFaultBodyDefinition(Expression expression) { - super(expression); - } - - @Override - public String toString() { - return "SetFaultBody[" + getExpression() + "]"; - } - - @Override - public String getShortName() { - return "setFaultBody"; - } - - @Override - public String getLabel() { - return "setFaultBody[" + getExpression() + "]"; - } - - /** - * Expression that returns the new fault body to use - */ - @Override - public void setExpression(ExpressionDefinition expression) { - super.setExpression(expression); - } -} diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java b/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java index c84b4c3..8f4a253 100644 --- a/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java +++ b/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java @@ -77,7 +77,6 @@ import org.apache.camel.model.SamplingDefinition; import org.apache.camel.model.ScriptDefinition; import org.apache.camel.model.SetBodyDefinition; import org.apache.camel.model.SetExchangePatternDefinition; -import org.apache.camel.model.SetFaultBodyDefinition; import org.apache.camel.model.SetHeaderDefinition; import org.apache.camel.model.SetPropertyDefinition; import org.apache.camel.model.SortDefinition; diff --git a/docs/components/modules/ROOT/pages/language-component.adoc b/docs/components/modules/ROOT/pages/language-component.adoc index 81161fa..dc3b08b 100644 --- a/docs/components/modules/ROOT/pages/language-component.adoc +++ b/docs/components/modules/ROOT/pages/language-component.adoc @@ -79,7 +79,7 @@ with the following path and query parameters: | Name | Description | Default | Type | *binary* (producer) | Whether the script is binary content or text content. By default the script is read as text content (eg java.lang.String) | false | boolean | *cacheScript* (producer) | Whether to cache the compiled script and reuse Notice reusing the script can cause side effects from processing one Camel org.apache.camel.Exchange to the next org.apache.camel.Exchange. | false | boolean -| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean +| *contentCache* (producer) | Sets whether to use resource content cache or not | true | boolean | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] | *script* (producer) | Sets the script to execute | | String | *transform* (producer) | Whether or not the result of the script should be used as message body. This options is default true. | true | boolean