activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r747188 - in /activemq/activemq-cpp/branches/activemq-cpp-2.x/src: main/activemq/connector/openwire/commands/ main/activemq/connector/stomp/commands/ main/activemq/core/ test-integration/activemq/test/
Date Mon, 23 Feb 2009 22:58:49 GMT
Author: tabish
Date: Mon Feb 23 22:58:47 2009
New Revision: 747188

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

Add readOnlyBody and readOnlyProperties to the base Message command and then use correct checks in the CMS Message implementations, set the Message body and propeties to read only in the ActiveMQConnection class explicitly on a dispatch to the consumer.

Modified:
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
    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/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQTextMessage.cpp
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/MessageCommand.h
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/StompMessage.h
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/TextMessageCommand.h
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQConnection.cpp
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQMessage.h
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/activemq/test/SimpleTest.cpp

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp Mon Feb 23 22:58:47 2009
@@ -85,7 +85,7 @@
 void ActiveMQBytesMessage::reset() throw ( cms::CMSException ) {
 
     try{
-        readOnly = true;
+        this->setReadOnlyBody( true );
         inputStream.setBuffer( getContent() );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -97,7 +97,7 @@
 bool ActiveMQBytesMessage::readBoolean() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readBoolean();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -109,7 +109,7 @@
 void ActiveMQBytesMessage::writeBoolean( bool value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeBoolean( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -121,7 +121,7 @@
 unsigned char ActiveMQBytesMessage::readByte() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readByte();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -133,7 +133,7 @@
 void ActiveMQBytesMessage::writeByte( unsigned char value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeByte( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -146,7 +146,7 @@
     throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.read( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -158,7 +158,7 @@
 void ActiveMQBytesMessage::writeBytes( const std::vector<unsigned char>& value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.write( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -171,7 +171,7 @@
     throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.read( buffer, 0, length );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -185,7 +185,7 @@
                          std::size_t length ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.write( value, offset, length );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -197,7 +197,7 @@
 char ActiveMQBytesMessage::readChar() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readChar();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -209,7 +209,7 @@
 void ActiveMQBytesMessage::writeChar( char value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeChar( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -221,7 +221,7 @@
 float ActiveMQBytesMessage::readFloat() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readFloat();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -233,7 +233,7 @@
 void ActiveMQBytesMessage::writeFloat( float value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeFloat( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -245,7 +245,7 @@
 double ActiveMQBytesMessage::readDouble() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readDouble();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -257,7 +257,7 @@
 void ActiveMQBytesMessage::writeDouble( double value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeDouble( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -269,7 +269,7 @@
 short ActiveMQBytesMessage::readShort() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readShort();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -281,7 +281,7 @@
 void ActiveMQBytesMessage::writeShort( short value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeShort( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -293,7 +293,7 @@
 unsigned short ActiveMQBytesMessage::readUnsignedShort() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readUnsignedShort();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -305,7 +305,7 @@
 void ActiveMQBytesMessage::writeUnsignedShort( unsigned short value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeUnsignedShort( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -317,7 +317,7 @@
 int ActiveMQBytesMessage::readInt() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readInt();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -329,7 +329,7 @@
 void ActiveMQBytesMessage::writeInt( int value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeInt( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -341,7 +341,7 @@
 long long ActiveMQBytesMessage::readLong() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readLong();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -353,7 +353,7 @@
 void ActiveMQBytesMessage::writeLong( long long value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeLong( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -365,7 +365,7 @@
 std::string ActiveMQBytesMessage::readString() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readString();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -377,7 +377,7 @@
 void ActiveMQBytesMessage::writeString( const std::string& value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeChars( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -389,7 +389,7 @@
 std::string ActiveMQBytesMessage::readUTF() const throw ( cms::CMSException ) {
 
     try{
-        checkReadOnly();
+        checkWriteOnlyBody();
         return dataInputStream.readUTF();
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -401,7 +401,7 @@
 void ActiveMQBytesMessage::writeUTF( const std::string& value ) throw ( cms::CMSException ) {
 
     try{
-        checkWriteOnly();
+        checkReadOnlyBody();
         dataOutputStream.writeUTF( value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )

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=747188&r1=747187&r2=747188&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 Mon Feb 23 22:58:47 2009
@@ -391,22 +391,11 @@
     protected:
 
         /**
-         * Throws an exception if not in write-only mode.
+         * Throws an exception if in write-only mode.
          * @throws CMSException.
          */
-        void checkWriteOnly() const throw (cms::CMSException){
-            if( readOnly ){
-                throw exceptions::ActiveMQException( __FILE__, __LINE__,
-                    "message is in read-only mode and cannot be written to" );
-            }
-        }
-
-        /**
-         * Throws an exception if not in read-only mode.
-         * @throws CMSException
-         */
-        void checkReadOnly() const throw (cms::CMSException){
-            if( !readOnly ){
+        void checkWriteOnlyBody() const throw (cms::CMSException){
+            if( !isReadOnlyBody() ){
                 throw exceptions::ActiveMQException( __FILE__, __LINE__,
                     "message is in write-only mode and cannot be read from" );
             }

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp Mon Feb 23 22:58:47 2009
@@ -160,6 +160,7 @@
     throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setBool( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -185,6 +186,7 @@
                                       throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setByte( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -210,6 +212,7 @@
                                        throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setByteArray( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -234,6 +237,7 @@
     throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setChar( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -259,6 +263,7 @@
                                         throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setDouble( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -283,6 +288,7 @@
     throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setFloat( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -307,6 +313,7 @@
     throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setInt( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -331,6 +338,7 @@
     throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setLong( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -355,6 +363,7 @@
     throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setShort( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -380,6 +389,7 @@
                                         throw( cms::CMSException ) {
 
     try{
+        checkReadOnlyBody();
         getMap().setString( name, value );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h Mon Feb 23 22:58:47 2009
@@ -52,12 +52,16 @@
         int redeliveryCount;
         util::PrimitiveMap properties;
         std::auto_ptr<utils::MessagePropertyInterceptor> propertiesInterceptor;
+        bool readOnlyBody;
+        bool readOnlyProperties;
 
     public:
 
         ActiveMQMessageBase() {
             this->ackHandler = NULL;
             this->redeliveryCount = 0;
+            this->readOnlyBody = false;
+            this->readOnlyProperties = false;
             this->propertiesInterceptor.reset(
                 new utils::MessagePropertyInterceptor( this, &this->properties ) );
         }
@@ -76,14 +80,16 @@
             this->properties.copy( message->properties );
             this->setAckHandler( message->getAckHandler() );
             this->setRedeliveryCount( message->getRedeliveryCount() );
+            this->setReadOnlyBody( message->isReadOnlyBody() );
+            this->setReadOnlyProperties( message->isReadOnlyProperties() );
 
             openwire::commands::Message::copyDataStructure( src );
         }
 
         /**
-         * Indicates that this command is aware of Marshalling, and needs
-         * to have its Marshalling methods invoked.
-         * @returns boolean indicating desire to be in marshalling stages
+         * Indicates that this command is aware of Marshaling, and needs
+         * to have its Marshaling methods invoked.
+         * @returns boolean indicating desire to be in marshaling stages
          */
         virtual bool isMarshalAware() const {
             return true;
@@ -233,6 +239,38 @@
             return false;
         }
 
+        /**
+         * Returns if the Message Body is Read Only.
+         * @returns true if the Message Body is Read Only.
+         */
+        virtual bool isReadOnlyBody() const {
+             return this->readOnlyBody;
+        }
+
+        /**
+         * Sets the Read Only status of a Message Body
+         * @param value - true if the Message Body is Read Only.
+         */
+        virtual void setReadOnlyBody( bool value ) {
+            this->readOnlyBody = value;
+        }
+
+        /**
+         * Returns if the Message Properties are Read Only.
+         * @returns true if the Message properties are Read Only.
+         */
+        virtual bool isReadOnlyProperties() const {
+            return this->readOnlyProperties;
+       }
+
+        /**
+         * Sets the Read Only status of a Message's Properties
+         * @param value - true if the Message Properties are Read Only.
+         */
+        virtual void setReadOnlyProperties( bool value )  {
+            this->readOnlyProperties = value;
+        }
+
     public:   // CMS Message
 
         /**
@@ -253,6 +291,7 @@
          * headers or properties.
          */
         virtual void clearBody() {
+            this->readOnlyBody = false;
             this->setContent( std::vector<unsigned char>() );
         }
 
@@ -261,7 +300,8 @@
          * header values.
          */
         virtual void clearProperties() {
-            properties.clear();
+            this->readOnlyProperties = false;
+            this->properties.clear();
         }
 
         /**
@@ -429,6 +469,7 @@
                                             throw( cms::CMSException ) {
 
             try{
+                checkReadOnlyProperties();
                 this->propertiesInterceptor->setBooleanProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -447,6 +488,7 @@
                                         throw( cms::CMSException ) {
 
             try{
+                checkReadOnlyProperties();
                 this->propertiesInterceptor->setByteProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -465,6 +507,7 @@
                                             throw( cms::CMSException ) {
 
             try{
+                checkReadOnlyProperties();
                 this->propertiesInterceptor->setDoubleProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -483,6 +526,7 @@
                                         throw( cms::CMSException ) {
 
             try{
+                checkReadOnlyProperties();
                 this->propertiesInterceptor->setFloatProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -501,6 +545,7 @@
                                         throw( cms::CMSException ) {
 
             try{
+                checkReadOnlyProperties();
                 this->propertiesInterceptor->setIntProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -519,6 +564,7 @@
                                         throw( cms::CMSException ) {
 
             try{
+                checkReadOnlyProperties();
                 this->propertiesInterceptor->setLongProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -537,6 +583,7 @@
                                         throw( cms::CMSException ) {
 
             try{
+                checkReadOnlyProperties();
                 this->propertiesInterceptor->setShortProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -555,6 +602,7 @@
                                             throw( cms::CMSException ) {
 
             try{
+                checkReadOnlyProperties();
                 this->propertiesInterceptor->setStringProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -736,6 +784,22 @@
             this->setType( type );
         }
 
+    protected:
+
+        void checkReadOnlyBody() {
+            if( this->isReadOnlyBody() ) {
+                throw exceptions::ActiveMQException(
+                    __FILE__, __LINE__, "Message Body is in Read Only Mode." );
+            }
+        }
+
+        void checkReadOnlyProperties() {
+            if( this->isReadOnlyProperties() ) {
+                throw exceptions::ActiveMQException(
+                    __FILE__, __LINE__, "Message Properties are in Read Only Mode." );
+            }
+        }
+
     };
 
 }}}}

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQTextMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQTextMessage.cpp?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQTextMessage.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/openwire/commands/ActiveMQTextMessage.cpp Mon Feb 23 22:58:47 2009
@@ -69,6 +69,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQTextMessage::setText( const std::string& msg ) throw( cms::CMSException ) {
     try{
+        checkReadOnlyBody();
         std::vector<unsigned char>& content = getContent();
         content.clear();
         decaf::io::ByteArrayOutputStream bos( content );

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h Mon Feb 23 22:58:47 2009
@@ -43,13 +43,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 frame's body when in read-only
          * mode.
          */
@@ -117,9 +110,6 @@
             // Invoke base class's version.
             StompMessage<cms::BytesMessage>::clearBody();
 
-            // Set the stream in write only mode.
-            readOnly = false;
-
             outputStream.setBuffer( getBytes() );
         }
 
@@ -153,7 +143,7 @@
          * @throws CMSException
          */
         virtual void reset() throw ( cms::CMSException ){
-            readOnly = true;
+            this->setReadOnlyBody( true );
             inputStream.setBuffer( getBytes() );
         }
 
@@ -167,6 +157,8 @@
             BytesMessageCommand* command =
                 new BytesMessageCommand( getFrame().clone() );
             command->setAckHandler( this->getAckHandler() );
+            command->setReadOnlyBody( this->isReadOnlyBody() );
+            command->setReadOnlyProperties( this->isReadOnlyProperties() );
 
             return command;
         }
@@ -181,7 +173,7 @@
                                    std::size_t numBytes )
             throw( cms::CMSException ) {
 
-            checkWriteOnly();
+            checkReadOnlyBody();
             this->setBytes( buffer, numBytes );
         }
 
@@ -216,7 +208,7 @@
          */
         virtual bool readBoolean() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readBoolean();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -233,7 +225,7 @@
          */
         virtual void writeBoolean( bool value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeBoolean( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -248,7 +240,7 @@
          */
         virtual unsigned char readByte() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readByte();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -263,7 +255,7 @@
          */
         virtual void writeByte( unsigned char value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeByte( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -293,7 +285,7 @@
         virtual std::size_t readBytes( std::vector<unsigned char>& value ) const
             throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.read( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -310,7 +302,7 @@
         virtual void writeBytes( const std::vector<unsigned char>& value )
             throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.write( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -347,7 +339,7 @@
             throw ( cms::CMSException )
         {
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.read( buffer, 0, length );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -367,7 +359,7 @@
                                  std::size_t offset,
                                  std::size_t length ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.write( value, offset, length );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -382,7 +374,7 @@
          */
         virtual char readChar() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readChar();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -397,7 +389,7 @@
          */
         virtual void writeChar( char value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeChar( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -412,7 +404,7 @@
          */
         virtual float readFloat() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readFloat();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -427,7 +419,7 @@
          */
         virtual void writeFloat( float value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeFloat( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -442,7 +434,7 @@
          */
         virtual double readDouble() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readDouble();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -457,7 +449,7 @@
          */
         virtual void writeDouble( double value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeDouble( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -472,7 +464,7 @@
          */
         virtual short readShort() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readShort();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -487,7 +479,7 @@
          */
         virtual void writeShort( short value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeShort( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -502,7 +494,7 @@
          */
         virtual unsigned short readUnsignedShort() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readUnsignedShort();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -517,7 +509,7 @@
          */
         virtual void writeUnsignedShort( unsigned short value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeUnsignedShort( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -526,13 +518,13 @@
         }
 
         /**
-         * Reads a 32 bit signed intger from the Bytes message stream
+         * Reads a 32 bit signed integer from the Bytes message stream
          * @returns int value from stream
          * @throws CMSException
          */
         virtual int readInt() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readInt();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -547,7 +539,7 @@
          */
         virtual void writeInt( int value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeInt( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -562,7 +554,7 @@
          */
         virtual long long readLong() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readLong();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -577,7 +569,7 @@
          */
         virtual void writeLong( long long value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeLong( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -592,7 +584,7 @@
          */
         virtual std::string readString() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readString();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -607,7 +599,7 @@
          */
         virtual void writeString( const std::string& value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeChars( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -622,7 +614,7 @@
          */
         virtual std::string readUTF() const throw ( cms::CMSException ){
             try{
-                checkReadOnly();
+                checkWriteOnlyBody();
                 return dataInputStream.readUTF();
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -637,7 +629,7 @@
          */
         virtual void writeUTF( const std::string& value ) throw ( cms::CMSException ){
             try{
-                checkWriteOnly();
+                checkReadOnlyBody();
                 dataOutputStream.writeUTF( value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -651,19 +643,8 @@
          * Throws an exception if not in write-only mode.
          * @throws CMSException.
          */
-        void checkWriteOnly() const throw ( cms::CMSException ){
-            if( readOnly ){
-                throw activemq::exceptions::ActiveMQException( __FILE__, __LINE__,
-                    "message is in read-only mode and cannot be written to" );
-            }
-        }
-
-        /**
-         * Throws an exception if not in read-only mode.
-         * @throws CMSException
-         */
-        void checkReadOnly() const throw ( cms::CMSException ){
-            if( !readOnly ){
+        void checkWriteOnlyBody() const throw ( cms::CMSException ){
+            if( !this->isReadOnlyBody() ){
                 throw activemq::exceptions::ActiveMQException( __FILE__, __LINE__,
                     "message is in write-only mode and cannot be read from" );
             }

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/MessageCommand.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/MessageCommand.h?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/MessageCommand.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/MessageCommand.h Mon Feb 23 22:58:47 2009
@@ -64,7 +64,10 @@
 
             MessageCommand* command =
                 new MessageCommand( getFrame().clone() );
+
             command->setAckHandler( this->getAckHandler() );
+            command->setReadOnlyBody( this->isReadOnlyBody() );
+            command->setReadOnlyProperties( this->isReadOnlyProperties() );
 
             return command;
         }

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/StompMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/StompMessage.h?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/StompMessage.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/StompMessage.h Mon Feb 23 22:58:47 2009
@@ -68,20 +68,27 @@
         // Cached Destination
         cms::Destination* replyTo;
 
+        bool readOnlyBody;
+        bool readOnlyProperties;
+
     public:
 
         StompMessage() :
             AbstractCommand< transport::Command >(),
             ackHandler( NULL ),
             dest( NULL ),
-            replyTo( NULL) {
+            replyTo( NULL ),
+            readOnlyBody( false ),
+            readOnlyProperties( false ) {
         }
 
         StompMessage( StompFrame* frame ) :
             AbstractCommand< transport::Command >( frame ),
             ackHandler( NULL ),
             dest( NULL ),
-            replyTo( NULL ) {
+            replyTo( NULL ),
+            readOnlyBody( false ),
+            readOnlyProperties( false ) {
 
             const std::string& destHeader = CommandConstants::toString(
                 CommandConstants::HEADER_DESTINATION );
@@ -113,6 +120,7 @@
          * headers or properties.
          */
         virtual void clearBody(){
+            this->readOnlyBody = false;
             getFrame().getBody().clear();
         }
 
@@ -122,6 +130,7 @@
          */
         virtual void clearProperties(){
 
+            this->readOnlyProperties = false;
             decaf::util::Properties& props = getFrame().getProperties();
             std::vector< std::pair< std::string, std::string > > propArray = props.toArray();
             for( unsigned int ix=0; ix<propArray.size(); ++ix ){
@@ -136,7 +145,7 @@
         }
 
         /**
-         * Retrieves the propery names.
+         * Retrieves the property names.
          * @return The complete set of property names currently in this
          * message.
          */
@@ -255,11 +264,11 @@
         }
 
         virtual void setBooleanProperty( const std::string& name,
-            bool value ) throw( cms::CMSException ){
+                                         bool value ) throw( cms::CMSException ){
 
             try{
+                checkReadOnlyProperties();
                 testProperty( name );
-
                 std::string strvalue = value? "true" : "false";
                 setPropertyValue( name, strvalue );
             }
@@ -272,6 +281,7 @@
             unsigned char value ) throw( cms::CMSException ){
 
             try{
+                checkReadOnlyProperties();
                 setStrictPropertyValue<unsigned char>( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -280,8 +290,9 @@
         }
 
         virtual void setDoubleProperty( const std::string& name,
-            double value ) throw( cms::CMSException ){
+                                        double value ) throw( cms::CMSException ){
             try{
+                checkReadOnlyProperties();
                 setStrictPropertyValue<double>( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -290,8 +301,9 @@
         }
 
         virtual void setFloatProperty( const std::string& name,
-            float value ) throw( cms::CMSException ){
+                                       float value ) throw( cms::CMSException ){
             try{
+                checkReadOnlyProperties();
                 setStrictPropertyValue<float>( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -300,8 +312,9 @@
         }
 
         virtual void setIntProperty( const std::string& name,
-            int value ) throw( cms::CMSException ){
+                                     int value ) throw( cms::CMSException ){
             try{
+                checkReadOnlyProperties();
                 setStrictPropertyValue<int>( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -310,8 +323,9 @@
         }
 
         virtual void setLongProperty( const std::string& name,
-            long long value ) throw( cms::CMSException ){
+                                      long long value ) throw( cms::CMSException ){
             try{
+                checkReadOnlyProperties();
                 setStrictPropertyValue<long long>( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -320,8 +334,9 @@
         }
 
         virtual void setShortProperty( const std::string& name,
-            short value ) throw( cms::CMSException ){
+                                       short value ) throw( cms::CMSException ){
             try{
+                checkReadOnlyProperties();
                 setStrictPropertyValue<short>( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -330,8 +345,9 @@
         }
 
         virtual void setStringProperty( const std::string& name,
-            const std::string& value ) throw( cms::CMSException ){
+                                        const std::string& value ) throw( cms::CMSException ){
             try{
+                checkReadOnlyProperties();
                 testProperty( name );
                 setPropertyValue( name, value );
             }
@@ -601,7 +617,7 @@
     public:    // ActiveMQMessage
 
         /**
-         * Gets the Acknowledgement Handler that this Message will use
+         * Gets the Acknowledgment Handler that this Message will use
          * when the Acknowledge method is called.
          * @returns handler ActiveMQAckHandler
          */
@@ -610,7 +626,7 @@
         }
 
         /**
-         * Sets the Acknowledgement Handler that this Message will use
+         * Sets the Acknowledgment Handler that this Message will use
          * when the Acknowledge method is called.
          * @param handler ActiveMQAckHandler
          */
@@ -655,6 +671,38 @@
             return false;
         }
 
+        /**
+         * Returns if the Message Body is Read Only.
+         * @returns true if the Message Body is Read Only.
+         */
+        virtual bool isReadOnlyBody() const {
+             return this->readOnlyBody;
+        }
+
+        /**
+         * Sets the Read Only status of a Message Body
+         * @param value - true if the Message Body is Read Only.
+         */
+        virtual void setReadOnlyBody( bool value ) {
+            this->readOnlyBody = value;
+        }
+
+        /**
+         * Returns if the Message Properties are Read Only.
+         * @returns true if the Message properties are Read Only.
+         */
+        virtual bool isReadOnlyProperties() const {
+            return this->readOnlyProperties;
+       }
+
+        /**
+         * Sets the Read Only status of a Message's Properties
+         * @param value - true if the Message Properties are Read Only.
+         */
+        virtual void setReadOnlyProperties( bool value )  {
+            this->readOnlyProperties = value;
+        }
+
     protected:
 
         /**
@@ -770,6 +818,20 @@
             return false;
         }
 
+        void checkReadOnlyBody() {
+            if( this->isReadOnlyBody() ) {
+                throw exceptions::ActiveMQException(
+                    __FILE__, __LINE__, "Message Body is in Read Only Mode." );
+            }
+        }
+
+        void checkReadOnlyProperties() {
+            if( this->isReadOnlyProperties() ) {
+                throw exceptions::ActiveMQException(
+                    __FILE__, __LINE__, "Message Properties are in Read Only Mode." );
+            }
+        }
+
     };
 
 }}}}

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/TextMessageCommand.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/TextMessageCommand.h?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/TextMessageCommand.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/connector/stomp/commands/TextMessageCommand.h Mon Feb 23 22:58:47 2009
@@ -62,6 +62,8 @@
             TextMessageCommand* command =
                 new TextMessageCommand( getFrame().clone() );
             command->setAckHandler( this->getAckHandler() );
+            command->setReadOnlyBody( this->isReadOnlyBody() );
+            command->setReadOnlyProperties( this->isReadOnlyProperties() );
 
             return command;
         }
@@ -91,6 +93,7 @@
          */
         virtual void setText( const char* msg ) throw( cms::CMSException ) {
             try{
+                checkReadOnlyBody();
                 setBytes( (unsigned char*)msg, strlen(msg) + 1 );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
@@ -104,6 +107,7 @@
          */
         virtual void setText( const std::string& msg ) throw( cms::CMSException ) {
             try{
+                checkReadOnlyBody();
                 setBytes( (unsigned char*)msg.c_str(), msg.length() + 1 );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQConnection.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQConnection.cpp?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQConnection.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQConnection.cpp Mon Feb 23 22:58:47 2009
@@ -233,6 +233,9 @@
                 delete message;
             } else {
 
+                message->setReadOnlyBody( true );
+                message->setReadOnlyProperties( true );
+
                 // Dispatch the message.
                 DispatchData data( consumer, message );
                 dispatcher->dispatch( data );

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQMessage.h?rev=747188&r1=747187&r2=747188&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQMessage.h (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/activemq/core/ActiveMQMessage.h Mon Feb 23 22:58:47 2009
@@ -28,7 +28,7 @@
     /**
      * Interface for all ActiveMQ Messages that will pass through the core
      * API layer.  This interface defines a method that the API uses to set
-     * an Acknowledgement handler that will be called by the message when
+     * an Acknowledgment handler that will be called by the message when
      * a user calls the <code>acknowledge</code> method of the Message
      * interface.  This is only done when the Session that this message
      * passes through is in Client Acknowledge mode.
@@ -39,7 +39,7 @@
         virtual ~ActiveMQMessage() {}
 
         /**
-         * Sets the Acknowledgement Handler that this Message will use
+         * Sets the Acknowledgment Handler that this Message will use
          * when the Acknowledge method is called.
          * @param handler ActiveMQAckHandler to call
          */
@@ -65,6 +65,30 @@
          */
         virtual bool isExpired() const = 0;
 
+        /**
+         * Returns if the Message Body is Read Only.
+         * @returns true if the Message Body is Read Only.
+         */
+        virtual bool isReadOnlyBody() const = 0;
+
+        /**
+         * Sets the Read Only status of a Message Body
+         * @param value - true if the Message Body is Read Only.
+         */
+        virtual void setReadOnlyBody( bool value ) = 0;
+
+        /**
+         * Returns if the Message Properties are Read Only.
+         * @returns true if the Message properties are Read Only.
+         */
+        virtual bool isReadOnlyProperties() const = 0;
+
+        /**
+         * Sets the Read Only status of a Message's Properties
+         * @param value - true if the Message Properties are Read Only.
+         */
+        virtual void setReadOnlyProperties( bool value ) = 0;
+
     };
 
 }}

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=747188&r1=747187&r2=747188&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 Mon Feb 23 22:58:47 2009
@@ -155,6 +155,18 @@
 
         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 );
+
+        TextMessage* txtMessage2 = dynamic_cast<cms::TextMessage*>( message.get() );
+        CPPUNIT_ASSERT( txtMessage2 != NULL );
+        CPPUNIT_ASSERT_THROW_MESSAGE(
+            "Should throw an ActiveMQExceptio",
+            txtMessage2->setText( "FOO" ),
+            exceptions::ActiveMQException );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
     AMQ_CATCHALL_THROW( ActiveMQException )



Mime
View raw message