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 2009/05/15 16:48:49 UTC

svn commit: r775168 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/core/ActiveMQSession.cpp test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp test-integration/activemq/test/openwire/OpenwireSimpleTest.h

Author: tabish
Date: Fri May 15 14:48:49 2009
New Revision: 775168

URL: http://svn.apache.org/viewvc?rev=775168&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-217

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp?rev=775168&r1=775167&r2=775168&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp Fri May 15 14:48:49 2009
@@ -36,6 +36,7 @@
 #include <activemq/commands/ActiveMQBytesMessage.h>
 #include <activemq/commands/ActiveMQTextMessage.h>
 #include <activemq/commands/ActiveMQMapMessage.h>
+#include <activemq/commands/ActiveMQStreamMessage.h>
 #include <activemq/commands/ActiveMQTempTopic.h>
 #include <activemq/commands/ActiveMQTempQueue.h>
 #include <activemq/commands/MessagePull.h>
@@ -529,9 +530,9 @@
     throw ( cms::CMSException ) {
 
     try{
-        // TODO
-        throw decaf::lang::exceptions::UnsupportedOperationException(
-            __FILE__, __LINE__, "StreamMessage Not Yet Implemented." );
+
+        this->checkClosed();
+        return new commands::ActiveMQStreamMessage();
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp?rev=775168&r1=775167&r2=775168&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp Fri May 15 14:48:49 2009
@@ -247,3 +247,68 @@
         CPPUNIT_ASSERT_MESSAGE( "CAUGHT EXCEPTION", false );
     } AMQ_CATCHALL_THROW( ActiveMQException )
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenwireSimpleTest::tesstStreamMessage() {
+
+    try{
+
+        // Create CMS Object for Comms
+        cms::Session* session( cmsProvider->getSession() );
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        unsigned char byteValue = 'A';
+        char charValue = 'B';
+        bool booleanValue = true;
+        short shortValue = 2048;
+        int intValue = 655369;
+        long long longValue = 0xFFFFFFFF00000000ULL;
+        float floatValue = 45.6545f;
+        double doubleValue = 654564.654654;
+        std::string stringValue = "The test string";
+
+        auto_ptr<cms::StreamMessage> streamMessage( session->createStreamMessage() );
+
+        streamMessage->writeString( stringValue );
+        streamMessage->writeBoolean( booleanValue );
+        streamMessage->writeByte( byteValue );
+        streamMessage->writeChar( charValue );
+        streamMessage->writeShort( shortValue );
+        streamMessage->writeInt( intValue );
+        streamMessage->writeLong( longValue );
+        streamMessage->writeFloat( floatValue );
+        streamMessage->writeDouble( doubleValue );
+
+        std::vector<unsigned char> bytes;
+        std::vector<unsigned char> readBytes;
+        bytes.push_back( 65 );
+        bytes.push_back( 66 );
+        bytes.push_back( 67 );
+        bytes.push_back( 68 );
+        bytes.push_back( 69 );
+        streamMessage->writeBytes( bytes );
+
+        // Send some text messages
+        producer->send( streamMessage.get() );
+
+        auto_ptr<cms::Message> message( consumer->receive( 2000 ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+
+        cms::StreamMessage* rcvStreamMessage = dynamic_cast<StreamMessage*>( message.get() );
+        CPPUNIT_ASSERT( rcvStreamMessage != NULL );
+        CPPUNIT_ASSERT( rcvStreamMessage->readString() == stringValue );
+        CPPUNIT_ASSERT( rcvStreamMessage->readBoolean() == booleanValue );
+        CPPUNIT_ASSERT( rcvStreamMessage->readByte() == byteValue );
+        CPPUNIT_ASSERT( rcvStreamMessage->readChar() == charValue );
+        CPPUNIT_ASSERT( rcvStreamMessage->readShort() == shortValue );
+        CPPUNIT_ASSERT( rcvStreamMessage->readInt() == intValue );
+        CPPUNIT_ASSERT( rcvStreamMessage->readLong() == longValue );
+        CPPUNIT_ASSERT( rcvStreamMessage->readFloat() == floatValue );
+        CPPUNIT_ASSERT( rcvStreamMessage->readDouble() == doubleValue );
+        CPPUNIT_ASSERT( rcvStreamMessage->readBytes( readBytes ) == bytes.size() );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h?rev=775168&r1=775167&r2=775168&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h Fri May 15 14:48:49 2009
@@ -41,6 +41,7 @@
         CPPUNIT_TEST( testMapMessageSendToQueue );
         CPPUNIT_TEST( testMapMessageSendToTopic );
         CPPUNIT_TEST( testDestroyDestination );
+        CPPUNIT_TEST( tesstStreamMessage );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -52,10 +53,11 @@
             return activemq::util::IntegrationCommon::getInstance().getOpenwireURL();
         }
 
-        virtual void testWithZeroConsumerPrefetch();
-        virtual void testMapMessageSendToQueue();
-        virtual void testMapMessageSendToTopic();
-        virtual void testDestroyDestination();
+        void testWithZeroConsumerPrefetch();
+        void testMapMessageSendToQueue();
+        void testMapMessageSendToTopic();
+        void tesstStreamMessage();
+        void testDestroyDestination();
 
     };