activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r596502 - in /activemq/activemq-cpp/decaf/trunk/src: main/decaf/internal/util/ByteArray.cpp test/decaf/internal/util/ByteArrayTest.cpp test/decaf/internal/util/ByteArrayTest.h test/testRegistry.cpp
Date Tue, 20 Nov 2007 00:47:07 GMT
Author: tabish
Date: Mon Nov 19 16:47:05 2007
New Revision: 596502

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

Working on the NIO package

Modified:
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.h
    activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.cpp?rev=596502&r1=596501&r2=596502&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/util/ByteArray.cpp Mon Nov 19
16:47:05 2007
@@ -184,8 +184,8 @@
 
         return this->array[index];
     }
-    DECAF_CATCH_RETHROW( InvalidStateException )
-    DECAF_CATCHALL_THROW( InvalidStateException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IndexOutOfBoundsException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -202,6 +202,6 @@
 
         return this->array[index];
     }
-    DECAF_CATCH_RETHROW( InvalidStateException )
-    DECAF_CATCHALL_THROW( InvalidStateException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IndexOutOfBoundsException )
 }

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.cpp?rev=596502&r1=596501&r2=596502&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.cpp Mon Nov
19 16:47:05 2007
@@ -20,40 +20,231 @@
 using namespace decaf;
 using namespace decaf::internal;
 using namespace decaf::internal::util;
