activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r915018 [4/4] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/activemq/commands/ main/activemq/io/ main/activemq/wireformat/openwire/marshal/ main/activemq/wireformat/openwire/utils/ main/decaf/internal/io/ main/decaf/io/ mai...
Date Mon, 22 Feb 2010 19:02:36 GMT
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp Mon Feb 22 19:02:35 2010
@@ -66,7 +66,7 @@
     bos.reset();
 
     for( int iy = 0; iy < numRuns; ++iy ){
-        bos.write( stlBuffer );
+        bos.write( &stlBuffer[0], bufferSize );
     }
     bos.reset();
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am Mon Feb 22 19:02:35 2010
@@ -91,6 +91,8 @@
     decaf/io/FilterInputStreamTest.cpp \
     decaf/io/FilterOutputStreamTest.cpp \
     decaf/io/InputStreamReaderTest.cpp \
+    decaf/io/InputStreamTest.cpp \
+    decaf/io/OutputStreamTest.cpp \
     decaf/io/OutputStreamWriterTest.cpp \
     decaf/io/ReaderTest.cpp \
     decaf/io/WriterTest.cpp \
@@ -229,6 +231,8 @@
     decaf/io/FilterInputStreamTest.h \
     decaf/io/FilterOutputStreamTest.h \
     decaf/io/InputStreamReaderTest.h \
+    decaf/io/InputStreamTest.h \
+    decaf/io/OutputStreamTest.h \
     decaf/io/OutputStreamWriterTest.h \
     decaf/io/ReaderTest.h \
     decaf/io/WriterTest.h \

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.cpp Mon Feb 22 19:02:35 2010
@@ -16,6 +16,8 @@
  */
 
 #include "BufferedInputStreamTest.h"
+
+#include <decaf/lang/Integer.h>
 #include <decaf/io/ByteArrayInputStream.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
 
@@ -33,8 +35,49 @@
 using namespace decaf::io;
 using namespace decaf::util;
 
