activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r512268 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/connector/openwire/commands/ main/activemq/connector/openwire/marshal/ main/activemq/connector/stomp/commands/ main/activemq/io/ test/activemq/connector/stomp/commands/
Date Tue, 27 Feb 2007 14:57:12 GMT
Author: tabish
Date: Tue Feb 27 06:57:08 2007
New Revision: 512268

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

Fixes for Tight Marshalling.  

Changed the DataOutputStream writeBytes to not append a trailing null and made the writeChars
do the trailing null append.  
Updated the docs on the methods to make this clear, and changed the code that was calling
writeBytes to call writeChars 
in the places that a trailing null was expected.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp?view=diff&rev=512268&r1=512267&r2=512268
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp
Tue Feb 27 06:57:08 2007
@@ -351,7 +351,7 @@
 
     try{
         checkWriteOnly();
-        dataOutputStream.writeBytes( value );
+        dataOutputStream.writeChars( value );
     }
     AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
     AMQ_CATCHALL_THROW( exceptions::ActiveMQException )

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp?view=diff&rev=512268&r1=512267&r2=512268
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
Tue Feb 27 06:57:08 2007
@@ -281,7 +281,7 @@
             // If we verified it only holds ascii values
             if( bs->readBoolean() ) {
                 dataOut->writeShort( (short)value.length() );
-                dataOut->write( (const unsigned char*)value.c_str(), 0, value.length()
);
+                dataOut->writeBytes( value );
             } else {
                 dataOut->writeChars( value );
             }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h?view=diff&rev=512268&r1=512267&r2=512268
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h
Tue Feb 27 06:57:08 2007
@@ -477,7 +477,7 @@
          */
         virtual void writeString( const std::string& value ) throw ( cms::CMSException
){
             checkWriteOnly();
-            dataOutputStream.writeBytes( value );
+            dataOutputStream.writeChars( value );
         }
 
         /**

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp?view=diff&rev=512268&r1=512267&r2=512268
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp Tue
Feb 27 06:57:08 2007
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 #include "DataOutputStream.h"
 #include <activemq/util/Endian.h>
 #include <activemq/util/Config.h>
@@ -51,12 +51,12 @@
     throw ( IOException ) {
 
     try {
-        
+
         if( buffer.size() == 0 ){
             // nothing to write.
             return;
         }
-        
+
         outputStream->write( &buffer[0], buffer.size() );
     }
     AMQ_CATCH_RETHROW( IOException )
@@ -75,9 +75,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void DataOutputStream::write( const unsigned char* buffer, 
-                              std::size_t offset, 
-                              std::size_t len ) throw ( IOException ) 
+void DataOutputStream::write( const unsigned char* buffer,
+                              std::size_t offset,
+                              std::size_t len ) throw ( IOException )
 {
 
     try {
@@ -118,8 +118,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void DataOutputStream::writeUnsignedShort( unsigned short value ) 
-    throw ( IOException ) 
+void DataOutputStream::writeUnsignedShort( unsigned short value )
+    throw ( IOException )
 {
     try {
         write( (unsigned char)( (value & 0xFF00) >> 8 ) );
@@ -193,17 +193,21 @@
 ////////////////////////////////////////////////////////////////////////////////
 void DataOutputStream::writeBytes( const std::string& value ) throw ( IOException ) {
     try {
-        // add one so that we write the NULL
-        this->write( (const unsigned char*)value.c_str(), value.length() + 1 );
+        // do not add one so that we don't write the NULL
+        this->write( (const unsigned char*)value.c_str(), value.length() );
     }
     AMQ_CATCH_RETHROW( IOException )
     AMQ_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void DataOutputStream::writeChars( const std::string& value AMQCPP_UNUSED) 
-throw ( IOException ) {
-    /* do nothing */
+void DataOutputStream::writeChars( const std::string& value ) throw ( IOException ) {
+    try {
+        // add one so that we write the NULL
+        this->write( (const unsigned char*)value.c_str(), value.length() + 1 );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h?view=diff&rev=512268&r1=512267&r2=512268
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h Tue Feb
27 06:57:08 2007
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 #ifndef _ACTIVEMQ_IO_DATAOUTPUTSTREAM_H_
 #define _ACTIVEMQ_IO_DATAOUTPUTSTREAM_H_
 
@@ -24,21 +24,21 @@
 namespace io{
 
     /**
-     * A data output stream lets an application write primitive Java data 
+     * A data output stream lets an application write primitive Java data
      * types to an output stream in a portable way. An application can then
      * use a data input stream to read the data back in.
      */
     class DataOutputStream : public FilterOutputStream
     {
     protected:
-    
+
         // The number of bytes written to the data output stream so far.
         std::size_t written;
-        
+
     public:
-    
+
         /**
-         * Creates a new data output stream to write data to the specified 
+         * Creates a new data output stream to write data to the specified
          * underlying output stream.
          * @param outputStream a stream to wrap with this one.
          * @param own true if this objects owns the stream that it wraps.
@@ -46,10 +46,10 @@
         DataOutputStream( OutputStream* outputStream, bool own = false );
 
         virtual ~DataOutputStream();
-        
+
         /**
-         * Returns the current value of the counter written, the number of 
-         * bytes written to this data output stream so far. If the counter 
+         * Returns the current value of the counter written, the number of
+         * bytes written to this data output stream so far. If the counter
          * overflows, it will be wrapped to Integer.MAX_VALUE.
          * @return the value of the written field.
          */
@@ -58,15 +58,15 @@
         }
 
         /**
-         * Writes a single byte to the output stream.  If no exception is 
+         * Writes a single byte to the output stream.  If no exception is
          * thrown, the counter written is incremented by 1.
          * @param c the byte.
          * @throws IOException thrown if an error occurs.
          */
         virtual void write( unsigned char c ) throw ( IOException );
-        
+
         /**
-         * Writes an array of bytes to the output stream.  the counter 
+         * Writes an array of bytes to the output stream.  the counter
          * written is incremented by len.
          * @param buffer The array of bytes to write.
          * @param len The number of bytes from the buffer to be written.
@@ -74,40 +74,40 @@
          */
         virtual void write( const unsigned char* buffer, std::size_t len )
             throw ( IOException );
-            
+
         /**
-         * Writes an array of bytes to the output stream.  the counter 
+         * Writes an array of bytes to the output stream.  the counter
          * written is incremented by len.
          * @param buffer The array of bytes to write.
          * @param len The number of bytes from the buffer to be written.
          * @throws IOException thrown if an error occurs.
          */
-        virtual void write( const unsigned char* buffer, 
-                            std::size_t offset, 
+        virtual void write( const unsigned char* buffer,
+                            std::size_t offset,
                             std::size_t len ) throw ( IOException );
-            
+
         /**
          * Writes an array of bytes to the output stream.
          * @param buffer The bytes to write.
          * @throws IOException thrown if an error occurs.
          */
-        virtual void write( const std::vector<unsigned char>& buffer ) 
+        virtual void write( const std::vector<unsigned char>& buffer )
             throw ( IOException );
-        
+
         /**
-         * Writes a boolean to the underlying output stream as a 1-byte value. The 
-         * value true is written out as the value (byte)1; the value false 
-         * is written out as the value (byte)0. If no exception is thrown, 
+         * Writes a boolean to the underlying output stream as a 1-byte value. The
+         * value true is written out as the value (byte)1; the value false
+         * is written out as the value (byte)0. If no exception is thrown,
          * the counter written is incremented by 1.
          * @param value the boolean to write.
          * @throws IOException
-         * 
+         *
          */
         virtual void writeBoolean( bool value ) throw ( IOException );
-        
+
         /**
-         * Writes out a byte to the underlying output stream as a 1-byte 
-         * value. If no exception is thrown, the counter written is 
+         * Writes out a byte to the underlying output stream as a 1-byte
+         * value. If no exception is thrown, the counter written is
          * incremented by 1.
          * @param value the unsigned char value to write.
          * @throws IOException
@@ -115,24 +115,24 @@
         virtual void writeByte( unsigned char value ) throw ( IOException );
 
         /**
-         * Writes a short to the underlying output stream as two bytes, high 
-         * byte first. If no exception is thrown, the counter written is 
+         * Writes a short to the underlying output stream as two bytes, high
+         * byte first. If no exception is thrown, the counter written is
          * incremented by 2.
          * @param value the value to write.
          * @throws IOException
          */
         virtual void writeShort( short value ) throw ( IOException );
-        
+
         /**
          * Writes a unsigned short to the bytes message stream as a 2 byte value
          * @param value - unsigned short to write to the stream
          * @throws IOException
          */
         virtual void writeUnsignedShort( unsigned short value ) throw ( IOException );
-        
+
         /**
-         * Writes out a char to the underlying output stream as a one byte 
-         * value If no exception is thrown, the counter written is 
+         * Writes out a char to the underlying output stream as a one byte
+         * value If no exception is thrown, the counter written is
          * incremented by 1.
          * @param value the value to write.
          * @throws IOException
@@ -140,8 +140,8 @@
         virtual void writeChar( char value ) throw ( IOException );
 
         /**
-         * Writes an int to the underlying output stream as four bytes, high 
-         * byte first. If no exception is thrown, the counter written is 
+         * Writes an int to the underlying output stream as four bytes, high
+         * byte first. If no exception is thrown, the counter written is
          * incremented by 4.
          * @param value the value to write.
          * @throws IOException
@@ -149,8 +149,8 @@
         virtual void writeInt( int value ) throw ( IOException );
 
         /**
-         * Writes an 64 bit long to the underlying output stream as eight 
-         * bytes, high byte first. If no exception is thrown, the counter 
+         * Writes an 64 bit long to the underlying output stream as eight
+         * bytes, high byte first. If no exception is thrown, the counter
          * written is incremented by 8.
          * @param value the value to write.
          * @throws IOException
@@ -158,10 +158,10 @@
         virtual void writeLong( long long value ) throw ( IOException );
 
         /**
-         * Converts the float argument to an int using the floatToIntBits 
-         * method in class Float, and then writes that int value to the 
-         * underlying output stream as a 4-byte quantity, high byte first. 
-         * If no exception is thrown, the counter written is incremented 
+         * Converts the float argument to an int using the floatToIntBits
+         * method in class Float, and then writes that int value to the
+         * underlying output stream as a 4-byte quantity, high byte first.
+         * If no exception is thrown, the counter written is incremented
          * by 4.
          * @param value the value to write.
          * @throws IOException
@@ -169,10 +169,10 @@
         virtual void writeFloat( float value ) throw ( IOException );
 
         /**
-         * Converts the double argument to a long using the doubleToLongBits 
-         * method in class Double, and then writes that long value to the 
-         * underlying output stream as an 8-byte quantity, high byte first. 
-         * If no exception is thrown, the counter written is incremented 
+         * Converts the double argument to a long using the doubleToLongBits
+         * method in class Double, and then writes that long value to the
+         * underlying output stream as an 8-byte quantity, high byte first.
+         * If no exception is thrown, the counter written is incremented
          * by 8.
          * @param value the value to write.
          * @throws IOException
@@ -180,21 +180,24 @@
         virtual void writeDouble( double value ) throw ( IOException );
 
         /**
-         * Writes out the string to the underlying output stream as a 
-         * sequence of bytes. Each character in the string is written out, 
-         * in sequence, by discarding its high eight bits. If no exception 
-         * is thrown, the counter written is incremented by the length of 
-         * value.
+         * Writes out the string to the underlying output stream as a
+         * sequence of bytes. Each character in the string is written out,
+         * in sequence, by discarding its high eight bits. If no exception
+         * is thrown, the counter written is incremented by the length of
+         * value.  The value written does not include a trailing null as that
+         * is not part of the sequence of bytes, if the null is needed, then use
+         * the writeChars method.
          * @param value the value to write.
          * @throws IOException
          */
         virtual void writeBytes( const std::string& value ) throw ( IOException );
 
         /**
-         * Writes a string to the underlying output stream as a sequence of 
-         * characters. Each character is written to the data output stream 
-         * as if by the writeChar method. If no exception is thrown, the 
-         * counter written is incremented by twice the length of value.
+         * Writes a string to the underlying output stream as a sequence of
+         * characters. Each character is written to the data output stream
+         * as if by the writeChar method. If no exception is thrown, the
+         * counter written is incremented by the length of value.  The trailing
+         * NULL charactor is written by this method.
          * @param value the value to write.
          * @throws IOException
          */

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h?view=diff&rev=512268&r1=512267&r2=512268
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h
Tue Feb 27 06:57:08 2007
@@ -44,18 +44,18 @@
         class TestAckHandler : public core::ActiveMQAckHandler
         {
         public:
-        
+
             TestAckHandler() { wasAcked = false; }
             virtual ~TestAckHandler() {}
-            
+
             virtual void acknowledgeMessage( const core::ActiveMQMessage* message AMQCPP_UNUSED)
-                throw ( cms::CMSException ) 
+                throw ( cms::CMSException )
             {
                 wasAcked = true;
             }
-            
+
         public:
-        
+
             bool wasAcked;
 
         };
@@ -70,9 +70,9 @@
             TestAckHandler ackHandler;
             BytesMessageCommand cmd;
 
-            CPPUNIT_ASSERT( cmd.getStompCommandId() == 
+            CPPUNIT_ASSERT( cmd.getStompCommandId() ==
                             CommandConstants::SEND );
-            
+
             CPPUNIT_ASSERT( cmd.isResponseRequired() == false );
             cmd.setResponseRequired( true );
             cmd.setCommandId( 123 );
@@ -82,55 +82,55 @@
             CPPUNIT_ASSERT( cmd.getCorrelationId() == 0 );
             CPPUNIT_ASSERT( cmd.getTransactionId() == "" );
             cmd.setTransactionId( "ID:123456" );
-            CPPUNIT_ASSERT( std::string( cmd.getTransactionId() ) == 
+            CPPUNIT_ASSERT( std::string( cmd.getTransactionId() ) ==
                             "ID:123456" );
             StompTopic topic("testTopic");
             cmd.setCMSDestination( &topic );
-            CPPUNIT_ASSERT( cmd.getCMSDestination()->toProviderString() == 
+            CPPUNIT_ASSERT( cmd.getCMSDestination()->toProviderString() ==
                             "/topic/testTopic" );
-            
+
             StompFrame* frame = cmd.marshal().clone();
-            
+
             CPPUNIT_ASSERT( frame != NULL );
-            
+
             BytesMessageCommand cmd1( frame );
-            
+
             CPPUNIT_ASSERT( cmd.getCommandId() == cmd1.getCommandId() );
             CPPUNIT_ASSERT( cmd.getStompCommandId() == cmd1.getStompCommandId() );
             CPPUNIT_ASSERT( cmd.isResponseRequired() == cmd1.isResponseRequired() );
             CPPUNIT_ASSERT( cmd.getCorrelationId() == cmd1.getCorrelationId() );
             CPPUNIT_ASSERT( std::string(cmd.getTransactionId()) == cmd1.getTransactionId()
);
-            
+
             cmd.setAckHandler( &ackHandler );
             cmd.acknowledge();
             CPPUNIT_ASSERT( ackHandler.wasAcked == true );
-            
-            CPPUNIT_ASSERT( 
+
+            CPPUNIT_ASSERT(
                 cmd.getProperties().hasProperty( "test" ) == false );
             cmd.getProperties().setProperty( "test", "value" );
-            CPPUNIT_ASSERT( 
+            CPPUNIT_ASSERT(
                 cmd.getProperties().hasProperty( "test" ) == true );
-            CPPUNIT_ASSERT( 
+            CPPUNIT_ASSERT(
                 std::string( cmd.getProperties().getProperty( "test" ) ) == "value" );
-                
+
             CPPUNIT_ASSERT( cmd.getCMSCorrelationId() == "" );
             cmd.setCMSCorrelationId( "ID:1234567" );
-            CPPUNIT_ASSERT( std::string( cmd.getCMSCorrelationId() ) == 
+            CPPUNIT_ASSERT( std::string( cmd.getCMSCorrelationId() ) ==
                             "ID:1234567" );
-            CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() == 
+            CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() ==
                             cms::DeliveryMode::PERSISTENT );
             cmd.setCMSDeliveryMode( cms::DeliveryMode::NON_PERSISTENT );
-            CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() == 
+            CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() ==
                             cms::DeliveryMode::NON_PERSISTENT );
             cmd.setCMSDestination( &topic );
-            CPPUNIT_ASSERT( cmd.getCMSDestination()->toProviderString() == 
+            CPPUNIT_ASSERT( cmd.getCMSDestination()->toProviderString() ==
                             "/topic/testTopic" );
             CPPUNIT_ASSERT( cmd.getCMSExpiration() == 0 );
             cmd.setCMSExpiration( 123 );
             CPPUNIT_ASSERT( cmd.getCMSExpiration() == 123 );
             CPPUNIT_ASSERT( cmd.getCMSMessageId() == "" );
             cmd.setCMSMessageId( "ID:1234567" );
-            CPPUNIT_ASSERT( std::string( cmd.getCMSMessageId() ) == 
+            CPPUNIT_ASSERT( std::string( cmd.getCMSMessageId() ) ==
                             "ID:1234567" );
             CPPUNIT_ASSERT( cmd.getCMSPriority() == 0 );
             cmd.setCMSPriority( 5 );
@@ -140,30 +140,30 @@
             CPPUNIT_ASSERT( cmd.getCMSRedelivered() == true );
             CPPUNIT_ASSERT( cmd.getCMSReplyTo() == NULL );
             cmd.setCMSReplyTo( &topic );
-            CPPUNIT_ASSERT( cmd.getCMSReplyTo()->toProviderString() == 
+            CPPUNIT_ASSERT( cmd.getCMSReplyTo()->toProviderString() ==
                             "/topic/testTopic" );
             CPPUNIT_ASSERT( cmd.getCMSTimeStamp() == 0 );
             cmd.setCMSTimeStamp( 123 );
             CPPUNIT_ASSERT( cmd.getCMSTimeStamp() == 123 );
             CPPUNIT_ASSERT( cmd.getCMSMessageType() == "" );
             cmd.setCMSMessageType( "test" );
-            CPPUNIT_ASSERT( std::string( cmd.getCMSMessageType() ) == 
+            CPPUNIT_ASSERT( std::string( cmd.getCMSMessageType() ) ==
                             "test" );
             CPPUNIT_ASSERT( cmd.getRedeliveryCount() == 0 );
             cmd.setRedeliveryCount( 123 );
             CPPUNIT_ASSERT( cmd.getRedeliveryCount() == 123 );
-            
+
             const char* bodyBytes = "TESTBODYBYTES\0";
             CPPUNIT_ASSERT( cmd.getBodyLength() == 0 );
-            cmd.setBodyBytes( (const unsigned char*)bodyBytes, 
+            cmd.setBodyBytes( (const unsigned char*)bodyBytes,
                               strlen( bodyBytes ) + 1 );
-            CPPUNIT_ASSERT( cmd.getBodyLength() == 
+            CPPUNIT_ASSERT( cmd.getBodyLength() ==
                             (unsigned int)strlen( bodyBytes ) + 1 );
-            CPPUNIT_ASSERT( std::string( (const char*)cmd.getBodyBytes() ) == 
+            CPPUNIT_ASSERT( std::string( (const char*)cmd.getBodyBytes() ) ==
                             bodyBytes );
 
             cms::Message* cmd2 = cmd.clone();
-            
+
             CPPUNIT_ASSERT( cmd.getCMSPriority() == cmd2->getCMSPriority() );
             CPPUNIT_ASSERT( cmd.getCMSTimeStamp() == cmd2->getCMSTimeStamp() );
             CPPUNIT_ASSERT( cmd.getCMSExpiration() == cmd2->getCMSExpiration() );
@@ -173,14 +173,14 @@
             CPPUNIT_ASSERT( std::string(cmd.getCMSMessageType()) == cmd2->getCMSMessageType()
);
             CPPUNIT_ASSERT( std::string(cmd.getCMSMessageId()) == cmd2->getCMSMessageId()
);
 
-            core::ActiveMQMessage* message = 
+            core::ActiveMQMessage* message =
                 dynamic_cast< core::ActiveMQMessage* >( cmd2 );
-                
+
             CPPUNIT_ASSERT( message != NULL );
-            CPPUNIT_ASSERT( cmd.getRedeliveryCount() == 
+            CPPUNIT_ASSERT( cmd.getRedeliveryCount() ==
                             message->getRedeliveryCount() );
-            
-            StompCommand* cmd4 = 
+
+            StompCommand* cmd4 =
                 dynamic_cast< StompCommand* >( cmd2 );
 
             CPPUNIT_ASSERT( cmd4 != NULL );
@@ -188,26 +188,26 @@
             CPPUNIT_ASSERT( cmd.getStompCommandId() == cmd4->getStompCommandId() );
             CPPUNIT_ASSERT( cmd.isResponseRequired() == cmd4->isResponseRequired() );
             CPPUNIT_ASSERT( cmd.getCorrelationId() == cmd4->getCorrelationId() );
-            CPPUNIT_ASSERT( std::string(cmd.getTransactionId()) == 
+            CPPUNIT_ASSERT( std::string(cmd.getTransactionId()) ==
                             cmd4->getTransactionId() );
 
-            BytesMessageCommand* cmd5 = 
+            BytesMessageCommand* cmd5 =
                 dynamic_cast< BytesMessageCommand* >( cmd2 );
 
             CPPUNIT_ASSERT( cmd5 != NULL );
-            CPPUNIT_ASSERT( std::string( (const char*)cmd.getBodyBytes() ) == 
+            CPPUNIT_ASSERT( std::string( (const char*)cmd.getBodyBytes() ) ==
                             (const char*)cmd5->getBodyBytes() );
 
             delete cmd2;
         }
-        
+
         void testReadOnly(){
-            
+
             StompFrame* frame = new StompFrame();
             frame->setCommand( CommandConstants::toString( CommandConstants::MESSAGE )
);
-            frame->getProperties().setProperty( CommandConstants::toString( CommandConstants::HEADER_DESTINATION
), 
+            frame->getProperties().setProperty( CommandConstants::toString( CommandConstants::HEADER_DESTINATION
),
                 (std::string)CommandConstants::topicPrefix + "mytopic" );
-            
+
             // write a bunch of values to the frame's body.
             io::ByteArrayOutputStream os( frame->getBody() );
             io::DataOutputStream dos(&os);
@@ -220,80 +220,80 @@
             dos.writeUnsignedShort( 5 );
             dos.writeInt( 6 );
             dos.writeLong( 7LL );
-            dos.writeBytes( "hello world" );
-            
+            dos.writeChars( "hello world" );
+
             // Assign the frame to the bytes message.
             BytesMessageCommand cmd(frame);
-            
+
             // First, verify that we can't write (read-only)
-            
+
             try{
                 cmd.setBodyBytes( (unsigned char*)"test", 5 );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeBoolean( true );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeByte( 2 );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeBytes( std::vector<unsigned char>() );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeBytes( (unsigned char*)"test", 0, 5 );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeChar( 'a' );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeFloat( 1.0f );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeDouble( 1.0 );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeUnsignedShort( 3 );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeShort( 4 );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeInt( 5 );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeLong( 6LL );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.writeString( "test" );
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             // Now, verify that all the reads work properly
-            
+
             CPPUNIT_ASSERT( cmd.readBoolean() == true );
             CPPUNIT_ASSERT( cmd.readByte() == 1 );
             CPPUNIT_ASSERT( cmd.readChar() == 'a' );
@@ -305,71 +305,71 @@
             CPPUNIT_ASSERT( cmd.readLong() == 7LL );
             CPPUNIT_ASSERT( cmd.readString() == "hello world" );
         }
-        
+
         void testWriteOnly(){
-            
+
             BytesMessageCommand cmd;
-            
+
             // First, verify that we can't read (write-only)
-            
+
             try{
                 cmd.readBoolean();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.readByte();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 std::vector<unsigned char> buf;
                 cmd.readBytes(buf);
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.readChar();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.readFloat();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.readDouble();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.readUnsignedShort();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.readShort();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.readInt();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.readLong();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             try{
                 cmd.readString();
                 CPPUNIT_ASSERT( false );
             } catch( exceptions::IllegalStateException& e ){}
-            
+
             // Now, verify that all the writes work properly
-            
+
             cmd.writeBoolean( true );
             cmd.writeByte( 1 );
             cmd.writeChar( 'a' );
@@ -380,10 +380,10 @@
             cmd.writeInt( 6 );
             cmd.writeLong( 7LL );
             cmd.writeString( "hello world" );
-            
+
             // Switch to read-only mode.
             cmd.reset();
-            
+
             CPPUNIT_ASSERT( cmd.readBoolean() == true );
             CPPUNIT_ASSERT( cmd.readByte() == 1 );
             CPPUNIT_ASSERT( cmd.readChar() == 'a' );



Mime
View raw message