You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by nm...@apache.org on 2007/03/18 14:02:03 UTC

svn commit: r519608 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector: openwire/OpenwireSimpleTest.cpp openwire/OpenwireSimpleTest.h stomp/SimpleTest.cpp stomp/SimpleTest.h

Author: nmittler
Date: Sun Mar 18 06:02:02 2007
New Revision: 519608

URL: http://svn.apache.org/viewvc?view=rev&rev=519608
Log:
AMQCPP-84 - adding more tests to openwire simpleTest

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.cpp?view=diff&rev=519608&r1=519607&r2=519608
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.cpp Sun Mar 18 06:02:02 2007
@@ -30,6 +30,7 @@
 #include <activemq/transport/TransportFactory.h>
 #include <activemq/network/Socket.h>
 #include <activemq/exceptions/NullPointerException.h>
+#include <activemq/core/ActiveMQConnectionFactory.h>
 #include <activemq/core/ActiveMQConnection.h>
 #include <activemq/core/ActiveMQConsumer.h>
 #include <activemq/core/ActiveMQProducer.h>
@@ -129,7 +130,6 @@
         delete topic;
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )
 }
 
 void OpenwireSimpleTest::testClientAck()
@@ -183,6 +183,228 @@
         delete topic;
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )
 }
 
+void OpenwireSimpleTest::testProducerWithNullDestination()
+{
+    try
+    {
+        TestSupport testSupport("tcp://localhost:61616?wireFormat=openwire", cms::Session::CLIENT_ACKNOWLEDGE );
+        testSupport.initialize();
+        
+        if( IntegrationCommon::debug ) {
+            cout << "Starting activemqcms test (sending "
+                 << IntegrationCommon::defaultMsgCount
+                 << " messages per type and sleeping "
+                 << IntegrationCommon::defaultDelay 
+                 << " milli-seconds) ...\n"
+                 << endl;
+        }
+        
+        // Create CMS Object for Comms
+        cms::Session* session = testSupport.getSession();
+        cms::Topic* topic = session->createTopic(Guid::createGUIDString());
+        cms::MessageConsumer* consumer =  session->createConsumer( topic );            
+        consumer->setMessageListener( &testSupport );
+        cms::MessageProducer* producer = session->createProducer( NULL );
+
+        cms::TextMessage* textMsg = session->createTextMessage();
+        
+        // Send some text messages
+        producer->send( topic, textMsg );
+        
+        delete textMsg;
+
+        // Wait for the messages to get here
+        testSupport.waitForMessages( 1 );
+        
+        unsigned int numReceived = testSupport.getNumReceived();
+        if( IntegrationCommon::debug ) {
+            printf("received: %d\n", numReceived );
+        }
+        CPPUNIT_ASSERT_EQUAL( 1, (int)numReceived );
+
+        if( IntegrationCommon::debug ) {
+            printf("Shutting Down\n" );
+        }
+        delete producer;                      
+        delete consumer;
+        delete topic;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+}
+
+void OpenwireSimpleTest::testSyncReceive()
+{
+    try
+    {
+        TestSupport testSupport("tcp://localhost:61616?wireFormat=openwire", cms::Session::CLIENT_ACKNOWLEDGE );
+        testSupport.initialize();
+        
+        if( IntegrationCommon::debug ) {
+            cout << "Starting activemqcms test (sending "
+                 << IntegrationCommon::defaultMsgCount
+                 << " messages per type and sleeping "
+                 << IntegrationCommon::defaultDelay 
+                 << " milli-seconds) ...\n"
+                 << endl;
+        }
+        
+        // Create CMS Object for Comms
+        cms::Session* session = testSupport.getSession();
+        cms::Topic* topic = session->createTopic(Guid::createGUIDString());
+        cms::MessageConsumer* consumer = session->createConsumer( topic );
+        cms::MessageProducer* producer = session->createProducer( topic );
+
+        cms::TextMessage* textMsg = session->createTextMessage();
+        
+        // Send some text messages
+        producer->send( textMsg );
+        
+        delete textMsg;
+
+        cms::Message* message = consumer->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+
+        if( IntegrationCommon::debug ) {
+            printf("Shutting Down\n" );
+        }
+        delete producer;                      
+        delete consumer;
+        delete topic;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+}
+
+void OpenwireSimpleTest::testMultipleConnections()
+{
+    try
+    {
+        
+        if( IntegrationCommon::debug ) {
+            cout << "Starting activemqcms test (sending "
+                 << IntegrationCommon::defaultMsgCount
+                 << " messages per type and sleeping "
+                 << IntegrationCommon::defaultDelay 
+                 << " milli-seconds) ...\n"
+                 << endl;
+        }
+        
+        // Create CMS Object for Comms
+        cms::ConnectionFactory* factory = new ActiveMQConnectionFactory("tcp://localhost:61616?wireFormat=openwire");
+        cms::Connection* connection1 = factory->createConnection();
+        connection1->start();
+        
+        cms::Connection* connection2 = factory->createConnection();
+        connection2->start();
+        
+        CPPUNIT_ASSERT( connection1->getClientID() != connection2->getClientID() );
+        
+        cms::Session* session1 = connection1->createSession();
+        cms::Session* session2 = connection2->createSession();
+        
+        cms::Topic* topic = session1->createTopic(Guid::createGUIDString());
+        
+        
+        cms::MessageConsumer* consumer1 = session1->createConsumer( topic );
+        cms::MessageConsumer* consumer2 = session2->createConsumer( topic );
+        
+        cms::MessageProducer* producer = session2->createProducer( topic );
+
+        cms::TextMessage* textMsg = session2->createTextMessage();
+        
+        // Send some text messages
+        producer->send( textMsg );
+        
+        delete textMsg;
+
+        cms::Message* message = consumer1->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+        
+        message = consumer2->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+
+        if( IntegrationCommon::debug ) {
+            printf("Shutting Down\n" );
+        }
+        
+        connection1->close();
+        connection2->close();
+        
+        delete producer;                      
+        delete consumer1;
+        delete consumer2;
+        delete topic;
+        delete session1;
+        delete session2;
+        delete connection1;
+        delete connection2;
+        delete factory;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+}
+
+void OpenwireSimpleTest::testMultipleSessions()
+{
+    try
+    {
+        
+        if( IntegrationCommon::debug ) {
+            cout << "Starting activemqcms test (sending "
+                 << IntegrationCommon::defaultMsgCount
+                 << " messages per type and sleeping "
+                 << IntegrationCommon::defaultDelay 
+                 << " milli-seconds) ...\n"
+                 << endl;
+        }
+        
+        // Create CMS Object for Comms
+        cms::ConnectionFactory* factory = new ActiveMQConnectionFactory("tcp://localhost:61616?wireFormat=openwire");
+        cms::Connection* connection = factory->createConnection();
+        connection->start();
+        
+        cms::Session* session1 = connection->createSession();
+        cms::Session* session2 = connection->createSession();
+        
+        cms::Topic* topic = session1->createTopic(Guid::createGUIDString());
+        
+        cms::MessageConsumer* consumer1 = session1->createConsumer( topic );
+        cms::MessageConsumer* consumer2 = session2->createConsumer( topic );
+        
+        cms::MessageProducer* producer = session2->createProducer( topic );
+
+        cms::TextMessage* textMsg = session2->createTextMessage();
+        
+        // Send some text messages
+        producer->send( textMsg );
+        
+        delete textMsg;
+
+        cms::Message* message = consumer1->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+        
+        message = consumer2->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+
+        if( IntegrationCommon::debug ) {
+            printf("Shutting Down\n" );
+        }
+        
+        connection->close();
+        
+        delete producer;                      
+        delete consumer1;
+        delete consumer2;
+        delete topic;
+        delete session1;
+        delete session2;
+        delete connection;
+        delete factory;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.h?view=diff&rev=519608&r1=519607&r2=519608
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleTest.h Sun Mar 18 06:02:02 2007
@@ -32,6 +32,10 @@
         CPPUNIT_TEST_SUITE( OpenwireSimpleTest );
         CPPUNIT_TEST( testAutoAck );
         CPPUNIT_TEST( testClientAck );
+        CPPUNIT_TEST( testProducerWithNullDestination );
+        CPPUNIT_TEST( testSyncReceive );
+        CPPUNIT_TEST( testMultipleConnections );
+        CPPUNIT_TEST( testMultipleSessions );
         CPPUNIT_TEST_SUITE_END();
         
     public:
@@ -41,7 +45,10 @@
 
         virtual void testAutoAck();
         virtual void testClientAck();
-
+        virtual void testProducerWithNullDestination();
+        virtual void testSyncReceive();
+        virtual void testMultipleConnections();
+        virtual void testMultipleSessions();
     };
 
 }}}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.cpp?view=diff&rev=519608&r1=519607&r2=519608
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.cpp Sun Mar 18 06:02:02 2007
@@ -30,6 +30,7 @@
 #include <activemq/transport/TransportFactory.h>
 #include <activemq/network/Socket.h>
 #include <activemq/exceptions/NullPointerException.h>
+#include <activemq/core/ActiveMQConnectionFactory.h>
 #include <activemq/core/ActiveMQConnection.h>
 #include <activemq/core/ActiveMQConsumer.h>
 #include <activemq/core/ActiveMQProducer.h>
@@ -129,7 +130,6 @@
         delete topic;
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )
 }
 
 void SimpleTest::testClientAck()
