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 2008/11/26 17:46:59 UTC
svn commit: r720916 - in
/activemq/activemq-cpp/trunk/src/test-integration/integration:
TestSupport.cpp TestSupport.h connector/openwire/OpenwireTransactionTest.cpp
connector/openwire/OpenwireTransactionTest.h
Author: tabish
Date: Wed Nov 26 08:46:58 2008
New Revision: 720916
URL: http://svn.apache.org/viewvc?rev=720916&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-209
Start of rewrite for Openwire Transaction Tests.
Modified:
activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.cpp
activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.h
activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.cpp
activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.h
Modified: activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.cpp?rev=720916&r1=720915&r2=720916&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.cpp Wed Nov 26 08:46:58 2008
@@ -84,10 +84,8 @@
// Set ourself as a recipient of Exceptions
connection->setExceptionListener( this );
+ reconnectSession();
connection->start();
-
- // Create a Session
- session = connection->createSession( ackMode );
}
AMQ_CATCH_RETHROW( activemq::exceptions::ActiveMQException )
AMQ_CATCHALL_THROW( activemq::exceptions::ActiveMQException )
@@ -275,3 +273,24 @@
}
}
+
+////////////////////////////////////////////////////////////////////////////////
+void TestSupport::reconnect() {
+ if( connection != NULL ) {
+ connection->close();
+ delete connection;
+ }
+
+ this->initialize( this->brokerUrl, this->ackMode );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TestSupport::reconnectSession() {
+
+ if (session != NULL) {
+ session->close();
+ delete session;
+ }
+
+ session = connection->createSession( this->ackMode );
+}
Modified: activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.h?rev=720916&r1=720915&r2=720916&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.h (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/integration/TestSupport.h Wed Nov 26 08:46:58 2008
@@ -89,6 +89,9 @@
const std::string& password,
const std::string& clientId );
+ virtual void reconnect();
+ virtual void reconnectSession();
+
public:
std::string brokerUrl;
Modified: activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.cpp?rev=720916&r1=720915&r2=720916&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.cpp Wed Nov 26 08:46:58 2008
@@ -155,7 +155,9 @@
session->commit();
// sends a message that gets rollbacked
- producer->send( session->createTextMessage( "I'm going to get rolled back." ) );
+ auto_ptr<Message> rollback(
+ session->createTextMessage( "I'm going to get rolled back." ) );
+ producer->send( rollback.get() );
session->rollback();
// sends a message
@@ -179,3 +181,62 @@
AMQ_CATCH_RETHROW( ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenwireTransactionTest::testSendSessionClose() {
+
+ try{
+
+ // Create CMS Object for Comms, this one is owned by the TestSupport
+ // class.
+ cms::Session* session = testSupport->getSession();
+
+ auto_ptr<cms::Topic> topic( session->createTopic("MYTOPIC") );
+ auto_ptr<cms::MessageConsumer> consumer( session->createConsumer( topic.get() ) );
+ auto_ptr<cms::MessageProducer> producer( session->createProducer( topic.get() ) );
+ producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+ auto_ptr<TextMessage> outbound1( session->createTextMessage( "First Message" ) );
+ auto_ptr<TextMessage> outbound2( session->createTextMessage( "Second Message" ) );
+
+ // sends a message
+ producer->send( outbound1.get() );
+ session->commit();
+
+ // sends a message that gets rollbacked
+ auto_ptr<Message> rollback(
+ session->createTextMessage( "I'm going to get rolled back." ) );
+ producer->send( rollback.get() );
+ consumer->close();
+
+ topic.reset( NULL );
+ consumer.reset( NULL );
+ producer.reset( NULL );
+ testSupport->reconnectSession();
+ session = testSupport->getSession();
+ topic.reset( session->createTopic("MYTOPIC") );
+ consumer.reset( session->createConsumer( topic.get() ) );
+ producer.reset( session->createProducer( topic.get() ) );
+ producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+ // sends a message
+ producer->send( outbound2.get() );
+ session->commit();
+
+ // receives the first message
+ auto_ptr<TextMessage> inbound1(
+ dynamic_cast<TextMessage*>( consumer->receive( 1500 ) ) );
+
+ // receives the second message
+ auto_ptr<TextMessage> inbound2(
+ dynamic_cast<TextMessage*>( consumer->receive( 4000 ) ) );
+
+ // validates that the rollbacked was not consumed
+ session->commit();
+
+ CPPUNIT_ASSERT( outbound1->getText() == inbound1->getText() );
+ CPPUNIT_ASSERT( outbound2->getText() == inbound2->getText() );
+ }
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
+}
Modified: activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.h?rev=720916&r1=720915&r2=720916&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.h (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/integration/connector/openwire/OpenwireTransactionTest.h Wed Nov 26 08:46:58 2008
@@ -32,6 +32,7 @@
CPPUNIT_TEST_SUITE( OpenwireTransactionTest );
CPPUNIT_TEST( testSendReceiveTransactedBatches );
CPPUNIT_TEST( testSendRollback );
+// CPPUNIT_TEST( testSendSessionClose );
CPPUNIT_TEST_SUITE_END();
private:
@@ -49,8 +50,9 @@
virtual void setUp();
virtual void tearDown();
- virtual void testSendReceiveTransactedBatches();
- virtual void testSendRollback();
+ void testSendReceiveTransactedBatches();
+ void testSendRollback();
+ void testSendSessionClose();
};