activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [3/4] activemq-cpp git commit: https://issues.apache.org/jira/browse/AMQCPP-580 https://issues.apache.org/jira/browse/AMQCPP-552
Date Tue, 28 Jul 2015 20:56:19 GMT
https://issues.apache.org/jira/browse/AMQCPP-580
https://issues.apache.org/jira/browse/AMQCPP-552

Add more tests for these scenarios

Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/9a4abd61
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/9a4abd61
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/9a4abd61

Branch: refs/heads/master
Commit: 9a4abd619a73c1b1b4e9826c7981e8932b1bbb8d
Parents: e04676c
Author: Timothy Bish <tabish121@gmail.com>
Authored: Tue Jul 28 16:51:45 2015 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Tue Jul 28 16:51:45 2015 -0400

----------------------------------------------------------------------
 .../openwire/OpenWireRedeliveryPolicyTest.cpp   | 38 +++++++++++++-------
 .../openwire/OpenWireRedeliveryPolicyTest.h     | 11 +++---
 2 files changed, 31 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/9a4abd61/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.cpp
b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.cpp
index ba3a265..ff9fcda 100644
--- a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.cpp
+++ b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.cpp
@@ -82,6 +82,20 @@ void OpenWireRedeliveryPolicyTest::testGetNext() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void OpenWireRedeliveryPolicyTest::testGetNextWithInitialDelay() {
+
+    DefaultRedeliveryPolicy policy;
+    policy.setInitialRedeliveryDelay(500);
+
+    long long delay = policy.getNextRedeliveryDelay(500);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 1", 1000LL, delay);
+    delay = policy.getNextRedeliveryDelay(delay);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 2", 1000LL, delay);
+    delay = policy.getNextRedeliveryDelay(delay);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 3", 1000LL, delay);
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void OpenWireRedeliveryPolicyTest::testExponentialRedeliveryPolicyDelaysDeliveryOnRollback()
{
 
     Pointer<ActiveMQConnectionFactory> connectionFactory(
@@ -223,7 +237,8 @@ void OpenWireRedeliveryPolicyTest::testDLQHandling() {
     Pointer<MessageProducer> producer(session->createProducer(destination.get()));
     Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
     Pointer<Queue> dlq(session->createQueue("ActiveMQ.DLQ"));
-    Pointer<MessageConsumer> dlqConsumer(session->createConsumer(destination.get()));
+    amqConnection->destroyDestination(dlq.get());
+    Pointer<MessageConsumer> dlqConsumer(session->createConsumer(dlq.get()));
 
     // Send the messages
     Pointer<TextMessage> message1(session->createTextMessage("1st"));
@@ -362,7 +377,7 @@ void OpenWireRedeliveryPolicyTest::testMaximumRedeliveryDelay() {
     policy->setUseExponentialBackOff(true);
     policy->setMaximumRedeliveries(-1);
     policy->setRedeliveryDelay(50);
-    // TODO - policy->setMaximumRedeliveryDelay(1000);
+    policy->setMaximumRedeliveryDelay(1000);
     policy->setBackOffMultiplier((short) 2);
     policy->setUseExponentialBackOff(true);
 
@@ -403,8 +418,8 @@ void OpenWireRedeliveryPolicyTest::testMaximumRedeliveryDelay() {
     CPPUNIT_ASSERT_EQUAL(std::string("2nd"), textMessage->getText());
     session->commit();
 
-    CPPUNIT_ASSERT_MESSAGE("Max delay should be 1 second.",
-                           policy->getNextRedeliveryDelay(Long::MAX_VALUE) == 1000);
+    long long result = policy->getNextRedeliveryDelay(Integer::MAX_VALUE);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Max delay should be 1 second.", 1000LL, result);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -473,8 +488,8 @@ void OpenWireRedeliveryPolicyTest::testRepeatedRedeliveryReceiveNoCommit()
{
     producer->send(message1.get());
 
     const int MAX_REDELIVERIES = 4;
-    for (int i = 0; i <= MAX_REDELIVERIES + 1; i++) {
 
+    for (int i = 0; i <= MAX_REDELIVERIES + 1; i++) {
         Pointer<Connection> loopConnection(connectionFactory->createConnection());
         Pointer<ActiveMQConnection> amqConnection = loopConnection.dynamicCast<ActiveMQConnection>();
 
@@ -489,15 +504,16 @@ void OpenWireRedeliveryPolicyTest::testRepeatedRedeliveryReceiveNoCommit()
{
         Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
 
         Pointer<cms::Message> received(consumer->receive(1000));
-        Pointer<ActiveMQTextMessage> textMessage = received.dynamicCast<ActiveMQTextMessage>();
 
         if (i <= MAX_REDELIVERIES) {
+            Pointer<ActiveMQTextMessage> textMessage = received.dynamicCast<ActiveMQTextMessage>();
             CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery", textMessage != NULL);
             CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
             CPPUNIT_ASSERT_EQUAL(i, textMessage->getRedeliveryCounter());
         } else {
-            CPPUNIT_ASSERT_MESSAGE("null on exceeding redelivery count", textMessage == NULL);
+            CPPUNIT_ASSERT_MESSAGE("null on exceeding redelivery count", received == NULL);
         }
+
         loopConnection->close();
     }
 
@@ -512,10 +528,8 @@ void OpenWireRedeliveryPolicyTest::testRepeatedRedeliveryReceiveNoCommit()
{
         CPPUNIT_ASSERT_MESSAGE("cause exception has no policy ref",
                                cause.find("RedeliveryPolicy") != std::string::npos);
     } else {
-        //CPPUNIT_FAIL("Message did not have a rollback cause");
+        CPPUNIT_FAIL("Message did not have a rollback cause");
     }
-
-    dlqSession->commit();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -615,10 +629,8 @@ void OpenWireRedeliveryPolicyTest::testRepeatedRedeliveryOnMessageNoCommit()
{
         CPPUNIT_ASSERT_MESSAGE("cause exception has no policy ref",
                                cause.find("RedeliveryPolicy") != std::string::npos);
     } else {
-        //CPPUNIT_FAIL("Message did not have a rollback cause");
+        CPPUNIT_FAIL("Message did not have a rollback cause");
     }
-
-    dlqSession->commit();
 }
 
 ////////////////////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/9a4abd61/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.h
b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.h
index 207adc8..e85197a 100644
--- a/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.h
+++ b/activemq-cpp/src/test-integration/activemq/test/openwire/OpenWireRedeliveryPolicyTest.h
@@ -29,18 +29,18 @@ namespace openwire {
 
         CPPUNIT_TEST_SUITE( OpenWireRedeliveryPolicyTest );
         CPPUNIT_TEST( testGetNext );
+        CPPUNIT_TEST( testGetNextWithInitialDelay );
         CPPUNIT_TEST( testExponentialRedeliveryPolicyDelaysDeliveryOnRollback );
         CPPUNIT_TEST( testNornalRedeliveryPolicyDelaysDeliveryOnRollback );
-        // TODO CPPUNIT_TEST( testDLQHandling );
+        CPPUNIT_TEST( testDLQHandling );
         CPPUNIT_TEST( testInfiniteMaximumNumberOfRedeliveries );
         CPPUNIT_TEST( testZeroMaximumNumberOfRedeliveries );
-        // TODO CPPUNIT_TEST( testRepeatedRedeliveryReceiveNoCommit );
-        // TODO CPPUNIT_TEST( testRepeatedRedeliveryOnMessageNoCommit );
+        CPPUNIT_TEST( testRepeatedRedeliveryReceiveNoCommit );
+        CPPUNIT_TEST( testRepeatedRedeliveryOnMessageNoCommit );
         CPPUNIT_TEST( testInitialRedeliveryDelayZero );
         CPPUNIT_TEST( testInitialRedeliveryDelayOne );
         CPPUNIT_TEST( testRedeliveryDelayOne );
-        // TODO - We don't currently support this property.
-        // CPPUNIT_TEST( testMaximumRedeliveryDelay );
+        CPPUNIT_TEST( testMaximumRedeliveryDelay );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -54,6 +54,7 @@ namespace openwire {
         virtual std::string getBrokerURL() const;
 
         void testGetNext();
+        void testGetNextWithInitialDelay();
         void testExponentialRedeliveryPolicyDelaysDeliveryOnRollback();
         void testNornalRedeliveryPolicyDelaysDeliveryOnRollback();
         void testDLQHandling();


Mime
View raw message