Author: bvahdat Date: Sat Dec 8 08:17:52 2012 New Revision: 1418620 URL: http://svn.apache.org/viewvc?rev=1418620&view=rev Log: Merged revisions 1418618 via svnmerge from https://svn.apache.org/repos/asf/camel/branches/camel-2.10.x
................ r1418618 | bvahdat | 2012-12-08 09:05:20 +0100 (Sa, 08 Dez 2012) | 9 lines Merged revisions 1418616 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk ........ r1418616 | bvahdat | 2012-12-08 08:53:20 +0100 (Sa, 08 Dez 2012) | 1 line CAMEL-5856: Fix and reenable the two JMS/JDBC Integration tests. ........ ................ Removed: camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/sql/init2.sql Modified: camel/branches/camel-2.9.x/ (props changed) camel/branches/camel-2.9.x/tests/camel-itest/pom.xml camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ Merged /camel/trunk:r1418616 Merged /camel/branches/camel-2.10.x:r1418618 Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.9.x/tests/camel-itest/pom.xml URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/tests/camel-itest/pom.xml?rev=1418620&r1=1418619&r2=1418620&view=diff ============================================================================== --- camel/branches/camel-2.9.x/tests/camel-itest/pom.xml (original) +++ camel/branches/camel-2.9.x/tests/camel-itest/pom.xml Sat Dec 8 08:17:52 2012 @@ -335,12 +335,6 @@ <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkMode>pertest</forkMode> - <excludes> - <!-- TODO FIXME ASAP --> - <exclude>**/XXXTest.*</exclude> - <exclude>**/FromJmsToJdbcIdempotentConsumerToJmsTest.*</exclude> - <exclude>**/FromJmsToJdbcIdempotentConsumerToJmsXaTest.*</exclude> - </excludes> <systemProperties> <property> <name>java.util.logging.config.file</name> @@ -350,6 +344,10 @@ <name>org.apache.activemq.default.directory.prefix</name> <value>target/</value> </property> + <property> + <name>derby.stream.error.file</name> + <value>target/derby.log</value> + </property> </systemProperties> </configuration> </plugin> Modified: camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java?rev=1418620&r1=1418619&r2=1418620&view=diff ============================================================================== --- camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java (original) +++ camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java Sat Dec 8 08:17:52 2012 @@ -51,11 +51,15 @@ public class FromJmsToJdbcIdempotentCons public void setUp() throws Exception { super.setUp(); - dataSource = context.getRegistry().lookup("myNonXADataSource", DataSource.class); + dataSource = context.getRegistry().lookup(getDatasourceName(), DataSource.class); jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.afterPropertiesSet(); } + protected String getDatasourceName() { + return "myNonXADataSource"; + } + @Test public void testJmsToJdbcJmsCommit() throws Exception { checkInitialState(); @@ -74,7 +78,7 @@ public class FromJmsToJdbcIdempotentCons assertTrue("Should complete 1 message", notify.matchesMockWaitTime()); // check that there is a message in the database and JMS queue - assertEquals(1, jdbcTemplate.queryForInt("select count(*) from CAMEL_MESSAGEPROCESSED")); + assertEquals(1, jdbcTemplate.queryForInt("select count(*) from CAMEL_MESSAGEPROCESSED")); Object out = consumer.receiveBody("activemq:queue:outbox", 3000); assertEquals("DONE-A", out); } @@ -86,6 +90,7 @@ public class FromJmsToJdbcIdempotentCons // use a notify to know that after 1+6 (1 original + 6 redelivery) attempts from AcitveMQ NotifyBuilder notify = new NotifyBuilder(context).whenDone(7).create(); + // TODO: occasionally we get only 6 instead of 7 expected exchanges which's most probably an issue in AcitveMQ itself getMockEndpoint("mock:a").expectedMessageCount(7); // force exception to occur at mock a getMockEndpoint("mock:a").whenAnyExchangeReceived(new Processor() { @@ -103,7 +108,7 @@ public class FromJmsToJdbcIdempotentCons assertTrue("Should complete 7 message", notify.matchesMockWaitTime()); // check that there is a message in the database and JMS queue - assertEquals(0, jdbcTemplate.queryForInt("select count(*) from CAMEL_MESSAGEPROCESSED")); + assertEquals(0, jdbcTemplate.queryForInt("select count(*) from CAMEL_MESSAGEPROCESSED")); assertNull(consumer.receiveBody("activemq:queue:outbox", 3000)); // the message should have been moved to the AMQ DLQ queue @@ -134,7 +139,7 @@ public class FromJmsToJdbcIdempotentCons assertTrue("Should complete 7 messages", notify.matchesMockWaitTime()); // check that there is a message in the database and JMS queue - assertEquals(0, jdbcTemplate.queryForInt("select count(*) from CAMEL_MESSAGEPROCESSED")); + assertEquals(0, jdbcTemplate.queryForInt("select count(*) from CAMEL_MESSAGEPROCESSED")); assertNull(consumer.receiveBody("activemq:queue:outbox", 3000)); // the message should have been moved to the AMQ DLQ queue @@ -162,17 +167,17 @@ public class FromJmsToJdbcIdempotentCons assertTrue("Should complete 3 messages", notify.matchesMockWaitTime()); // check that there is two messages in the database and JMS queue - assertEquals(2, jdbcTemplate.queryForInt("select count(*) from CAMEL_MESSAGEPROCESSED")); + assertEquals(2, 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)); } - + @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(); @@ -198,25 +203,24 @@ public class FromJmsToJdbcIdempotentCons 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(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)); } - + protected void checkInitialState() { // check there are no messages in the database and JMS queue - assertEquals(0, jdbcTemplate.queryForInt("select count(*) from CAMEL_MESSAGEPROCESSED")); + 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 { - IdempotentRepository<String> repository = context.getRegistry().lookup("messageIdRepository", IdempotentRepository.class); + IdempotentRepository<?> repository = context.getRegistry().lookup("messageIdRepository", IdempotentRepository.class); from("activemq:queue:inbox") .transacted("required") Modified: camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java?rev=1418620&r1=1418619&r2=1418620&view=diff ============================================================================== --- camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java (original) +++ camel/branches/camel-2.9.x/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.java Sat Dec 8 08:17:52 2012 @@ -16,15 +16,47 @@ */ package org.apache.camel.itest.sql; +import java.sql.DriverManager; +import java.sql.SQLException; + +import org.junit.After; +import org.junit.Before; + import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** - * Jms with JDBC idempotent consumer using XA test. + * Jms with JDBC idempotent consumer test using XA. */ public class FromJmsToJdbcIdempotentConsumerToJmsXaTest extends FromJmsToJdbcIdempotentConsumerToJmsTest { @Override + @Before + public void setUp() throws Exception { + deleteDirectory("target/testdb"); + + super.setUp(); + } + + @Override + @After + public void tearDown() throws Exception { + super.tearDown(); + + // shutdown the embedded Derby database so that the next test becomes a clean initial state + try { + DriverManager.getConnection("jdbc:derby:target/testdb;shutdown=true"); + } catch (SQLException e) { + // a successful shutdown always results in an SQLException to indicate that Derby has shut down and that there is no other exception. + } + } + + @Override + protected String getDatasourceName() { + return "myXADataSource"; + } + + @Override protected AbstractApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml"); } Modified: camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml?rev=1418620&r1=1418619&r2=1418620&view=diff ============================================================================== --- camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml (original) +++ camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.xml Sat Dec 8 08:17:52 2012 @@ -24,9 +24,9 @@ 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 http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd - http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd"> + http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> - <!-- jdbc idempotent repository --> + <!-- jdbc idempotent repository, per default creates the table CAMEL_MESSAGEPROCESSED if not already existing --> <bean id="messageIdRepository" class="org.apache.camel.processor.idempotent.jdbc.JdbcMessageIdRepository"> <constructor-arg index="0" ref="myNonXADataSource"/> <constructor-arg index="1" value="myProcessor"/> @@ -67,7 +67,5 @@ </broker:broker> <!-- datasource used to create the database tables --> - <jdbc:embedded-database id="myNonXADataSource" type="DERBY"> - <jdbc:script location="classpath:sql/init2.sql" /> - </jdbc:embedded-database> + <jdbc:embedded-database id="myNonXADataSource" type="DERBY"/> </beans> \ No newline at end of file Modified: camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml?rev=1418620&r1=1418619&r2=1418620&view=diff ============================================================================== --- camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml (original) +++ camel/branches/camel-2.9.x/tests/camel-itest/src/test/resources/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsXaTest.xml Sat Dec 8 08:17:52 2012 @@ -24,11 +24,11 @@ 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 http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd - http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd"> + http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> - <!-- jdbc idempotent repository --> + <!-- jdbc idempotent repository, per default creates the table CAMEL_MESSAGEPROCESSED if not already existing --> <bean id="messageIdRepository" class="org.apache.camel.processor.idempotent.jdbc.JdbcMessageIdRepository"> - <constructor-arg index="0" ref="myDataSource"/> + <constructor-arg index="0" ref="myXADataSource"/> <constructor-arg index="1" ref="requiredTemplate"/> <constructor-arg index="2" value="myProcessor"/> </bean> @@ -89,17 +89,10 @@ <broker:transportConnector uri="tcp://localhost:61616"/> </broker:transportConnectors> </broker:broker> - - <!-- datasource used to create the database tables --> - <jdbc:embedded-database id="myNonXADataSource" type="DERBY"> - <jdbc:script location="classpath:sql/init.sql" /> - </jdbc:embedded-database> - - <!-- define the datasource to the database - in this example we use an in memory database using Derby --> - <bean id="myDataSource" class="org.apache.derby.jdbc.EmbeddedXADataSource" depends-on="myNonXADataSource"> - <property name="databaseName" value="testdb"/> - <property name="createDatabase" value="true"/> - <property name="shutdownDatabase" value="true"/> + + <!-- XA datasource used to create the database tables --> + <bean id="myXADataSource" class="org.apache.derby.jdbc.EmbeddedXADataSource"> + <property name="databaseName" value="target/testdb;create=true"/> <property name="user" value="sa"/> <property name="password" value=""/> </bean>