@@ -183,6 +183,229 @@
         delete topic;
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+void SimpleTest::testProducerWithNullDestination()
+{
+    try
+    {
+        TestSupport testSupport("tcp://localhost:61613?wireFormat=stomp", cms::Session::CLIENT_ACKNOWLEDGE );
+        testSupport.initialize();
+        
+        if( IntegrationCommon::debug ) {
+            cout << "Starting activemqcms test (sending "
+                 << IntegrationCommon::defaultMsgCount
+                 << " messages per type and sleeping "
+                 << IntegrationCommon::defaultDelay 
+                 << " milli-seconds) ...\n"
+                 << endl;
+        }
+        
+        // Create CMS Object for Comms
+        cms::Session* session = testSupport.getSession();
+        cms::Topic* topic = session->createTopic(Guid::createGUIDString());
+        cms::MessageConsumer* consumer =  session->createConsumer( topic );            
+        consumer->setMessageListener( &testSupport );
+        cms::MessageProducer* producer = session->createProducer( NULL );
+
+        cms::TextMessage* textMsg = session->createTextMessage();
+        
+        // Send some text messages
+        producer->send( topic, textMsg );
+        
+        delete textMsg;
+
+        // Wait for the messages to get here
+        testSupport.waitForMessages( 1 );
+        
+        unsigned int numReceived = testSupport.getNumReceived();
+        if( IntegrationCommon::debug ) {
+            printf("received: %d\n", numReceived );
+        }
+        CPPUNIT_ASSERT_EQUAL( 1, (int)numReceived );
+
+        if( IntegrationCommon::debug ) {
+            printf("Shutting Down\n" );
+        }
+        delete producer;                      
+        delete consumer;
+        delete topic;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+}
+
+void SimpleTest::testSyncReceive()
+{
+    try
+    {
+        TestSupport testSupport("tcp://localhost:61613?wireFormat=stomp", cms::Session::CLIENT_ACKNOWLEDGE );
+        testSupport.initialize();
+        
+        if( IntegrationCommon::debug ) {
+            cout << "Starting activemqcms test (sending "
+                 << IntegrationCommon::defaultMsgCount
+                 << " messages per type and sleeping "
+                 << IntegrationCommon::defaultDelay 
+                 << " milli-seconds) ...\n"
+                 << endl;
+        }
+        
+        // Create CMS Object for Comms
+        cms::Session* session = testSupport.getSession();
+        cms::Topic* topic = session->createTopic(Guid::createGUIDString());
+        cms::MessageConsumer* consumer = session->createConsumer( topic );
+        cms::MessageProducer* producer = session->createProducer( topic );
+
+        cms::TextMessage* textMsg = session->createTextMessage();
+        
+        // Send some text messages
+        producer->send( textMsg );
+        
+        delete textMsg;
+
+        cms::Message* message = consumer->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+
+        if( IntegrationCommon::debug ) {
+            printf("Shutting Down\n" );
+        }
+        delete producer;                      
+        delete consumer;
+        delete topic;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+}
+
+void SimpleTest::testMultipleConnections()
+{
+    try
+    {
+        
+        if( IntegrationCommon::debug ) {
+            cout << "Starting activemqcms test (sending "
+                 << IntegrationCommon::defaultMsgCount
+                 << " messages per type and sleeping "
+                 << IntegrationCommon::defaultDelay 
+                 << " milli-seconds) ...\n"
+                 << endl;
+        }
+        
+        // Create CMS Object for Comms
+        cms::ConnectionFactory* factory = new ActiveMQConnectionFactory("tcp://localhost:61613?wireFormat=stomp");
+        cms::Connection* connection1 = factory->createConnection();
+        connection1->start();
+        
+        cms::Connection* connection2 = factory->createConnection();
+        connection2->start();
+        
+        CPPUNIT_ASSERT( connection1->getClientID() != connection2->getClientID() );
+        
+        cms::Session* session1 = connection1->createSession();
+        cms::Session* session2 = connection2->createSession();
+        
+        cms::Topic* topic = session1->createTopic(Guid::createGUIDString());
+        
+        
+        cms::MessageConsumer* consumer1 = session1->createConsumer( topic );
+        cms::MessageConsumer* consumer2 = session2->createConsumer( topic );
+        
+        cms::MessageProducer* producer = session2->createProducer( topic );
+
+        cms::TextMessage* textMsg = session2->createTextMessage();
+        
+        // Send some text messages
+        producer->send( textMsg );
+        
+        delete textMsg;
+
+        cms::Message* message = consumer1->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+        
+        message = consumer2->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+
+        if( IntegrationCommon::debug ) {
+            printf("Shutting Down\n" );
+        }
+        
+        connection1->close();
+        connection2->close();
+        
+        delete producer;                      
+        delete consumer1;
+        delete consumer2;
+        delete topic;
+        delete session1;
+        delete session2;
+        delete connection1;
+        delete connection2;
+        delete factory;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+}
+
+void SimpleTest::testMultipleSessions()
+{
+    try
+    {
+        
+        if( IntegrationCommon::debug ) {
+            cout << "Starting activemqcms test (sending "
+                 << IntegrationCommon::defaultMsgCount
+                 << " messages per type and sleeping "
+                 << IntegrationCommon::defaultDelay 
+                 << " milli-seconds) ...\n"
+                 << endl;
+        }
+        
+        // Create CMS Object for Comms
+        cms::ConnectionFactory* factory = new ActiveMQConnectionFactory("tcp://localhost:61613?wireFormat=stomp");
+        cms::Connection* connection = factory->createConnection();
+        connection->start();
+        
+        cms::Session* session1 = connection->createSession();
+        cms::Session* session2 = connection->createSession();
+        
+        cms::Topic* topic = session1->createTopic(Guid::createGUIDString());
+        
+        cms::MessageConsumer* consumer1 = session1->createConsumer( topic );
+        cms::MessageConsumer* consumer2 = session2->createConsumer( topic );
+        
+        cms::MessageProducer* producer = session2->createProducer( topic );
+
+        cms::TextMessage* textMsg = session2->createTextMessage();
+        
+        // Send some text messages
+        producer->send( textMsg );
+        
+        delete textMsg;
+
+        cms::Message* message = consumer1->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+        
+        message = consumer2->receive(1000);
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+
+        if( IntegrationCommon::debug ) {
+            printf("Shutting Down\n" );
+        }
+        
+        connection->close();
+        
+        delete producer;                      
+        delete consumer1;
+        delete consumer2;
+        delete topic;
+        delete session1;
+        delete session2;
+        delete connection;
+        delete factory;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
 }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.h?view=diff&rev=519608&r1=519607&r2=519608
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleTest.h Sun Mar 18 06:02:02 2007
@@ -32,6 +32,10 @@
         CPPUNIT_TEST_SUITE( SimpleTest );
         CPPUNIT_TEST( testAutoAck );
         CPPUNIT_TEST( testClientAck );
+        CPPUNIT_TEST( testProducerWithNullDestination );
+        CPPUNIT_TEST( testSyncReceive );
+        CPPUNIT_TEST( testMultipleConnections );
+        CPPUNIT_TEST( testMultipleSessions );
         CPPUNIT_TEST_SUITE_END();
         
     public:
@@ -41,6 +45,10 @@
 
         virtual void testAutoAck();
         virtual void testClientAck();
+        virtual void testProducerWithNullDestination();
+        virtual void testSyncReceive();
+        virtual void testMultipleConnections();
+        virtual void testMultipleSessions();
 
     };