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 2013/07/23 18:06:47 UTC

svn commit: r1506136 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/commands/ main/activemq/core/kernels/ test/activemq/core/

Author: tabish
Date: Tue Jul 23 16:06:47 2013
New Revision: 1506136

URL: http://svn.apache.org/r1506136
Log:
fix for: https://issues.apache.org/jira/browse/AMQCPP-502

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp?rev=1506136&r1=1506135&r2=1506136&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp Tue Jul 23 16:06:47 2013
@@ -49,6 +49,7 @@ const std::string ActiveMQDestination::Q
 const std::string ActiveMQDestination::TOPIC_QUALIFIED_PREFIX = "topic://";
 const std::string ActiveMQDestination::TEMP_QUEUE_QUALIFED_PREFIX = "temp-queue://";
 const std::string ActiveMQDestination::TEMP_TOPIC_QUALIFED_PREFIX = "temp-topic://";
+const std::string ActiveMQDestination::TEMP_DESTINATION_NAME_PREFIX = "ID:";
 
 ////////////////////////////////////////////////////////////////////////////////
 namespace {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.h?rev=1506136&r1=1506135&r2=1506136&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.h Tue Jul 23 16:06:47 2013
@@ -78,6 +78,8 @@ namespace commands {
 
         const static unsigned char ID_ACTIVEMQDESTINATION = 0;
 
+        static const std::string TEMP_DESTINATION_NAME_PREFIX;
+
         typedef decaf::lang::PointerComparator<ActiveMQDestination> COMPARATOR;
 
     private:

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp?rev=1506136&r1=1506135&r2=1506136&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp Tue Jul 23 16:06:47 2013
@@ -747,6 +747,10 @@ cms::Queue* ActiveMQSessionKernel::creat
                 __FILE__, __LINE__, "Destination Name cannot be the Empty String." );
         }
 
+        if (queueName.find(commands::ActiveMQDestination::TEMP_DESTINATION_NAME_PREFIX) == 0) {
+            return new ActiveMQTempQueue(queueName);
+        }
+
         return new commands::ActiveMQQueue(queueName);
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -764,6 +768,10 @@ cms::Topic* ActiveMQSessionKernel::creat
                 __FILE__, __LINE__, "Destination Name cannot be the Empty String." );
         }
 
+        if (topicName.find(commands::ActiveMQDestination::TEMP_DESTINATION_NAME_PREFIX) == 0) {
+            return new ActiveMQTempTopic(topicName);
+        }
+
         return new commands::ActiveMQTopic(topicName);
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.cpp?rev=1506136&r1=1506135&r2=1506136&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.cpp Tue Jul 23 16:06:47 2013
@@ -659,6 +659,42 @@ void ActiveMQSessionTest::testTransactio
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void ActiveMQSessionTest::testCreateTempQueueByName() {
+
+    MyCMSMessageListener msgListener1;
+
+    CPPUNIT_ASSERT(connection.get() != NULL);
+    CPPUNIT_ASSERT(connection->isStarted() == true);
+
+    // Create an Auto Ack Session
+    std::auto_ptr<cms::Session> session(connection->createSession());
+
+    // Create a Topic
+    std::auto_ptr<cms::Queue> queue(session->createQueue("ID:TestQueue"));
+
+    CPPUNIT_ASSERT(queue.get() != NULL);
+    CPPUNIT_ASSERT(queue->getDestinationType() == cms::Destination::TEMPORARY_QUEUE);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQSessionTest::testCreateTempTopicByName() {
+
+    MyCMSMessageListener msgListener1;
+
+    CPPUNIT_ASSERT(connection.get() != NULL);
+    CPPUNIT_ASSERT(connection->isStarted() == true);
+
+    // Create an Auto Ack Session
+    std::auto_ptr<cms::Session> session(connection->createSession());
+
+    // Create a Topic
+    std::auto_ptr<cms::Topic> topic(session->createTopic("ID:TestTopic"));
+
+    CPPUNIT_ASSERT(topic.get() != NULL);
+    CPPUNIT_ASSERT(topic->getDestinationType() == cms::Destination::TEMPORARY_TOPIC);
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void ActiveMQSessionTest::setUp() {
 
     try {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.h?rev=1506136&r1=1506135&r2=1506136&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.h Tue Jul 23 16:06:47 2013
@@ -49,6 +49,8 @@ namespace core{
         CPPUNIT_TEST( testTransactionCloseWithoutCommit );
         CPPUNIT_TEST( testExpiration );
         CPPUNIT_TEST( testCreateManyConsumersAndSetListeners );
+        CPPUNIT_TEST( testCreateTempQueueByName );
+        CPPUNIT_TEST( testCreateTempTopicByName );
         CPPUNIT_TEST_SUITE_END();
 
     private:
@@ -103,6 +105,8 @@ namespace core{
         void testTransactionCloseWithoutCommit();
         void testTransactionCommitAfterConsumerClosed();
         void testExpiration();
+        void testCreateTempQueueByName();
+        void testCreateTempTopicByName();
 
     };