-namespace decaf{
-namespace io{
+////////////////////////////////////////////////////////////////////////////////
+const std::string BufferedInputStreamTest::testString =
+    "Test_All_Tests\nTest_BufferedInputStream\nTest_java_io_BufferedOutputStream\n"
+    "Test_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\n"
+    "Test_java_io_DataInputStream\nTest_java_io_File\nTest_java_io_FileDescriptor\n"
+    "Test_java_io_FileInputStream\nTest_java_io_FileNotFoundException\nTest_java_io_FileOutputStream\n"
+    "Test_java_io_FilterInputStream\nTest_java_io_FilterOutputStream\nTest_java_io_InputStream\n"
+    "Test_java_io_IOException\nTest_java_io_OutputStream\nTest_java_io_PrintStream\n"
+    "Test_java_io_RandomAccessFile\nTest_java_io_SyncFailedException\nTest_java_lang_AbstractMethodError\n"
+    "Test_java_lang_ArithmeticException\nTest_java_lang_ArrayIndexOutOfBoundsException\n"
+    "Test_java_lang_ArrayStoreException\nTest_java_lang_Boolean\nTest_java_lang_Byte\n"
+    "Test_java_lang_Character\nTest_java_lang_Class\nTest_java_lang_ClassCastException\n"
+    "Test_java_lang_ClassCircularityError\nTest_java_lang_ClassFormatError\n"
+    "Test_java_lang_ClassLoader\nTest_java_lang_ClassNotFoundException\n"
+    "Test_java_lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_java_lang_Error\n"
+    "Test_java_lang_Exception\nTest_java_lang_ExceptionInInitializerError\nTest_java_lang_Float\n"
+    "Test_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\n"
+    "Test_java_lang_IllegalArgumentException\nTest_java_lang_IllegalMonitorStateException\n"
+    "Test_java_lang_IllegalThreadStateException\nTest_java_lang_IncompatibleClassChangeError\n"
+    "Test_java_lang_IndexOutOfBoundsException\nTest_java_lang_InstantiationError\n"
+    "Test_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_lang_InternalError\n"
+    "Test_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_java_lang_Long\n"
+    "Test_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_lang_NoClassDefFoundError\n"
+    "Test_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\n"
+    "Test_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_lang_NumberFormatException\n"
+    "Test_java_lang_Object\nTest_java_lang_OutOfMemoryError\nTest_java_lang_RuntimeException\n"
+    "Test_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_StackOverflowError\n"
+    "Test_java_lang_String\nTest_java_lang_StringBuffer\nTest_java_lang_StringIndexOutOfBoundsException\n"
+    "Test_java_lang_System\nTest_java_lang_Thread\nTest_java_lang_ThreadDeath\nTest_java_lang_ThreadGroup\n"
+    "Test_java_lang_Throwable\nTest_java_lang_UnknownError\nTest_java_lang_UnsatisfiedLinkError\n"
+    "Test_java_lang_VerifyError\nTest_java_lang_VirtualMachineError\nTest_java_lang_vm_Image\n"
+    "Test_java_lang_vm_MemorySegment\nTest_java_lang_vm_ROMStoreException\n"
+    "Test_java_lang_vm_VM\nTest_java_lang_Void\nTest_java_net_BindException\n"
+    "Test_java_net_ConnectException\nTest_java_net_DatagramPacket\nTest_java_net_DatagramSocket\n"
+    "Test_java_net_DatagramSocketImpl\nTest_java_net_InetAddress\nTest_java_net_NoRouteToHostException\n"
+    "Test_java_net_PlainDatagramSocketImpl\nTest_java_net_PlainSocketImpl\nTest_java_net_Socket\n"
+    "Test_java_net_SocketException\nTest_java_net_SocketImpl\nTest_java_net_SocketInputStream\n"
+    "Test_java_net_SocketOutputStream\nTest_java_net_UnknownHostException\nTest_java_util_ArrayEnumerator\n"
+    "Test_java_util_Date\nTest_java_util_EventObject\nTest_java_util_HashEnumerator\nTest_java_util_Hashtable\n"
+    "Test_java_util_Properties\nTest_java_util_ResourceBundle\nTest_java_util_tm\nTest_java_util_Vector\n";
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
 
     class MyInputStream : public InputStream{
     private:
@@ -75,7 +118,7 @@
             return len - pos;
         }
 
-        virtual int read() throw (IOException){
+        virtual int doReadByte() throw (IOException){
             if( this->isThrowOnRead() ) {
                 throw IOException(
                     __FILE__, __LINE__,
@@ -89,7 +132,8 @@
             return data.c_str()[pos++];
         }
 
-        virtual int read( unsigned char* buffer, std::size_t size, std::size_t offset, std::size_t length )
+        virtual int doReadArrayOffsetAndLength( unsigned char* buffer, std::size_t size,
+                                                std::size_t offset, std::size_t length )
             throw ( decaf::io::IOException,
                     decaf::lang::exceptions::IndexOutOfBoundsException,
                     decaf::lang::exceptions::NullPointerException ) {
@@ -125,57 +169,9 @@
             return ( pos += std::min( num, available() ) );
         }
 
-        virtual void mark( int readLimit DECAF_UNUSED ) {
-
-        }
-
-        virtual void reset() throw ( IOException ) {
-            throw IOException(
-                __FILE__, __LINE__,
-                "BufferedInputStream::reset - mark no yet supported." );
-        }
-
-        virtual bool markSupported() const{ return false; }
-
-        virtual void lock() throw( decaf::lang::exceptions::RuntimeException ) {
-        }
-
-        virtual bool tryLock() throw( decaf::lang::exceptions::RuntimeException ) {
-            return false;
-        }
-
-        virtual void unlock() throw( decaf::lang::exceptions::RuntimeException ) {
-        }
-
-        virtual void wait() throw( decaf::lang::exceptions::RuntimeException,
-                                   decaf::lang::exceptions::IllegalMonitorStateException,
-                                   decaf::lang::exceptions::InterruptedException ) {
-        }
-
-        virtual void wait( long long millisecs )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-        }
-
-        virtual void wait( long long millisecs, int nanos )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalArgumentException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-        }
-
-        virtual void notify() throw( decaf::lang::exceptions::RuntimeException,
-                                     decaf::lang::exceptions::IllegalMonitorStateException ) {
-        }
-
-        virtual void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
-                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
-        }
-
     };
 
-}}
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 void BufferedInputStreamTest::testConstructor() {
@@ -183,25 +179,32 @@
     std::string testStr = "TEST12345678910";
     MyInputStream myStream( testStr );
 
-    // Test for method BufferedInputStream(InputStream, int)
-    try {
-
-        // Create buffer with exact size of data
-        BufferedInputStream is( &myStream, testStr.length() );
-
-        // Ensure buffer gets filled by evaluating one read
-        CPPUNIT_ASSERT( is.read() != -1 );
+    // Create buffer with exact size of data
+    BufferedInputStream is( &myStream, testStr.length() );
 
-        // Read the remaining buffered characters, no IOException should
-        // occur.
-        is.skip( testStr.length() - 2 );
-        CPPUNIT_ASSERT( is.read() != -1 );
-        // is.read should now return -1 as all data has been read.
-        CPPUNIT_ASSERT( is.read() == -1 );
+    // Ensure buffer gets filled by evaluating one read
+    CPPUNIT_ASSERT( is.read() != -1 );
 
-    } catch( IOException& e ) {
-        e.printStackTrace();
-        CPPUNIT_ASSERT_MESSAGE("Exception during test_1_Constructor", false );
+    // Read the remaining buffered characters, no IOException should
+    // occur.
+    is.skip( testStr.length() - 2 );
+    CPPUNIT_ASSERT( is.read() != -1 );
+    // is.read should now return -1 as all data has been read.
+    CPPUNIT_ASSERT( is.read() == -1 );
+
+    {
+        BufferedInputStream nullStream( NULL );
+        CPPUNIT_ASSERT_THROW_MESSAGE(
+            "Should have thrown an IOException",
+            nullStream.read(),
+            IOException );
+    }
+    {
+        BufferedInputStream nullStream( NULL, (std::size_t)1 );
+        CPPUNIT_ASSERT_THROW_MESSAGE(
+            "Should have thrown an IOException",
+            nullStream.read(),
+            IOException );
     }
 }
 
@@ -266,6 +269,12 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamTest::testMarkSupported() {
+    BufferedInputStream is( NULL );
+    CPPUNIT_ASSERT_MESSAGE( "markSupported returned incorrect value", is.markSupported() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void BufferedInputStreamTest::testRead() {
 
     try {
@@ -337,12 +346,19 @@
 ////////////////////////////////////////////////////////////////////////////////
 void BufferedInputStreamTest::testReadException() {
 
+    unsigned char array[1];
+
     BufferedInputStream bis( NULL );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "should throw IOException",
-        bis.read( NULL, 1, 0, (size_t)-1 ),
-        IOException );
+        "should throw NullPointerException",
+        bis.read( NULL, 1, 0, 1 ),
+        NullPointerException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "should throw IndexOutOfBoundsException",
+        bis.read( array, 0, 1, 1 ),
+        IndexOutOfBoundsException );
 
     bis.close();
 
@@ -433,3 +449,219 @@
     available = bufStream.available();
     CPPUNIT_ASSERT( available == 1 );
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamTest::testSkipNullInputStream() {
+
+    BufferedInputStream buf( NULL, (std::size_t)5 );
+    CPPUNIT_ASSERT_EQUAL( (std::size_t)0, buf.skip( 0 ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamTest::testMarkI() {
+
+    ByteArrayInputStream stream;
+    stream.setByteArray( (const unsigned char*)testString.c_str(), testString.length() );
+
+    BufferedInputStream is( &stream );
+
+    unsigned char buf1[100];
+    unsigned char buf2[100];
+
+    is.skip( 3000 );
+    is.mark( 1000 );
+    is.read( buf1, 100 );
+    is.reset();
+    is.read( buf2, 100 );
+    is.reset();
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Failed to mark correct position",
+                                  std::string( buf1, buf1 + 100 ),
+                                  std::string( buf2, buf2 + 100 ) );
+
+    unsigned char bytes[256];
+    for( int i = 0; i < 256; i++ ) {
+        bytes[i] = (unsigned char)i;
+    }
+
+    {
+        ByteArrayInputStream bais;
+        bais.setByteArray( bytes, 256 );
+        BufferedInputStream in( &bais, (std::size_t)12 );
+
+        in.skip( 6 );
+        in.mark( 14 );
+
+        unsigned char bitBucket[14];
+        in.read( bitBucket, 14 );
+        in.reset();
+        CPPUNIT_ASSERT_MESSAGE( "Wrong bytes", in.read() == 6 && in.read() == 7 );
+    }
+    {
+        ByteArrayInputStream bais;
+        bais.setByteArray( bytes, 256 );
+        BufferedInputStream in( &bais, (std::size_t)12 );
+
+        in.skip( 6 );
+        in.mark( 8 );
+        in.skip( 7 );
+        in.reset();
+        CPPUNIT_ASSERT_MESSAGE( "Wrong bytes 2", in.read() == 6 && in.read() == 7 );
+    }
+    {
+        unsigned char temp[] = { 0, 1, 2, 3, 4 };
+        ByteArrayInputStream bais;
+        bais.setByteArray( temp, 5 );
+        BufferedInputStream buf( &bais, (std::size_t)2 );
+
+        buf.mark( 3 );
+        unsigned char bitBucket[3];
+        int result = buf.read( bitBucket, 3 );
+        CPPUNIT_ASSERT_EQUAL( 3, result );
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 0:", 0, (int)bytes[0] );
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 1:", 1, (int)bytes[1] );
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 2:", 2, (int)bytes[2] );
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 3:", 3, buf.read() );
+    }
+    {
+        unsigned char temp[] = { 0, 1, 2, 3, 4 };
+        ByteArrayInputStream bais;
+        bais.setByteArray( temp, 5 );
+        BufferedInputStream buf( &bais, (std::size_t)2 );
+
+        buf.mark( 3 );
+        unsigned char bitBucket[4];
+        int result = buf.read( bitBucket, 4 );
+
+        CPPUNIT_ASSERT_EQUAL(4, result);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 4:", 0, (int)bytes[0] );
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 5:", 1, (int)bytes[1] );
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 6:", 2, (int)bytes[2] );
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 7:", 3, (int)bytes[3] );
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 8:", 4, buf.read() );
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assert 9:", -1, buf.read() );
+    }
+    {
+        unsigned char temp[] = { 0, 1, 2, 3, 4 };
+        ByteArrayInputStream bais;
+        bais.setByteArray( temp, 5 );
+        BufferedInputStream buf( &bais, (std::size_t)2 );
+
+        buf.mark( Integer::MAX_VALUE );
+        buf.read();
+        buf.close();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamTest::testResetScenario1() {
+
+    unsigned char input[] = { '1','2','3','4','5','6','7','8','9','0','0' };
+
+    ByteArrayInputStream bais;
+    bais.setByteArray( &input[0], 11 );
+
+    BufferedInputStream buffis( &bais );
+
+    buffis.read();
+    buffis.mark( 5 );
+    buffis.skip( 5 );
+    buffis.reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamTest::testResetScenario2() {
+
+    unsigned char input[] = { '1','2','3','4','5','6','7','8','9','0','0' };
+
+    ByteArrayInputStream bais;
+    bais.setByteArray( &input[0], 11 );
+
+    BufferedInputStream buffis( &bais );
+
+    buffis.mark( 5 );
+    buffis.skip( 6 );
+    buffis.reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamTest::testResetException() {
+
+    BufferedInputStream bis( NULL );
+
+    // throws IOException with message "Mark has been invalidated"
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "should throw IOException",
+        bis.reset(),
+        IOException );
+
+    // does not throw IOException
+    bis.mark( 1 );
+    bis.reset();
+    bis.close();
+
+    // throws IOException with message "stream is closed"
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "should throw IOException",
+        bis.reset(),
+        IOException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamTest::testReset() {
+
+    ByteArrayInputStream stream;
+    stream.setByteArray( (const unsigned char*)testString.c_str(), testString.length() );
+
+    BufferedInputStream is( &stream );
+
+    unsigned char buf1[10];
+    unsigned char buf2[10];
+
+    is.mark( 2000 );
+    is.read( buf1, 10 );
+    is.reset();
+    is.read( buf2, 10 );
+    is.reset();
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Reset failed",
+                                  std::string( buf1, buf1 + 10 ),
+                                  std::string( buf2, buf2 + 10 ) );
+
+    unsigned char input[] = { '1','2','3','4','5','6','7','8','9','0' };
+    ByteArrayInputStream bais;
+    bais.setByteArray( &input[0], 10 );
+
+    BufferedInputStream bIn( &bais );
+    bIn.mark( 10 );
+
+    for( int i = 0; i < 11; i++ ) {
+        bIn.read();
+    }
+
+    bIn.reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamTest::testSkipJ() {
+
+    ByteArrayInputStream stream;
+    stream.setByteArray( (const unsigned char*)testString.c_str(), testString.length() );
+
+    BufferedInputStream is( &stream );
+
+    unsigned char buf1[10];
+    is.mark( 2000 );
+    is.skip( 1000 );
+    is.read( buf1, 10 );
+    is.reset();
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Failed to skip to correct position",
+                                  std::string( buf1, buf1 + 10 ),
+                                  testString.substr( 1000, 10 ) );
+
+    // throws IOException with message "stream is closed"
+    BufferedInputStream buf( NULL, (std::size_t)5 );
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "should throw IOException",
+        buf.skip( 10 ),
+        IOException );
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedInputStreamTest.h Mon Feb 22 19:02:35 2010
@@ -38,8 +38,20 @@
         CPPUNIT_TEST( testRead );
         CPPUNIT_TEST( testRead2 );
         CPPUNIT_TEST( testReadException );
+        CPPUNIT_TEST( testSkipNullInputStream );
+        CPPUNIT_TEST( testMarkSupported );
+        CPPUNIT_TEST( testResetScenario1 );
+        CPPUNIT_TEST( testResetScenario2 );
+        CPPUNIT_TEST( testResetException );
+        CPPUNIT_TEST( testReset );
+        CPPUNIT_TEST( testMarkI );
+        CPPUNIT_TEST( testSkipJ );
         CPPUNIT_TEST_SUITE_END();
 
+    private:
+
+        static const std::string testString;
+
     public:
 
         virtual ~BufferedInputStreamTest(){}
@@ -54,6 +66,14 @@
         void testRead();
         void testReadException();
         void testRead2();
+        void testMarkSupported();
+        void testSkipNullInputStream();
+        void testResetScenario1();
+        void testResetScenario2();
+        void testResetException();
+        void testReset();
+        void testMarkI();
+        void testSkipJ();
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedOutputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedOutputStreamTest.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedOutputStreamTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/BufferedOutputStreamTest.cpp Mon Feb 22 19:02:35 2010
@@ -26,8 +26,8 @@
 using namespace decaf::io;
 using namespace decaf::util;
 
-namespace decaf{
-namespace io{
+////////////////////////////////////////////////////////////////////////////////
+namespace {
 
     class MyOutputStream : public OutputStream{
     private:
@@ -43,7 +43,7 @@
 
         const char* getBuffer() const{ return buffer; }
 
-        virtual void write( unsigned char c ) throw (IOException){
+        virtual void doWriteByte( unsigned char c ) throw (IOException){
             if( pos >= 100 ){
                 throw IOException();
             }
@@ -51,18 +51,8 @@
             buffer[pos++] = c;
         }
 
-        virtual void write( const std::vector<unsigned char>& buffer )
-            throw ( IOException ) {
-
-            if( buffer.empty() ){
-                return;
-            }
-
-            this->write( &buffer[0], buffer.size(), 0, buffer.size() );
-        }
-
-        virtual void write( const unsigned char* buffer, std::size_t size,
-                            std::size_t offset, std::size_t length )
+        virtual void doWriteByteArrayBounded( const unsigned char* buffer, std::size_t size,
+                                              std::size_t offset, std::size_t length )
             throw ( decaf::io::IOException,
                     decaf::lang::exceptions::NullPointerException,
                     decaf::lang::exceptions::IndexOutOfBoundsException ) {
@@ -76,51 +66,9 @@
             pos += length;
         }
 
-        virtual void flush() throw (IOException){
-        }
-
-        virtual void close() throw(IOException){
-            // do nothing.
-        }
-
-        virtual void lock() throw( decaf::lang::exceptions::RuntimeException ) {
-        }
-
-        virtual bool tryLock() throw( decaf::lang::exceptions::RuntimeException ) {
-            return false;
-        }
-
-        virtual void unlock() throw( decaf::lang::exceptions::RuntimeException ) {
-        }
-
-        virtual void wait() throw( decaf::lang::exceptions::RuntimeException,
-                                   decaf::lang::exceptions::IllegalMonitorStateException,
-                                   decaf::lang::exceptions::InterruptedException ) {
-        }
-
-        virtual void wait( long long millisecs )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-        }
-
-        virtual void wait( long long millisecs, int nanos )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalArgumentException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-        }
-
-        virtual void notify() throw( decaf::lang::exceptions::RuntimeException,
-                                     decaf::lang::exceptions::IllegalMonitorStateException ) {
-        }
-
-        virtual void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
-                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
-        }
     };
 
-}}
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 void BufferedOutputStreamTest::testConstructor1() {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp Mon Feb 22 19:02:35 2010
@@ -63,7 +63,7 @@
         openDataInputStream();
         std::vector<unsigned char> result;
         result.resize( testData.length() );
-        is->read( result );
+        is->read( &result[0], testData.length() );
         CPPUNIT_ASSERT_MESSAGE( "Incorrect data read",
             string( (const char*)&result[0], result.size() ) == testData );
     } catch( IOException &e ) {
@@ -158,7 +158,7 @@
         openDataInputStream();
         std::vector<unsigned char> result;
         result.resize( testData.length() );
-        is->readFully( result );
+        is->readFully( &result[0], testData.length() );
 
         string expected = "";
         for( size_t ix = 0; ix < result.size(); ++ix ) {
@@ -180,7 +180,7 @@
         os->close();
         openDataInputStream();
         unsigned char* rbytes = new unsigned char[ testData.length() ];
-        is->readFully( rbytes, 0, testData.length() );
+        is->readFully( rbytes, testData.length() );
 
         string expected = "";
         for( size_t ix = 0; ix < testData.length(); ++ix ) {
@@ -203,22 +203,22 @@
 
     unsigned char* nullByteArray = NULL;
 
-    is.readFully( nullByteArray, 0, 0);
-    is.readFully( nullByteArray, 1, 0);
+    is.readFully( nullByteArray, 0, 0, 0);
+    is.readFully( nullByteArray, 0, 1, 0);
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        is.readFully( nullByteArray, 0, 1),
+        is.readFully( nullByteArray, 0, 0, 1),
         NullPointerException );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        is.readFully( nullByteArray, 1, 1),
+        is.readFully( nullByteArray, 0, 1, 1),
         NullPointerException );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        is.readFully( nullByteArray, 1, Integer::MAX_VALUE),
+        is.readFully( nullByteArray, 0, 1, Integer::MAX_VALUE),
         NullPointerException );
 }
 
@@ -228,22 +228,22 @@
     DataInputStream is(NULL);
     unsigned char* byteArray = new unsigned char[testData.length()];
 
-    is.readFully( byteArray, 0, 0 );
-    is.readFully( byteArray, 1, 0 );
+    is.readFully( byteArray, testData.length(), 0, 0 );
+    is.readFully( byteArray, testData.length(), 1, 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        is.readFully( byteArray, 1, 1 ),
+        is.readFully( byteArray, testData.length(), 1, 1 ),
         NullPointerException );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        is.readFully( byteArray, 0, 1 ),
+        is.readFully( byteArray, testData.length(), 0, 1 ),
         NullPointerException );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        is.readFully( byteArray, 0, Integer::MAX_VALUE ),
+        is.readFully( byteArray, testData.length(), 0, Integer::MAX_VALUE ),
         NullPointerException );
 
     delete [] byteArray;
@@ -255,22 +255,22 @@
     DataInputStream is(NULL);
     unsigned char* nullByteArray = NULL;
 
-    is.readFully( nullByteArray, 0, 0 );
-    is.readFully( nullByteArray, 1, 0 );
+    is.readFully( nullByteArray, 0, 0, 0 );
+    is.readFully( nullByteArray, 0, 1, 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        is.readFully( nullByteArray, 0, 1),
+        is.readFully( nullByteArray, 0, 0, 1),
         NullPointerException );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        is.readFully( nullByteArray, 1, 1),
+        is.readFully( nullByteArray, 0, 1, 1),
         NullPointerException );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        is.readFully( nullByteArray, 1, Integer::MAX_VALUE),
+        is.readFully( nullByteArray, 0, 1, Integer::MAX_VALUE),
         NullPointerException );
 }
 
@@ -338,7 +338,7 @@
         openDataInputStream();
         is->skip( 100 );
         std::vector<unsigned char> result( 50 );
-        is->read( result );
+        is->read( &result[0], 50 );
         is->close();
         CPPUNIT_ASSERT_MESSAGE("Incorrect data read",
             string( (const char*)&result[0], 50) == testData.substr( 100, 50) );
@@ -485,7 +485,7 @@
 
     try{
         std::vector<unsigned char> buffer2;
-        reader.readFully( buffer2 );
+        reader.readFully( &buffer2[0], buffer2.size() );
     } catch(...){
         CPPUNIT_ASSERT( false );
     }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataOutputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataOutputStreamTest.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataOutputStreamTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataOutputStreamTest.cpp Mon Feb 22 19:02:35 2010
@@ -131,7 +131,7 @@
         os->close();
         openDataInputStream();
         std::vector<unsigned char> result( testData.size() );
-        is->read( result );
+        is->read( &result[0], testData.size() );
         is->close();
         CPPUNIT_ASSERT_MESSAGE("Incorrect bytes written",
             string( (const char*)&result[0], result.size() ) == testData );
@@ -166,7 +166,7 @@
         os->close();
         openDataInputStream();
         std::vector<unsigned char> result( testData.size() );
-        is->read( result );
+        is->read( &result[0], testData.size() );
         is->close();
         CPPUNIT_ASSERT_MESSAGE("Incorrect bytes written",
             string( (const char*)&result[0], result.size() ) == testData );

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.cpp Mon Feb 22 19:02:35 2010
@@ -21,11 +21,12 @@
 using namespace std;
 using namespace decaf;
 using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
 using namespace decaf::io;
 using namespace decaf::util;
 
-namespace decaf{
-namespace io{
+////////////////////////////////////////////////////////////////////////////////
+namespace {
 
     class MyInputStream : public InputStream{
     private:
@@ -66,7 +67,16 @@
             return len - pos;
         }
 
-        virtual int read() throw (IOException){
+        virtual void close() throw(IOException){
+            this->closed = true;
+        }
+        virtual std::size_t skip( std::size_t num ) throw ( io::IOException, lang::exceptions::UnsupportedOperationException ) {
+            return ( pos += std::min( num, available() ) );
+        }
+
+    protected:
+
+        virtual int doReadByte() throw (IOException){
             if( this->isThrowOnRead() ) {
                 throw IOException(
                     __FILE__, __LINE__,
@@ -80,13 +90,23 @@
             return data.c_str()[pos++];
         }
 
-        virtual int read( unsigned char* buffer, std::size_t size, std::size_t offset, std::size_t length )
+        virtual int doReadArrayBounded( unsigned char* buffer, std::size_t size,
+                                        std::size_t offset, std::size_t length )
             throw ( decaf::io::IOException,
                     decaf::lang::exceptions::IndexOutOfBoundsException,
                     decaf::lang::exceptions::NullPointerException ) {
 
             std::size_t numToRead = std::min( length, available() );
 
+            if( buffer == NULL ) {
+                throw NullPointerException( __FILE__, __LINE__, "Buffer was Null." );
+            }
+
+            if( offset > size || offset + length > size ) {
+                throw IndexOutOfBoundsException(
+                    __FILE__, __LINE__, "Offset + Length greater than the given buffer size." );
+            }
+
             if( this->isThrowOnRead() ) {
                 throw IOException(
                     __FILE__, __LINE__,
@@ -108,63 +128,9 @@
             return (int)numToRead;
         }
 
-        virtual void close() throw(IOException){
-            this->closed = true;
-        }
-        virtual std::size_t skip( std::size_t num ) throw ( io::IOException, lang::exceptions::UnsupportedOperationException ) {
-            return ( pos += std::min( num, available() ) );
-        }
-
-        virtual void mark( int readLimit DECAF_UNUSED ) {
-
-        }
-
-        virtual void reset() throw ( IOException ) {
-            throw IOException(
-                __FILE__, __LINE__,
-                "BufferedInputStream::reset - mark no yet supported." );
-        }
-
-        virtual bool markSupported() const{ return false; }
-
-        virtual void lock() throw( decaf::lang::exceptions::RuntimeException ) {
-        }
-
-        virtual bool tryLock() throw( decaf::lang::exceptions::RuntimeException ) {
-            return false;
-        }
-
-        virtual void unlock() throw( decaf::lang::exceptions::RuntimeException ) {
-        }
-
-        virtual void wait() throw( decaf::lang::exceptions::RuntimeException,
-                                   decaf::lang::exceptions::IllegalMonitorStateException,
-                                   decaf::lang::exceptions::InterruptedException ) {
-        }
-
-        virtual void wait( long long millisecs )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-        }
-
-        virtual void wait( long long millisecs, int nanos )
-            throw( decaf::lang::exceptions::RuntimeException,
-                   decaf::lang::exceptions::IllegalArgumentException,
-                   decaf::lang::exceptions::IllegalMonitorStateException,
-                   decaf::lang::exceptions::InterruptedException ) {
-        }
-
-        virtual void notify() throw( decaf::lang::exceptions::RuntimeException,
-                                     decaf::lang::exceptions::IllegalMonitorStateException ) {
-        }
-
-        virtual void notifyAll() throw( decaf::lang::exceptions::RuntimeException,
-                                        decaf::lang::exceptions::IllegalMonitorStateException ) {
-        }
     };
 
-}}
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 void FilterInputStreamTest::testAvailable() {
@@ -237,8 +203,11 @@
     unsigned char buf[100];
     is.skip(3000);
     is.read( buf, 100, 0, 100 );
-    CPPUNIT_ASSERT_MESSAGE( "Failed to read correct data",
-        string( (const char*)buf, 100 ) == testStr.substr( 3000, 100 ) );
+
+    std::string bufferString( (const char*)buf, (const char*)(buf + 100) );
+    std::string testSubString = testStr.substr( 3000, 100 );
+
+    CPPUNIT_ASSERT_MESSAGE( "Failed to read correct data", bufferString == testSubString );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -257,3 +226,49 @@
     CPPUNIT_ASSERT_MESSAGE( "Failed to skip to correct position",
             string( (const char*)buf, 100 ) == testStr.substr( 1000, 100 ) );
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterInputStreamTest::testReadBIIIExceptions() {
+
+    std::string testStr;
+    for( int i = 0; i < 1000; ++i ) {
+        testStr += (char)i;
+    }
+    MyInputStream myStream( testStr );
+    FilterInputStream is( &myStream );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+         "should throw NullPointerException",
+         is.read( NULL, 1000, 0, 1001 ),
+         NullPointerException );
+
+    unsigned char buf[1000];
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+         "should throw IndexOutOfBoundsException",
+         is.read( buf, 1000, 0, 1001 ),
+         IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+         "should throw IndexOutOfBoundsException",
+         is.read( buf, 1000, 1001, 0 ),
+         IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+         "should throw IndexOutOfBoundsException",
+         is.read( buf, 1000, 500, 501 ),
+         IndexOutOfBoundsException );
+
+    {
+        MyInputStream myStream( testStr );
+        FilterInputStream is( &myStream );
+
+        unsigned char buf[1000];
+
+        is.close();
+        CPPUNIT_ASSERT_THROW_MESSAGE(
+             "should throw IOException",
+             is.read( buf, 1000, 0, 100 ),
+             IOException );
+    }
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterInputStreamTest.h Mon Feb 22 19:02:35 2010
@@ -36,6 +36,7 @@
         CPPUNIT_TEST( testRead2 );
         CPPUNIT_TEST( testRead3 );
         CPPUNIT_TEST( testSkip );
+        CPPUNIT_TEST( testReadBIIIExceptions );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -49,6 +50,7 @@
         void testRead2();
         void testRead3();
         void testSkip();
+        void testReadBIIIExceptions();
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.cpp Mon Feb 22 19:02:35 2010
@@ -22,6 +22,7 @@
 using namespace std;
 using namespace decaf;
 using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
 using namespace decaf::io;
 using namespace decaf::util;
 
@@ -108,3 +109,39 @@
         CPPUNIT_FAIL("Write test failed : " + e.getMessage());
     }
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void FilterOutputStreamTest::testWriteBIIIExceptions() {
+
+    ByteArrayOutputStream baos;
+    FilterOutputStream os( &baos );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an NullPointerException",
+        os.write( NULL, 1000, 0, 1001 ),
+        NullPointerException );
+
+    unsigned char buffer[1000];
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an IndexOutOfBoundsException",
+        os.write( buffer, 1000, 0, 1001 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an IndexOutOfBoundsException",
+        os.write( buffer, 1000, 1001, 0 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an IndexOutOfBoundsException",
+        os.write( buffer, 1000, 500, 501 ),
+        IndexOutOfBoundsException );
+
+    os.close();
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an IOException",
+        os.write( buffer, 1000, 0, 100 ),
+        IOException );
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.h?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/FilterOutputStreamTest.h Mon Feb 22 19:02:35 2010
@@ -35,6 +35,7 @@
         CPPUNIT_TEST( testFlush );
         CPPUNIT_TEST( testWrite1 );
         CPPUNIT_TEST( testWrite2 );
+        CPPUNIT_TEST( testWriteBIIIExceptions );
         CPPUNIT_TEST_SUITE_END();
 
         std::string testString;
@@ -53,6 +54,7 @@
         void testFlush();
         void testWrite1();
         void testWrite2();
+        void testWriteBIIIExceptions();
 
     };
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.cpp?rev=915018&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.cpp Mon Feb 22 19:02:35 2010
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "InputStreamTest.h"
+
+#include <decaf/io/InputStream.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::io;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace{
+
+    class MockInputStream : public InputStream {
+    public:
+
+        virtual ~MockInputStream() {}
+
+        virtual int doReadByte() throw( decaf::io::IOException ) {
+            return 0;
+        }
+
+    };
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+InputStreamTest::InputStreamTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+InputStreamTest::~InputStreamTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void InputStreamTest::test() {
+
+    MockInputStream stream;
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a NullPointerException",
+        stream.read( NULL, 0, 0, 1 ),
+        NullPointerException );
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.h?rev=915018&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.h Mon Feb 22 19:02:35 2010
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_IO_INPUTSTREAMTEST_H_
+#define _DECAF_IO_INPUTSTREAMTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace decaf {
+namespace io {
+
+    class InputStreamTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( InputStreamTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        InputStreamTest();
+        virtual ~InputStreamTest();
+
+        virtual void test();
+
+    };
+
+}}
+
+#endif /* _DECAF_IO_INPUTSTREAMTEST_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/InputStreamTest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.cpp?rev=915018&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.cpp Mon Feb 22 19:02:35 2010
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "OutputStreamTest.h"
+
+#include <decaf/io/OutputStream.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::io;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    class MockOutputStream : public OutputStream {
+    private:
+
+        std::vector<unsigned char> buffer;
+
+    public:
+
+        virtual ~MockOutputStream() {}
+
+        virtual void doWriteByte( unsigned char c ) throw( decaf::io::IOException ) {
+            buffer.push_back( c );
+        }
+
+        const std::vector<unsigned char>& getBuffer() {
+            return this->buffer;
+        }
+    };
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+OutputStreamTest::OutputStreamTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+OutputStreamTest::~OutputStreamTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OutputStreamTest::test() {
+
+    MockOutputStream ostream;
+
+    ostream.write( 'h' );
+    ostream.write( (const unsigned char*)std::string( "ello " ).c_str(), 5 );
+    ostream.write( (const unsigned char*)std::string( "hello world" ).c_str(), 11, 6, 5 );
+
+    std::string result( ostream.getBuffer().begin(), ostream.getBuffer().end() );
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Written string not what was expected",
+                                  std::string( "hello world" ), result );
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.h?rev=915018&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.h Mon Feb 22 19:02:35 2010
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_IO_OUTPUTSTREAMTEST_H_
+#define _DECAF_IO_OUTPUTSTREAMTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace decaf {
+namespace io {
+
+    class OutputStreamTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( OutputStreamTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        OutputStreamTest();
+        virtual ~OutputStreamTest();
+
+        void test();
+
+    };
+
+}}
+
+#endif /* _DECAF_IO_OUTPUTSTREAMTEST_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/OutputStreamTest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/ReaderTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/ReaderTest.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/ReaderTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/ReaderTest.cpp Mon Feb 22 19:02:35 2010
@@ -31,8 +31,7 @@
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-namespace decaf{
-namespace io{
+namespace {
 
     class MockReader : public decaf::io::Reader {
     private:
@@ -61,8 +60,8 @@
 
     protected:
 
-        virtual int doReadArraySizeOffsetLength( char* buffer, std::size_t size,
-                                                 std::size_t offset, std::size_t length )
+        virtual int doReadArrayBounded( char* buffer, std::size_t size,
+                                        std::size_t offset, std::size_t length )
             throw( decaf::io::IOException,
                    decaf::lang::exceptions::NullPointerException,
                    decaf::lang::exceptions::IndexOutOfBoundsException ) {
@@ -85,7 +84,7 @@
 
     };
 
-}}
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 ReaderTest::ReaderTest() {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/WriterTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/WriterTest.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/WriterTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/WriterTest.cpp Mon Feb 22 19:02:35 2010
@@ -28,8 +28,7 @@
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-namespace decaf{
-namespace io{
+namespace {
 
     class MockWriter : public Writer {
     private:
@@ -59,7 +58,7 @@
         virtual void flush() throw( decaf::io::IOException ) {
         }
 
-        virtual void doWriteArraySizeOffsetLength(
+        virtual void doWriteArrayBounded(
             const char* buffer, std::size_t size, std::size_t offset, std::size_t length )
                 throw( decaf::io::IOException,
                        decaf::lang::exceptions::NullPointerException,
@@ -94,7 +93,7 @@
         }
     };
 
-}}
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 WriterTest::WriterTest() {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp?rev=915018&r1=915017&r2=915018&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp Mon Feb 22 19:02:35 2010
@@ -168,6 +168,10 @@
 #include <decaf/nio/BufferTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( decaf::nio::BufferTest );
 
+#include <decaf/io/InputStreamTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::InputStreamTest );
+#include <decaf/io/OutputStreamTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::OutputStreamTest );
 #include <decaf/io/FilterInputStreamTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::FilterInputStreamTest );
 #include <decaf/io/FilterOutputStreamTest.h>



Mime
View raw message