activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1334526 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util: ActiveMQMessageTransformationTest.cpp ActiveMQMessageTransformationTest.h
Date Sat, 05 May 2012 22:28:31 GMT
Author: tabish
Date: Sat May  5 22:28:30 2012
New Revision: 1334526

URL: http://svn.apache.org/viewvc?rev=1334526&view=rev
Log:
Test coverage for ActiveMQMessageTransformation.

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

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.cpp?rev=1334526&r1=1334525&r2=1334526&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.cpp
Sat May  5 22:28:30 2012
@@ -17,8 +17,71 @@
 
 #include "ActiveMQMessageTransformationTest.h"
 
+#include <activemq/commands/ActiveMQDestination.h>
+#include <activemq/commands/ActiveMQTopic.h>
+#include <activemq/commands/ActiveMQQueue.h>
+#include <activemq/util/ActiveMQProperties.h>
+#include <activemq/util/ActiveMQMessageTransformation.h>
+
+#include <cms/Destination.h>
+#include <cms/Destination.h>
+#include <cms/Destination.h>
+
+#include <decaf/lang/Pointer.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+
 using namespace activemq;
 using namespace activemq::util;
+using namespace activemq::commands;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    class CustomCmsTopic : public cms::Topic {
+    private:
+
+        std::string name;
+
+    public:
+
+        CustomCmsTopic() : cms::Topic(), name("TEST-CMS-TOPIC") {
+
+        }
+
+        virtual std::string getTopicName() const {
+            return name;
+        }
+
+        virtual cms::Destination::DestinationType getDestinationType() const {
+            return cms::Destination::TOPIC;
+        }
+
+        virtual cms::Destination* clone() const {
+            return new CustomCmsTopic();
+        }
+
+        virtual void copy(const cms::Destination& source) {
+        }
+
+        virtual bool equals(const cms::Destination& other) const {
+
+            if (dynamic_cast<const CustomCmsTopic*>(&other) != NULL) {
+                return true;
+            }
+
+            return false;
+        }
+
+        virtual const cms::CMSProperties& getCMSProperties() const {
+            return activemq::util::ActiveMQProperties();
+        }
+
+    };
+
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 ActiveMQMessageTransformationTest::ActiveMQMessageTransformationTest() {
@@ -27,3 +90,44 @@ ActiveMQMessageTransformationTest::Activ
 ////////////////////////////////////////////////////////////////////////////////
 ActiveMQMessageTransformationTest::~ActiveMQMessageTransformationTest() {
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQMessageTransformationTest::testTransformDestination() {
+
+    CustomCmsTopic customTopic;
+    const ActiveMQDestination* transformed;
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an NullPointerException",
+        ActiveMQMessageTransformation::transformDestination(&customTopic, NULL),
+        NullPointerException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an NullPointerException",
+        ActiveMQMessageTransformation::transformDestination(NULL, NULL),
+        NullPointerException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an NullPointerException",
+        ActiveMQMessageTransformation::transformDestination(NULL, &transformed),
+        NullPointerException);
+
+    CPPUNIT_ASSERT(ActiveMQMessageTransformation::transformDestination(&customTopic,
&transformed));
+    CPPUNIT_ASSERT(transformed != NULL);
+    CPPUNIT_ASSERT(transformed->isTopic());
+    CPPUNIT_ASSERT(!transformed->isQueue());
+    CPPUNIT_ASSERT(!transformed->isAdvisory());
+    CPPUNIT_ASSERT(!transformed->isComposite());
+    CPPUNIT_ASSERT(!transformed->isTemporary());
+    CPPUNIT_ASSERT(!transformed->isWildcard());
+
+    CPPUNIT_ASSERT_EQUAL(customTopic.getTopicName(), transformed->getPhysicalName());
+    delete transformed;
+
+    ActiveMQQueue queue("ActiveMQ.Test.Queue");
+
+    CPPUNIT_ASSERT(!ActiveMQMessageTransformation::transformDestination(&queue, &transformed));
+    CPPUNIT_ASSERT(transformed != NULL);
+    CPPUNIT_ASSERT(!transformed->isTopic());
+    CPPUNIT_ASSERT(transformed->isQueue());
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.h?rev=1334526&r1=1334525&r2=1334526&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/ActiveMQMessageTransformationTest.h
Sat May  5 22:28:30 2012
@@ -28,7 +28,7 @@ namespace util {
     private:
 
         CPPUNIT_TEST_SUITE( ActiveMQMessageTransformationTest );
-        CPPUNIT_TEST( test );
+        CPPUNIT_TEST( testTransformDestination );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -36,7 +36,7 @@ namespace util {
         ActiveMQMessageTransformationTest();
         virtual ~ActiveMQMessageTransformationTest();
 
-        void test() {}
+        void testTransformDestination();
     };
 
 }}



Mime
View raw message