Author: tabish Date: Sun Jan 21 11:56:19 2007 New Revision: 498437 URL: http://svn.apache.org/viewvc?view=rev&rev=498437 Log: http://issues.apache.org/activemq/browse/AMQCPP-30 Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp?view=diff&rev=498437&r1=498436&r2=498437 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp Sun Jan 21 11:56:19 2007 @@ -48,14 +48,14 @@ } else { - dataOut.write( map->size() ); + dataOut.writeInt( map->size() ); std::vector keys = map->getKeys(); std::vector::const_iterator iter = keys.begin(); for(; iter != keys.end(); ++iter ) { - - dataOut.writeChars( *iter ); + + OpenwireStringSupport::writeString( dataOut, &(*iter) ); PrimitiveMap::ValueNode value = map->getValue( *iter ); marshalPrimitive( dataOut, value ); } @@ -83,7 +83,7 @@ for( int i=0; i < size; i++ ) { - std::string key = dataIn.readString(); + std::string key = OpenwireStringSupport::readString( dataIn ); unmarshalPrimitive( dataIn, key, *map ); } Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp?view=diff&rev=498437&r1=498436&r2=498437 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp Sun Jan 21 11:56:19 2007 @@ -24,6 +24,9 @@ using namespace std; using namespace activemq; +using namespace activemq::util; +using namespace activemq::io; +using namespace activemq::exceptions; using namespace activemq::connector; using namespace activemq::connector::openwire; using namespace activemq::connector::openwire::marshal; @@ -31,9 +34,62 @@ //////////////////////////////////////////////////////////////////////////////// void PrimitiveMapMarshallerTest::test() { -} + PrimitiveMap myMap; -//////////////////////////////////////////////////////////////////////////////// -void PrimitiveMapMarshallerTest::test2() -{ + unsigned char byteValue = 'A'; + char charValue = 'B'; + bool booleanValue = true; + short shortValue = 2048; + int intValue = 655369; + long long longValue = 0xFFFFFFFF00000000ULL; + float floatValue = 45.6545f; + double doubleValue = 654564.654654; + std::string stringValue = "The test string"; + + myMap.setString( "stringKey", stringValue ); + myMap.setBool( "boolKey", booleanValue ); + myMap.setByte( "byteKey", byteValue ); + myMap.setChar( "charKey", charValue ); + myMap.setShort( "shortKey", shortValue ); + myMap.setInt( "intKey", intValue ); + myMap.setLong( "longKey", longValue ); + myMap.setFloat( "floatKey", floatValue ); + myMap.setDouble( "doubleKey", doubleValue ); + + std::vector bytes; + bytes.push_back( 65 ); + bytes.push_back( 66 ); + bytes.push_back( 67 ); + bytes.push_back( 68 ); + bytes.push_back( 69 ); + myMap.setByteArray( "bytesKey", bytes ); + + std::vector marshaled; + + // Turn it into some bytes + PrimitiveMapMarshaller::marshal( &myMap, marshaled ); + + // Try and get it back from those bytes. + PrimitiveMap* newMap = NULL; + + try { + newMap = PrimitiveMapMarshaller::unmarshal( marshaled ); + } catch(...) { + CPPUNIT_ASSERT( false ); + } + + CPPUNIT_ASSERT( newMap != NULL ); + + CPPUNIT_ASSERT( myMap.getString( "stringKey" ) == stringValue ); + CPPUNIT_ASSERT( myMap.getBool( "boolKey" ) == booleanValue ); + CPPUNIT_ASSERT( myMap.getByte( "byteKey" ) == byteValue ); + CPPUNIT_ASSERT( myMap.getChar( "charKey" ) == charValue ); + CPPUNIT_ASSERT( myMap.getShort( "shortKey" ) == shortValue ); + CPPUNIT_ASSERT( myMap.getInt( "intKey" ) == intValue ); + CPPUNIT_ASSERT( myMap.getLong( "longKey" ) == longValue ); + CPPUNIT_ASSERT( myMap.getFloat( "floatKey" ) == floatValue ); + CPPUNIT_ASSERT( myMap.getDouble( "doubleKey" ) == doubleValue ); + CPPUNIT_ASSERT( myMap.getByteArray( "bytesKey" ) == bytes ); + + delete newMap; } Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h?view=diff&rev=498437&r1=498436&r2=498437 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h Sun Jan 21 11:56:19 2007 @@ -30,7 +30,6 @@ CPPUNIT_TEST_SUITE( PrimitiveMapMarshallerTest ); CPPUNIT_TEST( test ); - CPPUNIT_TEST( test2 ); CPPUNIT_TEST_SUITE_END(); public: @@ -39,7 +38,6 @@ virtual ~PrimitiveMapMarshallerTest() {} void test(); - void test2(); };