camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1102080 - in /camel/trunk/tests/camel-itest/src/test: java/org/apache/camel/itest/sql/ resources/ resources/org/apache/camel/itest/sql/
Date Wed, 11 May 2011 20:35:10 GMT
Author: cmueller
Date: Wed May 11 20:35:10 2011
New Revision: 1102080

URL: http://svn.apache.org/viewvc?rev=1102080&view=rev
Log:
Added test for JMS and JDBC idempotent consumer EIP without XA based on user issue

Added:
    camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java
      - copied, changed from r1101929, camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
    camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml
      - copied, changed from r1101929, camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml
    camel/trunk/tests/camel-itest/src/test/resources/transactions.properties
Modified:
    camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
    camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml

Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java?rev=1102080&r1=1102079&r2=1102080&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
(original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
Wed May 11 20:35:10 2011
@@ -16,8 +16,9 @@
  */
 package org.apache.camel.itest.sql;
 
-import java.io.File;
 import java.net.ConnectException;
+import java.util.concurrent.atomic.AtomicInteger;
+
 import javax.sql.DataSource;
 
 import org.apache.camel.Exchange;
@@ -26,7 +27,6 @@ import org.apache.camel.builder.NotifyBu
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spi.IdempotentRepository;
 import org.apache.camel.test.junit4.CamelSpringTestSupport;
-import org.apache.camel.util.FileUtil;
 import org.junit.Before;
 import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
@@ -34,13 +34,12 @@ import org.springframework.context.suppo
 import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
- * Jms with JDBC idempotent consumer using XA test.
+ * Jms with JDBC idempotent consumer test.
  */
 public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSupport {
 
     protected JdbcTemplate jdbcTemplate;
     protected DataSource dataSource;
-    protected IdempotentRepository repository;
 
     @Override
     protected AbstractApplicationContext createApplicationContext() {
@@ -50,14 +49,9 @@ public class FromJmsToJdbcIdempotentCons
     @Override
     @Before
     public void setUp() throws Exception {
-        // delete transaction log and AMQ data
-        FileUtil.deleteFile(new File("tm.out"));
-        FileUtil.deleteFile(new File("tmlog0.log"));
-        deleteDirectory("activemq-data");
-
         super.setUp();
 
-        dataSource = context.getRegistry().lookup("myNonXADataSource", DataSource.class);
+        dataSource = context.getRegistry().lookup("dataSource", DataSource.class);
         jdbcTemplate = new JdbcTemplate(dataSource);
         jdbcTemplate.afterPropertiesSet();
 
@@ -75,9 +69,7 @@ public class FromJmsToJdbcIdempotentCons
 
     @Test
     public void testJmsToJdbcJmsCommit() throws Exception {
-        // check there are no messages in the database and JMS queue
-        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 2000));
+        checkInitialState();
 
         // use a notify to know when the message is done
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
@@ -100,9 +92,7 @@ public class FromJmsToJdbcIdempotentCons
 
     @Test
     public void testJmsToJdbcJmsRollbackAtA() throws Exception {
-        // check there are no messages in the database and JMS queue
-        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 2000));
+        checkInitialState();
 
         // use a notify to know that after 1+6 (1 original + 6 redelivery) attempts from
AcitveMQ
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(7).create();
@@ -125,7 +115,7 @@ public class FromJmsToJdbcIdempotentCons
 
         // check that there is a message in the database and JMS queue
         assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 3000));
+        assertNull(consumer.receiveBody("activemq:queue:outbox", 3000));
 
         // the message should have been moved to the AMQ DLQ queue
         assertEquals("A", consumer.receiveBody("activemq:queue:ActiveMQ.DLQ", 3000));
@@ -133,15 +123,14 @@ public class FromJmsToJdbcIdempotentCons
 
     @Test
     public void testJmsToJdbcJmsRollbackAtB() throws Exception {
-        // check there are no messages in the database and JMS queue
-        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 2000));
+        checkInitialState();
 
         // use a notify to know that after 1+6 (1 original + 6 redelivery) attempts from
AcitveMQ
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(7).create();
 
         getMockEndpoint("mock:a").expectedMessageCount(7);
-        // force exception to occur at mock a
+        getMockEndpoint("mock:b").expectedMessageCount(7);
+        // force exception to occur at mock b
         getMockEndpoint("mock:b").whenAnyExchangeReceived(new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -157,7 +146,7 @@ public class FromJmsToJdbcIdempotentCons
 
         // check that there is a message in the database and JMS queue
         assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 3000));
