Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 45441 invoked from network); 28 Jun 2007 14:25:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jun 2007 14:25:11 -0000 Received: (qmail 75363 invoked by uid 500); 28 Jun 2007 14:25:14 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 75341 invoked by uid 500); 28 Jun 2007 14:25:14 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 75332 invoked by uid 99); 28 Jun 2007 14:25:14 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jun 2007 07:25:14 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jun 2007 07:25:10 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 5246B1A981D; Thu, 28 Jun 2007 07:24:50 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r551573 - in /activemq/activemq-cpp/trunk/src/decaf/src/test/decaf: io/DataInputStreamTest.cpp io/DataInputStreamTest.h net/SocketFactoryTest.cpp net/SocketTest.cpp Date: Thu, 28 Jun 2007 14:24:50 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070628142450.5246B1A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Thu Jun 28 07:24:49 2007 New Revision: 551573 URL: http://svn.apache.org/viewvc?view=rev&rev=551573 Log: http://issues.apache.org/activemq/browse/AMQCPP-103 Building Decaf lib Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp?view=diff&rev=551573&r1=551572&r2=551573 ============================================================================== --- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp Thu Jun 28 07:24:49 2007 @@ -109,3 +109,79 @@ //std::cout << "char[2] Value = " << (int)arrayVal[2] << std::endl; CPPUNIT_ASSERT( arrayVal[2] == 'c' ); } + +void DataInputStreamTest::testString() { + + std::string data1 = "This is a Test"; + std::string data2 = "of the readString method"; + std::string data3 = "This one should fail"; + + std::vector buffer; + + buffer.insert( buffer.begin(), data1.begin(), data1.end() ); + buffer.push_back( '\0' ); + buffer.insert( buffer.end(), data2.begin(), data2.end() ); + buffer.push_back( '\0' ); + buffer.insert( buffer.end(), data3.begin(), data3.end() ); + + // Create the stream with the buffer we just wrote to. + ByteArrayInputStream myStream( buffer ); + DataInputStream reader( &myStream ); + + std::string result1 = reader.readString(); + std::string result2 = reader.readString(); + + CPPUNIT_ASSERT( result1 == data1 ); + CPPUNIT_ASSERT( result2 == data2 ); + + try{ + std::string result3 = reader.readString(); + CPPUNIT_ASSERT( false ); + } catch(...){ + CPPUNIT_ASSERT( true ); + } +} + +void DataInputStreamTest::testUTF() { + + std::string data1 = "This is a Test"; + std::string data2 = "of the readString method"; + std::string data3 = "This one should fail"; + + char sizeData[sizeof(short)] = {0}; + short tempShort = 0; + + std::vector buffer; + + tempShort = util::Endian::byteSwap( ((unsigned short)data1.size()) ); + memcpy( sizeData, (char*)&tempShort, sizeof( short ) ); + buffer.insert( buffer.end(), sizeData, sizeData + sizeof(short) ); + buffer.insert( buffer.end(), data1.begin(), data1.end() ); + + tempShort = util::Endian::byteSwap( ((unsigned short)data2.size()) ); + memcpy( sizeData, (char*)&tempShort, sizeof( short ) ); + buffer.insert( buffer.end(), sizeData, sizeData + sizeof(short) ); + buffer.insert( buffer.end(), data2.begin(), data2.end() ); + + tempShort = util::Endian::byteSwap( (unsigned short)(data3.size() + 10 ) ); + memcpy( sizeData, (char*)&tempShort, sizeof( short ) ); + buffer.insert( buffer.end(), sizeData, sizeData + sizeof(short) ); + buffer.insert( buffer.end(), data3.begin(), data3.end() ); + + // Create the stream with the buffer we just wrote to. + ByteArrayInputStream myStream( buffer ); + DataInputStream reader( &myStream ); + + std::string result1 = reader.readUTF(); + std::string result2 = reader.readUTF(); + + CPPUNIT_ASSERT( result1 == data1 ); + CPPUNIT_ASSERT( result2 == data2 ); + + try{ + std::string result3 = reader.readUTF(); + CPPUNIT_ASSERT( false ); + } catch(...){ + CPPUNIT_ASSERT( true ); + } +} Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h?view=diff&rev=551573&r1=551572&r2=551573 ============================================================================== --- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h (original) +++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h Thu Jun 28 07:24:49 2007 @@ -40,6 +40,8 @@ CPPUNIT_TEST_SUITE( DataInputStreamTest ); CPPUNIT_TEST( test ); + CPPUNIT_TEST( testString ); + CPPUNIT_TEST( testUTF ); CPPUNIT_TEST_SUITE_END(); public: @@ -49,6 +51,8 @@ virtual void tearDown(){} void test(); + void testString(); + void testUTF(); }; Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp?view=diff&rev=551573&r1=551572&r2=551573 ============================================================================== --- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp Thu Jun 28 07:24:49 2007 @@ -17,7 +17,7 @@ #include "SocketFactoryTest.h" -CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketFactoryTest ); +//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketFactoryTest ); #include #include Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp?view=diff&rev=551573&r1=551572&r2=551573 ============================================================================== --- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp Thu Jun 28 07:24:49 2007 @@ -17,7 +17,7 @@ #include "SocketTest.h" -CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketTest ); +//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketTest ); #include