Added unit test based on user forum issue
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0450fa24 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0450fa24 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0450fa24 Branch: refs/heads/master Commit: 0450fa24ab4acd38b394d6d90d910e2121a8a28e Parents: 94f5dcb Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Nov 5 11:29:34 2013 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Nov 5 12:02:11 2013 +0100 ---------------------------------------------------------------------- ...ExceptionAndRollbackUsingTransactedTest.java | 32 ++++++++ ...pedOnExceptionAndRollbackUsingTransacted.xml | 79 ++++++++++++++++++++ 2 files changed, 111 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/0450fa24/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransactedTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransactedTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransactedTest.java new file mode 100644 index 0000000..9a9a4d6 --- /dev/null +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/SpringTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransactedTest.java @@ -0,0 +1,32 @@ +/** + * 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.interceptor; + +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * Easier transaction configuration as we do not have to setup a transaction error handler + */ +public class SpringTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransactedTest extends SpringTransactionalClientDataWithOnExceptionAndRollbackUsingTransactedTest { + + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext( + "/org/apache/camel/spring/interceptor/springTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransacted.xml"); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0450fa24/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransacted.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransacted.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransacted.xml new file mode 100644 index 0000000..b7986db --- /dev/null +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataWithRouteScopedOnExceptionAndRollbackUsingTransacted.xml @@ -0,0 +1,79 @@ +<?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"> + + <import resource="transactionalClientDataSource.xml"/> + + <!-- START SNIPPET: e1 --> + <camelContext xmlns="http://camel.apache.org/schema/spring"> + + <route> + <from uri="direct:okay"/> + <transacted/> + <onException> + <exception>java.lang.IllegalArgumentException</exception> + <handled> + <constant>true</constant> + </handled> + <to uri="mock:error"/> + <transform> + <constant>Sorry</constant> + </transform> + <rollback markRollbackOnly="true"/> + </onException> + <setBody> + <constant>Tiger in Action</constant> + </setBody> + <bean ref="bookService"/> + <setBody> + <constant>Elephant in Action</constant> + </setBody> + <bean ref="bookService"/> + </route> + + <route> + <from uri="direct:fail"/> + <transacted/> + <onException> + <exception>java.lang.IllegalArgumentException</exception> + <handled> + <constant>true</constant> + </handled> + <to uri="mock:error"/> + <transform> + <constant>Sorry</constant> + </transform> + <rollback markRollbackOnly="true"/> + </onException> + <setBody> + <constant>Tiger in Action</constant> + </setBody> + <bean ref="bookService"/> + <setBody> + <constant>Donkey in Action</constant> + </setBody> + <bean ref="bookService"/> + </route> + </camelContext> + <!-- END SNIPPET: e1 --> + +</beans>