+        assertNull(consumer.receiveBody("activemq:queue:outbox", 3000));
 
         // the message should have been moved to the AMQ DLQ queue
         assertEquals("B", consumer.receiveBody("activemq:queue:ActiveMQ.DLQ", 3000));
@@ -165,9 +154,7 @@ public class FromJmsToJdbcIdempotentCons
 
     @Test
     public void testFilterIdempotent() throws Exception {
-        // check there are no messages in the database and JMS queue
-        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 2000));
+        checkInitialState();
 
         // use a notify to know when the message is done
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();
@@ -190,13 +177,57 @@ public class FromJmsToJdbcIdempotentCons
         assertEquals("DONE-D", consumer.receiveBody("activemq:queue:outbox", 3000));
         assertEquals("DONE-E", consumer.receiveBody("activemq:queue:outbox", 3000));
     }
+    
+    @Test
+    public void testRetryAfterException() throws Exception {
+        checkInitialState();
+        
+        final AtomicInteger counter = new AtomicInteger();
+        
+        // use a notify to know when the message is done
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(4).create();
+
+        // use mock during testing as well
+        getMockEndpoint("mock:a").expectedMessageCount(4);
+        // there should be 1 duplicate
+        getMockEndpoint("mock:b").expectedMessageCount(4);
+        getMockEndpoint("mock:b").whenAnyExchangeReceived(new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                if (counter.getAndIncrement() == 1) {
+                    throw new ConnectException("Forced cannot send to AMQ queue");
+                }
+            }
+        });
+
+        template.sendBodyAndHeader("activemq:queue:inbox", "D", "uid", 111);
+        template.sendBodyAndHeader("activemq:queue:inbox", "E", "uid", 222);
+        template.sendBodyAndHeader("activemq:queue:inbox", "F", "uid", 333);
+
+        // assert mock and wait for the message to be done
+        assertMockEndpointsSatisfied();
+        assertTrue("Should complete 4 messages", notify.matchesMockWaitTime());
+
+        // check that there is two messages in the database and JMS queue
+        assertEquals(3, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
+        assertEquals("DONE-D", consumer.receiveBody("activemq:queue:outbox", 3000));
+        assertEquals("DONE-E", consumer.receiveBody("activemq:queue:outbox", 3000));
+        assertEquals("DONE-F", consumer.receiveBody("activemq:queue:outbox", 3000));
+    }
+    
+    private void checkInitialState() {
+        // check there are no messages in the database and JMS queue
+        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
+        assertNull(consumer.receiveBody("activemq:queue:outbox", 2000));
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
+            @SuppressWarnings("unchecked")
             @Override
             public void configure() throws Exception {
-                repository = context.getRegistry().lookup("messageIdRepository", IdempotentRepository.class);
+                IdempotentRepository<String> repository = context.getRegistry().lookup("messageIdRepository",
IdempotentRepository.class);
 
                 from("activemq:queue:inbox")
                     .transacted("required")

Copied: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java
(from r1101929, camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java?p2=camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java&p1=camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java&r1=1101929&r2=1102080&rev=1102080&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
(original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java
Wed May 11 20:35:10 2011
@@ -16,8 +16,9 @@
  */
 package org.apache.camel.itest.sql;
 
-import java.io.File;
 import java.net.ConnectException;
+import java.util.concurrent.atomic.AtomicInteger;
+
 import javax.sql.DataSource;
 
 import org.apache.camel.Exchange;
@@ -26,7 +27,6 @@ import org.apache.camel.builder.NotifyBu
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spi.IdempotentRepository;
 import org.apache.camel.test.junit4.CamelSpringTestSupport;
-import org.apache.camel.util.FileUtil;
 import org.junit.Before;
 import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
@@ -36,25 +36,19 @@ import org.springframework.jdbc.core.Jdb
 /**
  * Jms with JDBC idempotent consumer using XA test.
  */
-public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSupport {
+public class FromJmsToJdbcIdempotentConsumerToJmsXaTest extends CamelSpringTestSupport {
 
     protected JdbcTemplate jdbcTemplate;
     protected DataSource dataSource;
-    protected IdempotentRepository repository;
 
     @Override
     protected AbstractApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml");
+        return new ClassPathXmlApplicationContext("org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml");
     }
 
     @Override
     @Before
     public void setUp() throws Exception {
-        // delete transaction log and AMQ data
-        FileUtil.deleteFile(new File("tm.out"));
-        FileUtil.deleteFile(new File("tmlog0.log"));
-        deleteDirectory("activemq-data");
-
         super.setUp();
 
         dataSource = context.getRegistry().lookup("myNonXADataSource", DataSource.class);
@@ -75,9 +69,7 @@ public class FromJmsToJdbcIdempotentCons
 
     @Test
     public void testJmsToJdbcJmsCommit() throws Exception {
-        // check there are no messages in the database and JMS queue
-        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 2000));
+        checkInitialState();
 
         // use a notify to know when the message is done
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
@@ -100,9 +92,7 @@ public class FromJmsToJdbcIdempotentCons
 
     @Test
     public void testJmsToJdbcJmsRollbackAtA() throws Exception {
-        // check there are no messages in the database and JMS queue
-        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 2000));
+        checkInitialState();
 
         // use a notify to know that after 1+6 (1 original + 6 redelivery) attempts from
AcitveMQ
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(7).create();
@@ -125,7 +115,7 @@ public class FromJmsToJdbcIdempotentCons
 
         // check that there is a message in the database and JMS queue
         assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 3000));
+        assertNull(consumer.receiveBody("activemq:queue:outbox", 3000));
 
         // the message should have been moved to the AMQ DLQ queue
         assertEquals("A", consumer.receiveBody("activemq:queue:ActiveMQ.DLQ", 3000));
@@ -133,15 +123,14 @@ public class FromJmsToJdbcIdempotentCons
 
     @Test
     public void testJmsToJdbcJmsRollbackAtB() throws Exception {
-        // check there are no messages in the database and JMS queue
-        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 2000));
+        checkInitialState();
 
         // use a notify to know that after 1+6 (1 original + 6 redelivery) attempts from
AcitveMQ
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(7).create();
 
         getMockEndpoint("mock:a").expectedMessageCount(7);
-        // force exception to occur at mock a
+        getMockEndpoint("mock:b").expectedMessageCount(7);
+        // force exception to occur at mock b
         getMockEndpoint("mock:b").whenAnyExchangeReceived(new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -157,7 +146,7 @@ public class FromJmsToJdbcIdempotentCons
 
         // check that there is a message in the database and JMS queue
         assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 3000));