+using namespace decaf::nio;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayTest::testRead(){
 
+    unsigned char* data = new unsigned char[256];
+    for( int i = 0; i < 256; ++i ) {
+        data[i] = i;
+    }
+
+    ByteArray array( data, 256 );
+
+    CPPUNIT_ASSERT( array.getCapacity() == 256 );
+
+    unsigned char* result = new unsigned char[256];
+    array.read( result, 0, 256 );
+
+    for( int i = 0; i < 256; ++i ){
+        CPPUNIT_ASSERT( data[i] == result[i] );
+    }
+
+    delete data;
+    delete result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayTest::testWrite(){
 
+    unsigned char* data = new unsigned char[256];
+    for( int i = 0; i < 256; ++i ) {
+        data[i] = i;
+    }
+
+    ByteArray array( (std::size_t)256 );
+
+    CPPUNIT_ASSERT( array.getCapacity() == 256 );
+
+    array.write( data, 0, 256 );
+    unsigned char* result = new unsigned char[256];
+    array.read( result, 0, 256 );
+
+    for( int i = 0; i < 256; ++i ){
+        CPPUNIT_ASSERT( data[i] == result[i] );
+    }
+
+    delete data;
+    delete result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayTest::testCtor1(){
 
+    ByteArray array1( (std::size_t)256 );
+    CPPUNIT_ASSERT( array1.getCapacity() == 256 );
+    ByteArray array2( (std::size_t)54 );
+    CPPUNIT_ASSERT( array2.getCapacity() == 54 );
+    ByteArray array3( (std::size_t)5555 );
+    CPPUNIT_ASSERT( array3.getCapacity() == 5555 );
+    ByteArray array4( (std::size_t)0 );
+    CPPUNIT_ASSERT( array4.getCapacity() == 0 );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayTest::testCtor2(){
 
+    unsigned char* data1 = new unsigned char[256];
+    unsigned char* data2 = new unsigned char[999];
+    unsigned char* data3 = new unsigned char[12];
+    unsigned char* data4 = new unsigned char[0];
+
+    ByteArray array1( data1, 256, true );
+    ByteArray array2( data2, 999, true );
+    ByteArray array3( data3, 10, true );
+    ByteArray array4( data4, 0, true );
+
+    CPPUNIT_ASSERT( array1.getCapacity() == 256 );
+    CPPUNIT_ASSERT( array2.getCapacity() == 999 );
+    CPPUNIT_ASSERT( array3.getCapacity() == 10 );
+    CPPUNIT_ASSERT( array4.getCapacity() == 0 );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayTest::testClear(){
 
+    unsigned char* data = new unsigned char[256];
+    for( int i = 0; i < 256; ++i ) {
+        data[i] = i;
+    }
+
+    ByteArray array( (std::size_t)256 );
+
+    CPPUNIT_ASSERT( array.getCapacity() == 256 );
+
+    array.write( data, 0, 256 );
+    unsigned char* result = new unsigned char[256];
+    array.read( result, 0, 256 );
+
+    for( int i = 0; i < 256; ++i ){
+        CPPUNIT_ASSERT( data[i] == result[i] );
+    }
+
+    array.clear();
+    array.read( result, 0, 256 );
+
+    for( int i = 0; i < 256; ++i ){
+        CPPUNIT_ASSERT( result[i] == 0 );
+    }
+
+    delete data;
+    delete result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayTest::testReszie(){
 
+    unsigned char* data = new unsigned char[256];
+    for( int i = 0; i < 256; ++i ) {
+        data[i] = i;
+    }
+
+    ByteArray array( (std::size_t)256 );
+
+    CPPUNIT_ASSERT( array.getCapacity() == 256 );
+
+    array.write( data, 0, 256 );
+    unsigned char* result = new unsigned char[256];
+    array.read( result, 0, 256 );
+
+    for( int i = 0; i < 256; ++i ){
+        CPPUNIT_ASSERT( data[i] == result[i] );
+    }
+
+    array.resize( 128 );
+    CPPUNIT_ASSERT( array.getCapacity() == 128 );
+    unsigned char* result2 = new unsigned char[128];
+    array.read( result2, 0, 128 );
+
+    for( int i = 0; i < 128; ++i ){
+        CPPUNIT_ASSERT( result[i] == data[i] );
+    }
+
+    delete result;
+    delete result2;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayTest::testOperators(){
 
+    unsigned char* data = new unsigned char[256];
+    for( int i = 0; i < 256; ++i ) {
+        data[i] = i;
+    }
+
+    ByteArray array( data, 256 );
+
+    CPPUNIT_ASSERT( array.getCapacity() == 256 );
+
+    for( int i = 0; i < 256; ++i ){
+        CPPUNIT_ASSERT( data[i] == array[i] );
+    }
+
+    delete data;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteArrayTest::testReadExceptions() {
+
+    unsigned char* data = new unsigned char[256];
+    for( int i = 0; i < 256; ++i ) {
+        data[i] = i;
+    }
+
+    ByteArray array( data, 256, true );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should Throw NullPointerException",
+        array.read( NULL, 0, 500 ),
+        NullPointerException );
+
+    unsigned char result[5000];
+    ByteArray array2( 256 );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should Throw BufferUnderflowException",
+        array.read( result, 0, 500 ),
+        BufferUnderflowException );
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteArrayTest::testWriteExceptions() {
+
+    unsigned char* data = new unsigned char[256];
+    for( int i = 0; i < 256; ++i ) {
+        data[i] = i;
+    }
+
+    ByteArray array( data, 256, true );
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should Throw NullPointerException",
+        array.write( NULL, 0, 500 ),
+        NullPointerException );
+
+    unsigned char result[5000];
+    ByteArray array2( 256 );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should Throw BufferOverflowException",
+        array.write( result, 0, 500 ),
+        BufferOverflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteArrayTest::testOperatorsExceptions() {
+
+    unsigned char* data = new unsigned char[256];
+    for( int i = 0; i < 256; ++i ) {
+        data[i] = i;
+    }
+
+    ByteArray array( data, 256, true );
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should Throw IndexOutOfBoundsException",
+        array[9999],
+        IndexOutOfBoundsException );
 }

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.h?rev=596502&r1=596501&r2=596502&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/util/ByteArrayTest.h Mon Nov
19 16:47:05 2007
@@ -32,12 +32,15 @@
 
         CPPUNIT_TEST_SUITE( ByteArrayTest );
         CPPUNIT_TEST( testRead );
+        CPPUNIT_TEST( testReadExceptions );
         CPPUNIT_TEST( testWrite );
+        CPPUNIT_TEST( testWriteExceptions );
         CPPUNIT_TEST( testCtor1 );
         CPPUNIT_TEST( testCtor2 );
         CPPUNIT_TEST( testClear );
         CPPUNIT_TEST( testReszie );
         CPPUNIT_TEST( testOperators );
+        CPPUNIT_TEST( testOperatorsExceptions );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -52,6 +55,9 @@
         virtual void testClear();
         virtual void testReszie();
         virtual void testOperators();
+        virtual void testReadExceptions();
+        virtual void testWriteExceptions();
+        virtual void testOperatorsExceptions();
 
     };
 

Modified: activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp?rev=596502&r1=596501&r2=596502&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp Mon Nov 19 16:47:05 2007
@@ -18,33 +18,36 @@
 // All CPP Unit tests are registered in here so we can disable them and
 // enable them easily in one place.
 
-#include <decaf/io/FilterInputStreamTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::FilterInputStreamTest );
-#include <decaf/io/FilterOutputStreamTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::FilterOutputStreamTest );
-#include <decaf/io/BufferedInputStreamTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::BufferedInputStreamTest );
-#include <decaf/io/BufferedOutputStreamTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::BufferedOutputStreamTest );
-#include <decaf/io/ByteArrayInputStreamTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::ByteArrayInputStreamTest );
-#include <decaf/io/ByteArrayOutputStreamTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::ByteArrayOutputStreamTest );
-#include <decaf/io/DataInputStreamTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::DataInputStreamTest );
-#include <decaf/io/DataOutputStreamTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::DataOutputStreamTest );
+#include <decaf/internal/util/ByteArrayTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::util::ByteArrayTest );
 
-#include <decaf/lang/MathTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::MathTest );
-#include <decaf/lang/ByteTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ByteTest );
-#include <decaf/lang/CharacterTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::CharacterTest );
-#include <decaf/lang/BooleanTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::BooleanTest );
-#include <decaf/lang/ShortTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ShortTest );
+//#include <decaf/io/FilterInputStreamTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::FilterInputStreamTest );
+//#include <decaf/io/FilterOutputStreamTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::FilterOutputStreamTest );
+//#include <decaf/io/BufferedInputStreamTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::BufferedInputStreamTest );
+//#include <decaf/io/BufferedOutputStreamTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::BufferedOutputStreamTest );
+//#include <decaf/io/ByteArrayInputStreamTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::ByteArrayInputStreamTest );
+//#include <decaf/io/ByteArrayOutputStreamTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::ByteArrayOutputStreamTest );
+//#include <decaf/io/DataInputStreamTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::DataInputStreamTest );
+//#include <decaf/io/DataOutputStreamTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::DataOutputStreamTest );
+
+//#include <decaf/lang/MathTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::MathTest );
+//#include <decaf/lang/ByteTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ByteTest );
+//#include <decaf/lang/CharacterTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::CharacterTest );
+//#include <decaf/lang/BooleanTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::BooleanTest );
+//#include <decaf/lang/ShortTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ShortTest );
 //#include <decaf/lang/IntegerTest.h>
 //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::IntegerTest );
 //#include <decaf/lang/LongTest.h>
@@ -60,33 +63,33 @@
 //#include <decaf/lang/SystemTest.h>
 //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::SystemTest );
 //
-#include <decaf/net/SocketFactoryTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketFactoryTest );
-#include <decaf/net/SocketTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketTest );
+//#include <decaf/net/SocketFactoryTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketFactoryTest );
+//#include <decaf/net/SocketTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketTest );
 //#include <decaf/net/URITest.h>
 //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::URITest );
 //#include <decaf/net/URISyntaxExceptionTest.h>
 //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::URISyntaxExceptionTest );
 //
-#include <decaf/util/concurrent/CountDownLatchTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::CountDownLatchTest );
-#include <decaf/util/concurrent/MutexTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::MutexTest );
-#include <decaf/util/concurrent/ThreadPoolTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::ThreadPoolTest );
+//#include <decaf/util/concurrent/CountDownLatchTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::CountDownLatchTest );
+//#include <decaf/util/concurrent/MutexTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::MutexTest );
+//#include <decaf/util/concurrent/ThreadPoolTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::ThreadPoolTest );
 
-#include <decaf/util/DateTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::DateTest );
-#include <decaf/util/UUIDTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::UUIDTest );
-#include <decaf/util/MapTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::MapTest );
-#include <decaf/util/QueueTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::QueueTest );
-#include <decaf/util/RandomTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::RandomTest );
-#include <decaf/util/SetTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::SetTest );
-#include <decaf/util/StringTokenizerTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::StringTokenizerTest );
+//#include <decaf/util/DateTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::DateTest );
+//#include <decaf/util/UUIDTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::UUIDTest );
+//#include <decaf/util/MapTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::MapTest );
+//#include <decaf/util/QueueTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::QueueTest );
+//#include <decaf/util/RandomTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::RandomTest );
+//#include <decaf/util/SetTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::SetTest );
+//#include <decaf/util/StringTokenizerTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::StringTokenizerTest );



Mime
View raw message