Author: tabish Date: Sat May 31 17:42:24 2008 New Revision: 662112 URL: http://svn.apache.org/viewvc?rev=662112&view=rev Log: http://issues.apache.org/activemq/browse/AMQCPP-172 Modified: activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h Modified: activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp?rev=662112&r1=662111&r2=662112&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp Sat May 31 17:42:24 2008 @@ -18,6 +18,7 @@ #include "PrimitiveMapMarshallerTest.h" #include +#include #include using namespace std; @@ -30,8 +31,8 @@ using namespace activemq::connector::openwire::marshal; //////////////////////////////////////////////////////////////////////////////// -void PrimitiveMapMarshallerTest::test() -{ +void PrimitiveMapMarshallerTest::test() { + PrimitiveMap myMap; unsigned char byteValue = 'A'; @@ -91,3 +92,76 @@ delete newMap; } + +//////////////////////////////////////////////////////////////////////////////// +void PrimitiveMapMarshallerTest::testLists() { + + PrimitiveMap myMap; + + PrimitiveList list1; + PrimitiveList list2; + PrimitiveList list3; + + list1.add( 1 ); + list2.add( 2 ); + list3.add( 3 ); + + myMap.setValue( "1", list1 ); + myMap.setValue( "2", list2 ); + myMap.setValue( "3", list3 ); + + 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 ); + + std::cout << std::endl << "Deleting Map" << std::endl; + delete newMap; +} + +//////////////////////////////////////////////////////////////////////////////// +void PrimitiveMapMarshallerTest::testMaps() { + + PrimitiveMap myMap; + + PrimitiveMap map1; + PrimitiveMap map2; + PrimitiveMap map3; + + map1.setValue( "1", 1 ); + map2.setValue( "2", 2 ); + map3.setValue( "3", 3 ); + + myMap.setValue( "1", map1 ); + myMap.setValue( "2", map2 ); + myMap.setValue( "3", map3 ); + + 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 ); + + delete newMap; +} Modified: activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h?rev=662112&r1=662111&r2=662112&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h (original) +++ activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h Sat May 31 17:42:24 2008 @@ -25,20 +25,24 @@ namespace connector{ namespace openwire{ namespace marshal{ - + class PrimitiveMapMarshallerTest : public CppUnit::TestFixture { - + CPPUNIT_TEST_SUITE( PrimitiveMapMarshallerTest ); CPPUNIT_TEST( test ); + CPPUNIT_TEST( testLists ); + //CPPUNIT_TEST( testMaps ); CPPUNIT_TEST_SUITE_END(); public: - + PrimitiveMapMarshallerTest() {} virtual ~PrimitiveMapMarshallerTest() {} void test(); - + void testLists(); + void testMaps(); + }; }}}}