+        assertNull(consumer.receiveBody("activemq:queue:outbox", 3000));
 
         // the message should have been moved to the AMQ DLQ queue
         assertEquals("B", consumer.receiveBody("activemq:queue:ActiveMQ.DLQ", 3000));
@@ -165,9 +154,7 @@ public class FromJmsToJdbcIdempotentCons
 
     @Test
     public void testFilterIdempotent() throws Exception {
-        // check there are no messages in the database and JMS queue
-        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
-        assertEquals(null, consumer.receiveBody("activemq:queue:outbox", 2000));
+        checkInitialState();
 
         // use a notify to know when the message is done
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();
@@ -190,13 +177,57 @@ public class FromJmsToJdbcIdempotentCons
         assertEquals("DONE-D", consumer.receiveBody("activemq:queue:outbox", 3000));
         assertEquals("DONE-E", consumer.receiveBody("activemq:queue:outbox", 3000));
     }
+    
+    @Test
+    public void testRetryAfterException() throws Exception {
+        checkInitialState();
+        
+        final AtomicInteger counter = new AtomicInteger();
+        
+        // use a notify to know when the message is done
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(4).create();
+
+        // use mock during testing as well
+        getMockEndpoint("mock:a").expectedMessageCount(4);
+        // there should be 1 duplicate
+        getMockEndpoint("mock:b").expectedMessageCount(4);
+        getMockEndpoint("mock:b").whenAnyExchangeReceived(new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                if (counter.getAndIncrement() == 1) {
+                    throw new ConnectException("Forced cannot send to AMQ queue");
+                }
+            }
+        });
+
+        template.sendBodyAndHeader("activemq:queue:inbox", "D", "uid", 111);
+        template.sendBodyAndHeader("activemq:queue:inbox", "E", "uid", 222);
+        template.sendBodyAndHeader("activemq:queue:inbox", "F", "uid", 333);
+
+        // assert mock and wait for the message to be done
+        assertMockEndpointsSatisfied();
+        assertTrue("Should complete 4 messages", notify.matchesMockWaitTime());
+
+        // check that there is two messages in the database and JMS queue
+        assertEquals(3, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
+        assertEquals("DONE-D", consumer.receiveBody("activemq:queue:outbox", 3000));
+        assertEquals("DONE-E", consumer.receiveBody("activemq:queue:outbox", 3000));
+        assertEquals("DONE-F", consumer.receiveBody("activemq:queue:outbox", 3000));
+    }
+    
+    private void checkInitialState() {
+        // check there are no messages in the database and JMS queue
+        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from  CAMEL_MESSAGEPROCESSED"));
+        assertNull(consumer.receiveBody("activemq:queue:outbox", 2000));
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
+            @SuppressWarnings("unchecked")
             @Override
             public void configure() throws Exception {
-                repository = context.getRegistry().lookup("messageIdRepository", IdempotentRepository.class);
+                IdempotentRepository<String> repository = context.getRegistry().lookup("messageIdRepository",
IdempotentRepository.class);
 
                 from("activemq:queue:inbox")
                     .transacted("required")

Modified: camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml?rev=1102080&r1=1102079&r2=1102080&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml
(original)
+++ camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml
Wed May 11 20:35:10 2011
@@ -26,49 +26,26 @@
 
     <!-- jdbc idempotent repository -->
     <bean id="messageIdRepository" class="org.apache.camel.processor.idempotent.jdbc.JdbcMessageIdRepository">
-        <constructor-arg index="0" ref="myDataSource"/>
-        <constructor-arg index="1" ref="requiredTemplate"/>
-        <constructor-arg index="2" value="myProcessor"/>
+        <constructor-arg index="0" ref="dataSource"/>
+        <constructor-arg index="1" value="myProcessor"/>
     </bean>
 
     <!-- use required TX -->
     <bean id="requiredTemplate" class="org.springframework.transaction.support.TransactionTemplate">
-        <property name="transactionManager" ref="jtaTransactionManager"/>
+        <property name="transactionManager" ref="jmsTransactionManager"/>
     </bean>
     <bean id="required" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
         <property name="transactionTemplate" ref="requiredTemplate"/>
     </bean>
 
-    <!-- setup Atomikos for XA transaction -->
-    <bean id="atomikosTransactionManager"
-          class="com.atomikos.icatch.jta.UserTransactionManager"
-          init-method="init" destroy-method="close" depends-on="my-broker">
-        <!-- when close is called, should we force transactions to terminate or not? -->
-        <property name="forceShutdown" value="false"/>
-    </bean>
-
-    <!-- this is some atomikos setup you must do -->
-    <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"
depends-on="my-broker">
-        <property name="transactionTimeout" value="300"/>
-    </bean>
-
-    <!-- this is some atomikos setup you must do -->
-    <bean id="connectionFactory"
-          class="com.atomikos.jms.AtomikosConnectionFactoryBean" depends-on="my-broker">
-        <property name="uniqueResourceName" value="myUniqueResource"/>
-        <property name="xaConnectionFactory" ref="jmsXaConnectionFactory"/>
-    </bean>
-
-    <!-- this is the Spring JtaTransactionManager which under the hood uses Atomikos -->
-    <bean id="jtaTransactionManager"
-          class="org.springframework.transaction.jta.JtaTransactionManager" depends-on="my-broker">
-        <property name="transactionManager" ref="atomikosTransactionManager"/>
-        <property name="userTransaction" ref="atomikosUserTransaction"/>
+    <!-- this is the Spring JmsTransactionManager which under the hood uses Atomikos -->
+    <bean id="jmsTransactionManager"
+          class="org.springframework.jms.connection.JmsTransactionManager" depends-on="my-broker">
+        <property name="connectionFactory" ref="jmsConnectionFactory"/>
     </bean>
 
     <!-- Is the ConnectionFactory to connect to the JMS broker -->
-    <!-- notice how we must use the XA connection factory -->
-    <bean id="jmsXaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory"
depends-on="my-broker">
+    <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
depends-on="my-broker">
         <property name="brokerURL" value="tcp://localhost:61616"/>
     </bean>
 
@@ -77,7 +54,7 @@
         <!-- must indicate that we use transacted acknowledge mode -->
         <property name="transacted" value="true"/>
         <!-- refer to the transaction manager -->
-        <property name="transactionManager" ref="jtaTransactionManager"/>
+        <property name="transactionManager" ref="jmsTransactionManager"/>
     </bean>
 
     <!-- setup a local JMS Broker for testing purpose -->
@@ -87,24 +64,11 @@
         </broker:transportConnectors>
     </broker:broker>
 
-    <!-- define the datasource to the database - in this example we use an in memory database
using HSQLDB -->
-    <!-- HSQLDB is not XA compatible so we wrap that using a special Atomikos NonXA to
XA DataSource -->
-    <bean id="myDataSource" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
-        <property name="uniqueResourceName" value="hsqldb"/>
-        <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
-        <property name="url" value="jdbc:hsqldb:mem:mydatabase"/>
-        <property name="user" value="sa"/>
-        <property name="password" value=""/>
-        <property name="poolSize" value="3"/>
-    </bean>
-
     <!-- datasource used to create the database tables -->
-    <bean id="myNonXADataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
+    <bean id="dataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
destroy-method="destroy">
         <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
         <property name="url" value="jdbc:hsqldb:mem:mydatabase"/>
         <property name="username" value="sa"/>
         <property name="password" value=""/>
     </bean>
-
-</beans>
-
+</beans>
\ No newline at end of file

Copied: camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml
(from r1101929, camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml?p2=camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml&p1=camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml&r1=1101929&r2=1102080&rev=1102080&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml
(original)
+++ camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml
Wed May 11 20:35:10 2011
@@ -54,7 +54,8 @@
 
     <!-- this is some atomikos setup you must do -->
     <bean id="connectionFactory"
-          class="com.atomikos.jms.AtomikosConnectionFactoryBean" depends-on="my-broker">
+          class="com.atomikos.jms.AtomikosConnectionFactoryBean"
+          init-method="init" destroy-method="close" depends-on="my-broker">
         <property name="uniqueResourceName" value="myUniqueResource"/>
         <property name="xaConnectionFactory" ref="jmsXaConnectionFactory"/>
     </bean>
@@ -89,7 +90,7 @@
 
     <!-- define the datasource to the database - in this example we use an in memory database
using HSQLDB -->
     <!-- HSQLDB is not XA compatible so we wrap that using a special Atomikos NonXA to
XA DataSource -->
-    <bean id="myDataSource" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
+    <bean id="myDataSource" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean"
destroy-method="close">
         <property name="uniqueResourceName" value="hsqldb"/>
         <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
         <property name="url" value="jdbc:hsqldb:mem:mydatabase"/>
@@ -99,12 +100,10 @@
     </bean>
 
     <!-- datasource used to create the database tables -->
-    <bean id="myNonXADataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
+    <bean id="myNonXADataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
destroy-method="destroy">
         <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
         <property name="url" value="jdbc:hsqldb:mem:mydatabase"/>
         <property name="username" value="sa"/>
         <property name="password" value=""/>
     </bean>
-
-</beans>
-
+</beans>
\ No newline at end of file

Added: camel/trunk/tests/camel-itest/src/test/resources/transactions.properties
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/resources/transactions.properties?rev=1102080&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/resources/transactions.properties (added)
+++ camel/trunk/tests/camel-itest/src/test/resources/transactions.properties Wed May 11 20:35:10
2011
@@ -0,0 +1,43 @@
+#
+#
+#    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.
+#
+#
+############################################################
+
+com.atomikos.icatch.console_file_name = tm.out
+com.atomikos.icatch.console_file_count = 1
+com.atomikos.icatch.automatic_resource_registration = true
+com.atomikos.icatch.client_demarcation = false
+com.atomikos.icatch.threaded_2pc = true
+com.atomikos.icatch.serial_jta_transactions = true
+com.atomikos.icatch.log_base_dir = ./target/
+com.atomikos.icatch.console_log_level = WARN
+com.atomikos.icatch.max_actives = 50
+com.atomikos.icatch.checkpoint_interval = 500
+com.atomikos.icatch.enable_logging = true
+com.atomikos.icatch.output_dir = ./target/
+com.atomikos.icatch.log_base_name = tmlog
+com.atomikos.icatch.console_file_limit = -1
+com.atomikos.icatch.max_timeout = 300000
+com.atomikos.icatch.tm_unique_name = camel-itest
+java.naming.factory.initial = com.sun.jndi.rmi.registry.RegistryContextFactory
+java.naming.provider.url = rmi://localhost:1099
+com.atomikos.icatch.service = com.atomikos.icatch.standalone.UserTransactionServiceFactory
+com.atomikos.icatch.force_shutdown_on_vm_exit = false
+com.atomikos.icatch.default_jta_timeout = 10000
\ No newline at end of file



Mime
View raw message