You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2013/10/25 13:51:08 UTC

git commit: Polished tests, corrected a typo by JmsConsumerShutdownTest#testSedaConsumerShutdownWithMessageInFlight, removed some deprecated API usage of JdbcTemplate. Also re-enabled 2 tests which seem to work again since the recent AMQ 5.9 upgrade.

Updated Branches:
  refs/heads/master c6f05fa09 -> e92aab5af


Polished tests, corrected a typo by JmsConsumerShutdownTest#testSedaConsumerShutdownWithMessageInFlight, removed some deprecated API usage of JdbcTemplate. Also re-enabled 2 tests which seem to work again since the recent AMQ 5.9 upgrade.

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e92aab5a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e92aab5a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e92aab5a

Branch: refs/heads/master
Commit: e92aab5aff3744210c191fba71f9e35fd35bb226
Parents: c6f05fa
Author: Babak Vahdat <bv...@apache.org>
Authored: Fri Oct 25 13:50:56 2013 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Fri Oct 25 13:50:56 2013 +0200

----------------------------------------------------------------------
 .../camel/itest/jms/JmsConsumerShutdownTest.java   | 12 ++++--------
 .../FromJmsToJdbcIdempotentConsumerToJmsTest.java  | 17 ++++++-----------
 2 files changed, 10 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e92aab5a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsConsumerShutdownTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsConsumerShutdownTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsConsumerShutdownTest.java
index e5aac72..9261272 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsConsumerShutdownTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsConsumerShutdownTest.java
@@ -43,12 +43,9 @@ public class JmsConsumerShutdownTest extends AbstractJUnit4SpringContextTests {
     @EndpointInject(uri = "mock:exception")
     protected MockEndpoint exception;
 
-    // Camel context will never shut down. Regardless of the settings in DefaultShutdownStrategy
-    // JmsConsumer does not correctly shut down direct subroutes
-    @Test(timeout = 20000)
+    @Test
     @DirtiesContext
     public void testJmsConsumerShutdownWithMessageInFlight() throws InterruptedException {
-
         end.expectedMessageCount(0);
         end.setResultWaitTime(2000);
 
@@ -65,11 +62,10 @@ public class JmsConsumerShutdownTest extends AbstractJUnit4SpringContextTests {
         end.assertIsSatisfied();
     }
 
-    // For comparison, SedaConsumer will correctly shut down direct subroutes
-    @Test(timeout = 20000)
+    // Just for the sake of comparison test the SedaConsumer as well
+    @Test
     @DirtiesContext
     public void testSedaConsumerShutdownWithMessageInFlight() throws InterruptedException {
-
         end.expectedMessageCount(0);
         end.setResultWaitTime(2000);
 
@@ -81,7 +77,7 @@ public class JmsConsumerShutdownTest extends AbstractJUnit4SpringContextTests {
             }
         });
 
-        seda.sendBody("activemq:start", "Hello");
+        seda.sendBody("seda:start", "Hello");
 
         end.assertIsSatisfied();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/e92aab5a/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
index bc8d4da..b67afe6 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/sql/FromJmsToJdbcIdempotentConsumerToJmsTest.java
@@ -28,7 +28,6 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spi.IdempotentRepository;
 import org.apache.camel.test.spring.CamelSpringTestSupport;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -79,12 +78,11 @@ public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSup
         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(new Integer(1), jdbcTemplate.queryForObject("select count(*) from CAMEL_MESSAGEPROCESSED", Integer.class));
         Object out = consumer.receiveBody("activemq:queue:outbox", 3000);
         assertEquals("DONE-A", out);
     }
 
-    @Ignore("see the TODO below")
     @Test
     public void testJmsToJdbcJmsRollbackAtA() throws Exception {
         checkInitialState();
@@ -92,7 +90,6 @@ public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSup
         // 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 ActiveMQ itself
         getMockEndpoint("mock:a").expectedMessageCount(7);
         // force exception to occur at mock a
         getMockEndpoint("mock:a").whenAnyExchangeReceived(new Processor() {
@@ -110,14 +107,13 @@ public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSup
         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(new Integer(0), jdbcTemplate.queryForObject("select count(*) from CAMEL_MESSAGEPROCESSED", Integer.class));
         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));
     }
 
-    @Ignore("see the TODO below")
     @Test
     public void testJmsToJdbcJmsRollbackAtB() throws Exception {
         checkInitialState();
@@ -125,7 +121,6 @@ public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSup
         // 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 ActiveMQ itself
         getMockEndpoint("mock:a").expectedMessageCount(7);
         getMockEndpoint("mock:b").expectedMessageCount(7);
         // force exception to occur at mock b
@@ -143,7 +138,7 @@ public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSup
         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(new Integer(0), jdbcTemplate.queryForObject("select count(*) from CAMEL_MESSAGEPROCESSED", Integer.class));
         assertNull(consumer.receiveBody("activemq:queue:outbox", 3000));
 
         // the message should have been moved to the AMQ DLQ queue
@@ -171,7 +166,7 @@ public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSup
         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(new Integer(2), jdbcTemplate.queryForObject("select count(*) from CAMEL_MESSAGEPROCESSED", Integer.class));
         assertEquals("DONE-D", consumer.receiveBody("activemq:queue:outbox", 3000));
         assertEquals("DONE-E", consumer.receiveBody("activemq:queue:outbox", 3000));
     }
@@ -207,7 +202,7 @@ public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSup
         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(new Integer(3), jdbcTemplate.queryForObject("select count(*) from CAMEL_MESSAGEPROCESSED", Integer.class));
         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));
@@ -215,7 +210,7 @@ public class FromJmsToJdbcIdempotentConsumerToJmsTest extends CamelSpringTestSup
 
     protected void checkInitialState() {
         // check there are no messages in the database and JMS queue
-        assertEquals(0, jdbcTemplate.queryForInt("select count(*) from CAMEL_MESSAGEPROCESSED"));
+        assertEquals(new Integer(0), jdbcTemplate.queryForObject("select count(*) from CAMEL_MESSAGEPROCESSED", Integer.class));
         assertNull(consumer.receiveBody("activemq:queue:outbox", 2000));
     }