activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r516895 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/cms/ test-integration/integration/ test-integration/integration/connector/stomp/
Date Sun, 11 Mar 2007 12:08:52 GMT
Author: nmittler
Date: Sun Mar 11 05:08:51 2007
New Revision: 516895

URL: http://svn.apache.org/viewvc?view=rev&rev=516895
Log:
adding integration test for client acknowledge

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp
    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/main/cms/CMSException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSException.h?view=diff&rev=516895&r1=516894&r2=516895
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSException.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSException.h Sun Mar 11 05:08:51
2007
@@ -45,6 +45,21 @@
         virtual std::string getMessage() const = 0;
         
         /**
+         * Adds a file/line number to the stack trace.
+         * @param file The name of the file calling this method (use __FILE__).
+         * @param lineNumber The line number in the calling file (use __LINE__).
+         */
+        virtual void setMark( const char* file, const int lineNumber ) = 0;
+        
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * @return Copy of this Exception object
+         */
+        virtual CMSException* clone() const = 0;
+        
+        /**
          * Provides the stack trace for every point where
          * this exception was caught, marked, and rethrown.
          * @return vector containing stack trace strings
@@ -61,6 +76,12 @@
          * @param stream the target output stream.
          */
         virtual void printStackTrace( std::ostream& stream ) const = 0;
+        
+        /**
+         * Gets the stack trace as one contiguous string.
+         * @return string with formatted stack trace data
+         */
+        virtual std::string getStackTraceString() const = 0;
         
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp?view=diff&rev=516895&r1=516894&r2=516895
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp
Sun Mar 11 05:08:51 2007
@@ -222,12 +222,19 @@
 
 void TestSupport::onException( const cms::CMSException& error )
 {
-    bool AbstractTester = false;
-    CPPUNIT_ASSERT( AbstractTester );
+    CPPUNIT_ASSERT_MESSAGE( error.getStackTraceString(), false );
 }
 
 void TestSupport::onMessage( const cms::Message* message )
 {
+    if( session->getAcknowledgeMode() == cms::Session::CLIENT_ACKNOWLEDGE ) {
+        try {
+            message->acknowledge();
+        } catch( CMSException& ex ) {
+            CPPUNIT_ASSERT_MESSAGE(ex.getStackTraceString(), false );
+        }
+    }
+    
     // Got a text message.
     const cms::TextMessage* txtMsg = 
         dynamic_cast<const cms::TextMessage*>(message);
@@ -247,7 +254,7 @@
         {
             mutex.notifyAll();
         }
-
+        
         return;
     }
     
@@ -272,7 +279,8 @@
         {
             mutex.notifyAll();
         }
-
+        
         return;
     }
+    
 }

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=516895&r1=516894&r2=516895
==============================================================================
--- 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 11 05:08:51 2007
@@ -73,20 +73,74 @@
 using namespace integration::connector::stomp;
 
 SimpleTest::SimpleTest()
-:
-    testSupport( "tcp://localhost:61613?wireFormat=stomp" )
 {
-    testSupport.initialize();
 }
 
 SimpleTest::~SimpleTest()
 {
 }
 
-void SimpleTest::test()
+void SimpleTest::testAutoAck()
 {
     try
     {
+        TestSupport testSupport("tcp://localhost:61613?wireFormat=stomp");
+        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("mytopic");
+        cms::MessageConsumer* consumer = 
+            session->createConsumer( topic );            
+        consumer->setMessageListener( &testSupport );
+        cms::MessageProducer* producer = 
+            session->createProducer( topic );
+
+        // Send some text messages
+        testSupport.produceTextMessages( 
+            *producer, IntegrationCommon::defaultMsgCount );
+        
+        // Send some bytes messages.
+        testSupport.produceTextMessages( 
+            *producer, IntegrationCommon::defaultMsgCount );
+
+        // Wait for the messages to get here
+        testSupport.waitForMessages( IntegrationCommon::defaultMsgCount * 2 );
+        
+        unsigned int numReceived = testSupport.getNumReceived();
+        if( IntegrationCommon::debug ) {
+            printf("received: %d\n", numReceived );
+        }
+        CPPUNIT_ASSERT( 
+            numReceived == IntegrationCommon::defaultMsgCount * 2 );
+
+        if( IntegrationCommon::debug ) {
+            printf("Shutting Down\n" );
+        }
+        delete producer;                      
+        delete consumer;
+        delete topic;
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+void SimpleTest::testClientAck()
+{
+    try
+    {
+        TestSupport testSupport("tcp://localhost:61613?wireFormat=stomp", cms::Session::CLIENT_ACKNOWLEDGE
);
+        testSupport.initialize();
+        
         if( IntegrationCommon::debug ) {
             cout << "Starting activemqcms test (sending "
                  << IntegrationCommon::defaultMsgCount

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=516895&r1=516894&r2=516895
==============================================================================
--- 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 11 05:08:51 2007
@@ -30,19 +30,17 @@
     class SimpleTest : public CppUnit::TestFixture
     {
         CPPUNIT_TEST_SUITE( SimpleTest );
-        CPPUNIT_TEST( test );
+        CPPUNIT_TEST( testAutoAck );
+        CPPUNIT_TEST( testClientAck );
         CPPUNIT_TEST_SUITE_END();
-
-    private:
-    
-        TestSupport testSupport;
         
     public:
 
     	SimpleTest();
     	virtual ~SimpleTest();
 
-        virtual void test(void);
+        virtual void testAutoAck();
+        virtual void testClientAck();
 
     };
 



Mime
View raw message