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/12/05 22:37:55 UTC

svn commit: r723878 - in /activemq/activemq-cpp/trunk/src/test-integration/activemq/util: CMSProvider.cpp CMSProvider.h

Author: tabish
Date: Fri Dec  5 13:37:55 2008
New Revision: 723878

URL: http://svn.apache.org/viewvc?rev=723878&view=rev
Log:
Update integration test CMSProvider class to attempt to remove the Topics and Queue that it creates.

Modified:
    activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.cpp
    activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.h

Modified: activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.cpp?rev=723878&r1=723877&r2=723878&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.cpp Fri Dec  5 13:37:55 2008
@@ -20,6 +20,7 @@
 #include <cms/ConnectionFactory.h>
 
 #include <activemq/exceptions/ActiveMQException.h>
+#include <activemq/core/ActiveMQConnection.h>
 
 #include <decaf/util/UUID.h>
 #include <decaf/lang/exceptions/IllegalStateException.h>
@@ -28,6 +29,7 @@
 using namespace cms;
 using namespace activemq;
 using namespace activemq::util;
+using namespace activemq::core;
 using namespace decaf;
 using namespace decaf::util;
 using namespace decaf::lang::exceptions;
@@ -57,11 +59,34 @@
 ////////////////////////////////////////////////////////////////////////////////
 void CMSProvider::close() throw( decaf::lang::Exception ) {
 
+    if( this->consumer.get() != NULL ) {
+        this->consumer->close();
+    }
+    if( this->producer.get() != NULL ) {
+        this->producer->close();
+    }
+    if( this->noDestProducer.get() != NULL ) {
+        this->noDestProducer->close();
+    }
+
+    if( this->destination.get() != NULL && !isDurable() ) {
+        this->destroyDestination( this->destination.get() );
+    }
+
+    this->destination.reset( NULL );
+    this->tempDestination.reset( NULL );
+
+    if( this->session.get() != NULL ) {
+        this->session->close();
+    }
+
+    if( this->connection.get() != NULL ) {
+        this->connection->close();
+    }
+
     this->consumer.reset( NULL );
     this->producer.reset( NULL );
     this->noDestProducer.reset( NULL );
-    this->destination.reset( NULL );
-    this->tempDestination.reset( NULL );
     this->session.reset( NULL );
     this->connection.reset( NULL );
 }
@@ -126,6 +151,16 @@
                 "CMSProvider has not been Initialized or is closed." );
         }
 
+        if( this->consumer.get() != NULL ) {
+            this->consumer->close();
+        }
+        if( this->producer.get() != NULL ) {
+            this->producer->close();
+        }
+        if( this->noDestProducer.get() != NULL ) {
+            this->noDestProducer->close();
+        }
+
         // Free any previously held resources.
         this->destination.reset( NULL );
         this->tempDestination.reset( NULL );
@@ -145,6 +180,7 @@
 void CMSProvider::unsubscribe() {
 
     try {
+
         if( this->connection.get() == NULL ) {
             throw decaf::lang::exceptions::IllegalStateException(
                 __FILE__, __LINE__,
@@ -339,3 +375,28 @@
     AMQ_CATCH_RETHROW( activemq::exceptions::ActiveMQException )
     AMQ_CATCHALL_THROW( activemq::exceptions::ActiveMQException )
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void CMSProvider::destroyDestination( const cms::Destination* destination ) {
+
+    try {
+
+        if( this->connection.get() == NULL ) {
+            throw decaf::lang::exceptions::IllegalStateException(
+                __FILE__, __LINE__,
+                "CMSProvider has not been Initialized or is closed." );
+        }
+
+        ActiveMQConnection* amqConnection =
+            dynamic_cast<ActiveMQConnection*>( this->connection.get() );
+
+        try{
+            amqConnection->destroyDestination( destination );
+        } catch( decaf::lang::Exception& ex ) {
+            ex.printStackTrace();
+        } catch( ... ) {
+        }
+    }
+    AMQ_CATCH_RETHROW( activemq::exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( activemq::exceptions::ActiveMQException )
+}

Modified: activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.h?rev=723878&r1=723877&r2=723878&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.h (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.h Fri Dec  5 13:37:55 2008
@@ -185,6 +185,11 @@
          */
         virtual cms::Destination* getTempDestination();
 
+        /**
+         * Destroys a Destination at the Broker side, freeing the resources associated with it.
+         */
+        virtual void destroyDestination( const cms::Destination* destination );
+
     };
 
 }}