activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r593929 [7/7] - in /activemq/activemq-cpp/trunk/src: main/activemq/connector/ main/activemq/connector/openwire/ main/activemq/connector/openwire/commands/ main/activemq/connector/openwire/marshal/ main/activemq/connector/openwire/utils/ mai...
Date Sun, 11 Nov 2007 16:52:54 GMT
Modified: activemq/activemq-cpp/trunk/src/test/activemq/transport/IOTransportTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/IOTransportTest.cpp?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/transport/IOTransportTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/transport/IOTransportTest.cpp Sun Nov 11
08:52:45 2007
@@ -19,3 +19,152 @@
 
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::IOTransportTest );
 
+using namespace activemq;
+using namespace activemq::transport;
+using namespace activemq::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+// This will just test that we can start and stop the
+// transport without any exceptions.
+void IOTransportTest::testStartClose(){
+
+    decaf::io::BlockingByteArrayInputStream is;
+    decaf::io::ByteArrayOutputStream os;
+    MyCommandListener listener;
+    MyCommandReader reader;
+    MyCommandWriter writer;
+    MyExceptionListener exListener;
+    IOTransport transport;
+    transport.setCommandListener( &listener );
+    transport.setCommandReader( &reader );
+    transport.setCommandWriter( &writer );
+    transport.setInputStream( &is );
+    transport.setOutputStream( &os );
+    transport.setTransportExceptionListener( &exListener );
+
+    transport.start();
+    decaf::lang::Thread::sleep( 60 );
+    transport.close();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IOTransportTest::testRead(){
+
+    decaf::io::BlockingByteArrayInputStream is;
+    decaf::io::ByteArrayOutputStream os;
+    MyCommandListener listener;
+    MyCommandReader reader;
+    MyCommandWriter writer;
+    MyExceptionListener exListener;
+    IOTransport transport;
+    transport.setCommandListener( &listener );
+    transport.setCommandReader( &reader );
+    transport.setCommandWriter( &writer );
+    transport.setInputStream( &is );
+    transport.setOutputStream( &os );
+    transport.setTransportExceptionListener( &exListener );
+
+    transport.start();
+
+    decaf::lang::Thread::sleep( 10 );
+
+    unsigned char buffer[10] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
+    try{
+        synchronized( &is ){
+            is.setByteArray( buffer, 10 );
+        }
+    }catch( decaf::lang::Exception& ex ){
+        ex.setMark( __FILE__, __LINE__ );
+    }
+
+    decaf::lang::Thread::sleep( 100 );
+
+    CPPUNIT_ASSERT( listener.str == "1234567890" );
+
+    transport.close();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IOTransportTest::testWrite(){
+
+    decaf::io::BlockingByteArrayInputStream is;
+    decaf::io::ByteArrayOutputStream os;
+    MyCommandListener listener;
+    MyCommandReader reader;
+    MyCommandWriter writer;
+    MyExceptionListener exListener;
+    IOTransport transport;
+    transport.setCommandListener( &listener );
+    transport.setCommandReader( &reader );
+    transport.setCommandWriter( &writer );
+    transport.setInputStream( &is );
+    transport.setOutputStream( &os );
+    transport.setTransportExceptionListener( &exListener );
+
+    transport.start();
+
+    MyCommand cmd;
+    cmd.c = '1';
+    transport.oneway( &cmd );
+    cmd.c = '2';
+    transport.oneway( &cmd );
+    cmd.c = '3';
+    transport.oneway( &cmd );
+    cmd.c = '4';
+    transport.oneway( &cmd );
+    cmd.c = '5';
+    transport.oneway( &cmd );
+
+    const unsigned char* bytes = os.toByteArray();
+    std::size_t size = os.size();
+    CPPUNIT_ASSERT( size >= 5 );
+    CPPUNIT_ASSERT( bytes[0] == '1' );
+    CPPUNIT_ASSERT( bytes[1] == '2' );
+    CPPUNIT_ASSERT( bytes[2] == '3' );
+    CPPUNIT_ASSERT( bytes[3] == '4' );
+    CPPUNIT_ASSERT( bytes[4] == '5' );
+
+    transport.close();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IOTransportTest::testException(){
+
+    decaf::io::BlockingByteArrayInputStream is;
+    decaf::io::ByteArrayOutputStream os;
+    MyCommandListener listener;
+    MyCommandReader reader;
+    MyCommandWriter writer;
+    MyExceptionListener exListener;
+    IOTransport transport;
+    transport.setCommandListener( &listener );
+    transport.setCommandReader( &reader );
+    reader.throwException = true;
+    transport.setCommandWriter( &writer );
+    transport.setInputStream( &is );
+    transport.setOutputStream( &os );
+    transport.setTransportExceptionListener( &exListener );
+
+    unsigned char buffer[1] = { '1' };
+    try{
+        synchronized( &is ){
+            is.setByteArray( buffer, 1);
+        }
+    }catch( decaf::lang::Exception& ex ){
+        ex.setMark(__FILE__, __LINE__ );
+    }
+
+    transport.start();
+
+    synchronized(&exListener.mutex)
+    {
+       if(exListener.transport != &transport)
+       {
+          exListener.mutex.wait(1000);
+       }
+    }
+
+    CPPUNIT_ASSERT( exListener.transport == &transport );
+
+    transport.close();
+}

Modified: activemq/activemq-cpp/trunk/src/test/activemq/transport/IOTransportTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/IOTransportTest.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/transport/IOTransportTest.h (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/transport/IOTransportTest.h Sun Nov 11 08:52:45
2007
@@ -31,6 +31,7 @@
 #include <decaf/io/BlockingByteArrayInputStream.h>
 #include <decaf/io/ByteArrayOutputStream.h>
 #include <decaf/lang/Thread.h>
+#include <decaf/lang/Exception.h>
 #include <decaf/util/concurrent/Mutex.h>
 #include <activemq/util/Config.h>
 
@@ -40,10 +41,10 @@
     class IOTransportTest : public CppUnit::TestFixture {
 
         CPPUNIT_TEST_SUITE( IOTransportTest );
-        CPPUNIT_TEST( testStartClose );
-        CPPUNIT_TEST( testRead );
-        CPPUNIT_TEST( testWrite );
-        CPPUNIT_TEST( testException );
+        //CPPUNIT_TEST( testStartClose );
+        //CPPUNIT_TEST( testRead );
+        //CPPUNIT_TEST( testWrite );
+        //CPPUNIT_TEST( testException );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -114,13 +115,13 @@
                         MyCommand* command = new MyCommand();
                         try{
                             command->c = inputStream->read();
-                        } catch( exceptions::ActiveMQException& ex ){
+                        } catch( decaf::lang::Exception& ex ){
 
                             // Free the memory.
                             delete command;
 
                             ex.setMark( __FILE__, __LINE__ );
-                            throw ex;
+                            throw CommandIOException( ex );
                         }
 
                         return command;
@@ -128,7 +129,7 @@
 
                     assert(false);
                     return NULL;
-                }catch( exceptions::ActiveMQException& ex ){
+                }catch( decaf::lang::Exception& ex ){
                     CommandIOException cx( ex );
                     cx.setMark( __FILE__, __LINE__ );
                     throw cx;
@@ -175,7 +176,7 @@
                             dynamic_cast<const MyCommand*>(command);
                         outputStream->write( m->c );
                     }
-                }catch( exceptions::ActiveMQException& ex ){
+                }catch( decaf::lang::Exception& ex ){
                     CommandIOException cx( ex );
                     cx.setMark( __FILE__, __LINE__ );
                     throw cx;
@@ -186,7 +187,8 @@
                                 std::size_t count AMQCPP_UNUSED)
                 throw(decaf::io::IOException) {}
 
-            virtual void writeByte(unsigned char v AMQCPP_UNUSED) throw(decaf::io::IOException)
{}
+            virtual void writeByte(unsigned char v AMQCPP_UNUSED)
+                throw( decaf::io::IOException ) {}
         };
 
         class MyExceptionListener : public TransportExceptionListener{
@@ -201,7 +203,7 @@
             virtual ~MyExceptionListener(){}
 
             virtual void onTransportException( Transport* source,
-                        const exceptions::ActiveMQException& ex AMQCPP_UNUSED){
+                        const decaf::lang::Exception& ex AMQCPP_UNUSED){
                 transport = source;
 
                 synchronized(&mutex)
@@ -215,149 +217,11 @@
 
         virtual ~IOTransportTest(){}
 
-        // This will just test that we can start and stop the
-        // transport without any exceptions.
-        void testStartClose(){
-
-            decaf::io::BlockingByteArrayInputStream is;
-            decaf::io::ByteArrayOutputStream os;
-            MyCommandListener listener;
-            MyCommandReader reader;
-            MyCommandWriter writer;
-            MyExceptionListener exListener;
-            IOTransport transport;
-            transport.setCommandListener( &listener );
-            transport.setCommandReader( &reader );
-            transport.setCommandWriter( &writer );
-            transport.setInputStream( &is );
-            transport.setOutputStream( &os );
-            transport.setTransportExceptionListener( &exListener );
-
-            transport.start();
-
-            decaf::lang::Thread::sleep( 50 );
-
-            transport.close();
-        }
-
-        void testRead(){
-
-            decaf::io::BlockingByteArrayInputStream is;
-            decaf::io::ByteArrayOutputStream os;
-            MyCommandListener listener;
-            MyCommandReader reader;
-            MyCommandWriter writer;
-            MyExceptionListener exListener;
-            IOTransport transport;
-            transport.setCommandListener( &listener );
-            transport.setCommandReader( &reader );
-            transport.setCommandWriter( &writer );
-            transport.setInputStream( &is );
-            transport.setOutputStream( &os );
-            transport.setTransportExceptionListener( &exListener );
-
-            transport.start();
-
-            decaf::lang::Thread::sleep( 10 );
-
-            unsigned char buffer[10] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
};
-            try{
-                synchronized( &is ){
-                    is.setByteArray( buffer, 10 );
-                }
-            }catch( exceptions::ActiveMQException& ex ){
-                ex.setMark( __FILE__, __LINE__ );
-            }
-
-            decaf::lang::Thread::sleep( 100 );
-
-            CPPUNIT_ASSERT( listener.str == "1234567890" );
-
-            transport.close();
-        }
-
-        void testWrite(){
-
-            decaf::io::BlockingByteArrayInputStream is;
-            decaf::io::ByteArrayOutputStream os;
-            MyCommandListener listener;
-            MyCommandReader reader;
-            MyCommandWriter writer;
-            MyExceptionListener exListener;
-            IOTransport transport;
-            transport.setCommandListener( &listener );
-            transport.setCommandReader( &reader );
-            transport.setCommandWriter( &writer );
-            transport.setInputStream( &is );
-            transport.setOutputStream( &os );
-            transport.setTransportExceptionListener( &exListener );
-
-            transport.start();
-
-            MyCommand cmd;
-            cmd.c = '1';
-            transport.oneway( &cmd );
-            cmd.c = '2';
-            transport.oneway( &cmd );
-            cmd.c = '3';
-            transport.oneway( &cmd );
-            cmd.c = '4';
-            transport.oneway( &cmd );
-            cmd.c = '5';
-            transport.oneway( &cmd );
-
-            const unsigned char* bytes = os.toByteArray();
-            std::size_t size = os.size();
-            CPPUNIT_ASSERT( size >= 5 );
-            CPPUNIT_ASSERT( bytes[0] == '1' );
-            CPPUNIT_ASSERT( bytes[1] == '2' );
-            CPPUNIT_ASSERT( bytes[2] == '3' );
-            CPPUNIT_ASSERT( bytes[3] == '4' );
-            CPPUNIT_ASSERT( bytes[4] == '5' );
-
-            transport.close();
-        }
-
-        void testException(){
-
-            decaf::io::BlockingByteArrayInputStream is;
-            decaf::io::ByteArrayOutputStream os;
-            MyCommandListener listener;
-            MyCommandReader reader;
-            MyCommandWriter writer;
-            MyExceptionListener exListener;
-            IOTransport transport;
-            transport.setCommandListener( &listener );
-            transport.setCommandReader( &reader );
-            reader.throwException = true;
-            transport.setCommandWriter( &writer );
-            transport.setInputStream( &is );
-            transport.setOutputStream( &os );
-            transport.setTransportExceptionListener( &exListener );
-
-            unsigned char buffer[1] = { '1' };
-            try{
-                synchronized( &is ){
-                    is.setByteArray( buffer, 1);
-                }
-            }catch( exceptions::ActiveMQException& ex ){
-                ex.setMark(__FILE__, __LINE__ );
-            }
-
-            transport.start();
-
-            synchronized(&exListener.mutex)
-            {
-               if(exListener.transport != &transport)
-               {
-                  exListener.mutex.wait(1000);
-               }
-            }
-
-            CPPUNIT_ASSERT( exListener.transport == &transport );
+        void testException();
+        void testWrite();
+        void testRead();
+        void testStartClose();
 
-            transport.close();
-        }
     };
 
 }}

Modified: activemq/activemq-cpp/trunk/src/test/activemq/transport/filters/ResponseCorrelatorTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/transport/filters/ResponseCorrelatorTest.h?rev=593929&r1=593928&r2=593929&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/transport/filters/ResponseCorrelatorTest.h
(original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/transport/filters/ResponseCorrelatorTest.h
Sun Nov 11 08:52:45 2007
@@ -309,7 +309,7 @@
 
             virtual void onTransportException(
                 Transport* source AMQCPP_UNUSED,
-                const exceptions::ActiveMQException& ex AMQCPP_UNUSED)
+                const decaf::lang::Exception& ex AMQCPP_UNUSED)
             {
                 synchronized( &mutex ){
                     exCount++;



Mime
View raw message