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 2009/06/05 14:09:28 UTC

svn commit: r781993 - in /camel/trunk/components/camel-spring/src/test: java/org/apache/camel/spring/interceptor/ resources/org/apache/camel/spring/interceptor/

Author: davsclaus
Date: Fri Jun  5 12:09:27 2009
New Revision: 781993

URL: http://svn.apache.org/viewvc?rev=781993&view=rev
Log:
CAMEL-1663: Polished unit test a bit more.

Added:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsume.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsumeImpl.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithAnnotatedBeanTest.java   (contents, props changed)
      - copied, changed from r781974, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientWithAnnotatedBeanTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml   (contents, props changed)
      - copied, changed from r781974, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionClientWithAnnotatedBeanTest.xml
Removed:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientWithAnnotatedBeanTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionClientWithAnnotatedBeanTest.xml
Modified:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedBookServiceImpl.java

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedBookServiceImpl.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedBookServiceImpl.java?rev=781993&r1=781992&r2=781993&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedBookServiceImpl.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedBookServiceImpl.java Fri Jun  5 12:09:27 2009
@@ -35,16 +35,16 @@
     @Autowired
     private DataSource dataSource;
 
-    @EndpointInject(uri = "mock:book")
+    @EndpointInject(uri = "seda:book")
     private ProducerTemplate template;
 
     public void orderBook(String title) throws Exception {
         Transactional tx = this.getClass().getAnnotation(Transactional.class);
         if (tx == null) {
-            throw new IllegalArgumentException("Spring annotation-driven should have instrumented this class as @Transactional");
+            throw new IllegalStateException("Spring annotation-driven should have instrumented this class as @Transactional");
         }
         if (!"REQUIRED".equals(tx.propagation().name())) {
-            throw new IllegalArgumentException("Should be REQUIRED propagation");
+            throw new IllegalStateException("Should be REQUIRED propagation");
         }
 
         if (title.startsWith("Donkey")) {

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsume.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsume.java?rev=781993&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsume.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsume.java Fri Jun  5 12:09:27 2009
@@ -0,0 +1,26 @@
+/**
+ * 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;
+
+/**
+ * @version $Revision$
+ */
+public interface AnnotatedConsume {
+
+    void handleTitle(String title);
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsume.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsume.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsumeImpl.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsumeImpl.java?rev=781993&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsumeImpl.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsumeImpl.java Fri Jun  5 12:09:27 2009
@@ -0,0 +1,53 @@
+/**
+ * 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.apache.camel.Consume;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @version $Revision$
+ */
+@Transactional(propagation = org.springframework.transaction.annotation.Propagation.NEVER, readOnly = true)
+public class AnnotatedConsumeImpl implements AnnotatedConsume {
+
+    @Produce(uri = "mock:book")
+    ProducerTemplate producer;
+
+    @Consume(uri = "seda:book")
+    public void handleTitle(String title) {
+        Transactional tx = this.getClass().getAnnotation(Transactional.class);
+        if (tx == null) {
+            throw new IllegalStateException("Spring annotation-driven should have instrumented this class as @Transactional");
+        }
+        if (!"NEVER".equals(tx.propagation().name())) {
+            throw new IllegalStateException("Should be NEVER propagation");
+        }
+        if (!tx.readOnly()) {
+            throw new IllegalStateException("Should be read only");
+        }
+
+        if (!title.contains("in Action")) {
+            throw new IllegalArgumentException("Not a book title we like");
+        }
+
+        producer.sendBody(title);
+    }
+    
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsumeImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/AnnotatedConsumeImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithAnnotatedBeanTest.java (from r781974, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientWithAnnotatedBeanTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithAnnotatedBeanTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithAnnotatedBeanTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientWithAnnotatedBeanTest.java&r1=781974&r2=781993&rev=781993&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientWithAnnotatedBeanTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithAnnotatedBeanTest.java Fri Jun  5 12:09:27 2009
@@ -16,13 +16,34 @@
  */
 package org.apache.camel.spring.interceptor;
 
+import org.apache.camel.component.mock.MockEndpoint;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
  * @version $Revision$
  */
-public class TransactionClientWithAnnotatedBeanTest extends TransactionalClientDataSourceTest {
+public class TransactionalClientWithAnnotatedBeanTest extends TransactionalClientDataSourceTest {
+
+    @Override
+    public void testTransactionSuccess() throws Exception {
+        MockEndpoint book = getMockEndpoint("mock:book");
+        book.expectedMessageCount(2);
+
+        super.testTransactionSuccess();
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    public void testTransactionRollback() throws Exception {
+        MockEndpoint book = getMockEndpoint("mock:book");
+        book.expectedMessageCount(1);
+
+        super.testTransactionRollback();
+
+        assertMockEndpointsSatisfied();
+    }
 
     @Override
     protected void setUp() throws Exception {
@@ -32,7 +53,7 @@
 
     protected AbstractXmlApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext(
-            "/org/apache/camel/spring/interceptor/transactionClientWithAnnotatedBeanTest.xml");
+                "/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml");
     }
 
     @Override

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithAnnotatedBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithAnnotatedBeanTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml (from r781974, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionClientWithAnnotatedBeanTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionClientWithAnnotatedBeanTest.xml&r1=781974&r2=781993&rev=781993&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionClientWithAnnotatedBeanTest.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml Fri Jun  5 12:09:27 2009
@@ -46,4 +46,6 @@
 
     <bean id="annotatedRoute" class="org.apache.camel.spring.interceptor.AnnotatedRoute"/>
 
+    <bean id="annotatedConsumer" class="org.apache.camel.spring.interceptor.AnnotatedConsumeImpl"/>
+
 </beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientWithAnnotatedBeanTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml