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/03/27 16:29:54 UTC

svn commit: r759177 - in /activemq/activemq-cpp/branches/activemq-cpp-2.x/src: main/activemq/connector/openwire/commands/ test-integration/activemq/test/ test-integration/activemq/test/openwire/

Author: tabish
Date: Fri Mar 27 15:29:51 2009
New Revision: 759177

URL: http://svn.apache.org/viewvc?rev=759177&view=rev
Log:
Add a new Integration test to investigate an issue reported on the Mailing list, couldn't reproduce it but its worth keeping the test, also removed an unused variable from the ActiveMQBytesMessage class.

Modified:
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.cpp
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.h
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h?rev=759177&r1=759176&r2=759177&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h Fri Mar 27 15:29:51 2009
@@ -120,9 +120,6 @@
             // Invoke base class's version.
             ActiveMQMessageBase<cms::BytesMessage>::clearBody();
 
-            // Set the stream in write only mode.
-            readOnly = false;
-
             outputStream.setBuffer( getContent() );
         }
 
@@ -191,7 +188,6 @@
          */
         virtual void writeByte( unsigned char value ) throw ( cms::CMSException );
 
-
         /**
          * Reads a byte array from the bytes message stream.
          *
@@ -404,13 +400,6 @@
     private:
 
         /**
-         * Flag that indicates what state the stream is in.  If true, the
-         * message may only be read from.  If false, the message may only be
-         * written to.
-         */
-        bool readOnly;
-
-        /**
          * InputStream that wraps around the command's content when in
          * read-only mode.
          */

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.cpp?rev=759177&r1=759176&r2=759177&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.cpp Fri Mar 27 15:29:51 2009
@@ -356,3 +356,50 @@
         CPPUNIT_ASSERT( false );
     }
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testBytesMessageSendRecv() {
+
+    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 );
+
+        auto_ptr<cms::BytesMessage> bytesMessage( session->createBytesMessage() );
+
+        bytesMessage->writeBoolean( true );
+        bytesMessage->writeByte( 127 );
+        bytesMessage->writeDouble( 123456.789 );
+        bytesMessage->writeInt( 65537 );
+        bytesMessage->writeString( "TEST-STRING" );
+
+        // Send some text messages
+        producer->send( bytesMessage.get() );
+
+        auto_ptr<cms::Message> message( consumer->receive( 2000 ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+
+        CPPUNIT_ASSERT_THROW_MESSAGE(
+            "Should throw an ActiveMQExceptio",
+            message->setStringProperty( "FOO", "BAR" ),
+            exceptions::ActiveMQException );
+
+        BytesMessage* bytesMessage2 = dynamic_cast<cms::BytesMessage*>( message.get() );
+        CPPUNIT_ASSERT( bytesMessage2 != NULL );
+        CPPUNIT_ASSERT_THROW_MESSAGE(
+            "Should throw an ActiveMQExceptio",
+            bytesMessage2->writeBoolean( false ),
+            exceptions::ActiveMQException );
+
+        CPPUNIT_ASSERT( bytesMessage2->readBoolean() == true );
+        CPPUNIT_ASSERT( bytesMessage2->readByte() == 127 );
+        CPPUNIT_ASSERT( bytesMessage2->readDouble() == 123456.789 );
+        CPPUNIT_ASSERT( bytesMessage2->readInt() == 65537 );
+        CPPUNIT_ASSERT( bytesMessage2->readString() == "TEST-STRING" );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.h?rev=759177&r1=759176&r2=759177&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.h Fri Mar 27 15:29:51 2009
@@ -39,6 +39,7 @@
         virtual void testMultipleSessions();
         virtual void testReceiveAlreadyInQueue();
         virtual void testQuickCreateAndDestroy();
+        virtual void testBytesMessageSendRecv();
 
 
     };

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h?rev=759177&r1=759176&r2=759177&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h Fri Mar 27 15:29:51 2009
@@ -36,6 +36,7 @@
         CPPUNIT_TEST( testMultipleSessions );
         CPPUNIT_TEST( testReceiveAlreadyInQueue );
         CPPUNIT_TEST( testQuickCreateAndDestroy );
+        CPPUNIT_TEST( testBytesMessageSendRecv );
         CPPUNIT_TEST( testWithZeroConsumerPrefetch );
         CPPUNIT_TEST( testMapMessageSendToQueue );
         CPPUNIT_TEST( testMapMessageSendToTopic );