You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2010/06/11 17:14:47 UTC

svn commit: r953720 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test: TransactionTest.cpp TransactionTest.h openwire/OpenwireTransactionTest.h

Author: tabish
Date: Fri Jun 11 15:14:47 2010
New Revision: 953720

URL: http://svn.apache.org/viewvc?rev=953720&view=rev
Log:
Add an additional transaction test

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp?rev=953720&r1=953719&r2=953720&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp Fri Jun 11 15:14:47 2010
@@ -122,6 +122,47 @@ void TransactionTest::testSendRollback()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void TransactionTest::testSendRollbackCommitRollback() {
+
+    // Create CMS Object for Comms
+    cms::Session* session = cmsProvider->getSession();
+    cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+    cms::MessageProducer* producer = cmsProvider->getProducer();
+
+    producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+    auto_ptr<TextMessage> outbound1( session->createTextMessage( "First Message" ) );
+    auto_ptr<TextMessage> outbound2( session->createTextMessage( "Second Message" ) );
+
+    // sends them and then rolls back.
+    producer->send( outbound1.get() );
+    producer->send( outbound2.get() );
+    session->rollback();
+
+    // Send one and commit.
+    producer->send( outbound1.get() );
+    session->commit();
+
+    // receives the first message
+    auto_ptr<TextMessage> inbound1(
+        dynamic_cast<TextMessage*>( consumer->receive( 1500 ) ) );
+
+    CPPUNIT_ASSERT( NULL == consumer->receive( 1500 ) );
+    CPPUNIT_ASSERT( outbound1->getText() == inbound1->getText() );
+
+    session->rollback();
+
+    inbound1.reset(
+        dynamic_cast<TextMessage*>( consumer->receive( 1500 ) ) );
+
+    CPPUNIT_ASSERT( NULL == consumer->receive( 1500 ) );
+    CPPUNIT_ASSERT( outbound1->getText() == inbound1->getText() );
+
+    // validates that the rollbacked was not consumed
+    session->commit();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void TransactionTest::testSendSessionClose() {
 
     try {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h?rev=953720&r1=953719&r2=953720&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h Fri Jun 11 15:14:47 2010
@@ -44,6 +44,7 @@ namespace test{
         void testSendRollback();
         void testSendSessionClose();
         void testWithTTLSet();
+        void testSendRollbackCommitRollback();
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h?rev=953720&r1=953719&r2=953720&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h Fri Jun 11 15:14:47 2010
@@ -30,6 +30,7 @@ namespace openwire{
         CPPUNIT_TEST( testSendReceiveTransactedBatches );
         CPPUNIT_TEST( testSendRollback );
         CPPUNIT_TEST( testWithTTLSet );
+        CPPUNIT_TEST( testSendRollbackCommitRollback );
 //        CPPUNIT_TEST( testSendSessionClose );
         CPPUNIT_TEST_SUITE_END();