activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r533714 - in /activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network: SocketFactoryTest.cpp SocketFactoryTest.h SocketTest.cpp SocketTest.h
Date Mon, 30 Apr 2007 11:53:18 GMT
Author: tabish
Date: Mon Apr 30 04:53:18 2007
New Revision: 533714

URL: http://svn.apache.org/viewvc?view=rev&rev=533714
Log:
Merging in fixes for 2.0.1

Modified:
    activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.cpp
    activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.h
    activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.cpp
    activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.h

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.cpp?view=diff&rev=533714&r1=533713&r2=533714
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.cpp
(original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.cpp
Mon Apr 30 04:53:18 2007
@@ -18,3 +18,129 @@
 #include "SocketFactoryTest.h"
 
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::network::SocketFactoryTest );
+
+#include <activemq/util/SimpleProperties.h>
+#include <activemq/network/SocketFactory.h>
+#include <activemq/network/TcpSocket.h>
+
+using namespace activemq;
+using namespace activemq::network;
+
+////////////////////////////////////////////////////////////////////////////////
+void SocketFactoryTest::test()
+{
+    try
+    {
+        MyServerThread serverThread;
+        serverThread.start();
+
+        concurrent::Thread::sleep( 500 );
+
+        util::SimpleProperties properties;
+
+        std::ostringstream ostream;
+
+        ostream << "127.0.0.1:" << port;
+
+        properties.setProperty("soLinger", "false");
+
+        Socket* client = SocketFactory::createSocket(
+            ostream.str(), properties );
+
+        synchronized(&serverThread.mutex)
+        {
+            if(serverThread.getNumClients() != 1)
+            {
+                serverThread.mutex.wait(1000);
+            }
+        }
+
+        CPPUNIT_ASSERT( client->isConnected() );
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
+
+        client->close();
+
+        synchronized(&serverThread.mutex)
+        {
+            if(serverThread.getNumClients() != 0)
+            {
+                serverThread.mutex.wait(1000);
+            }
+        }
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 0 );
+
+        serverThread.stop();
+        serverThread.join();
+
+        delete client;
+    }
+    catch(exceptions::ActiveMQException ex)
+    {
+        std::cout << "SocketFactoryTest::test - Caught Exception." << std::endl;
+        ex.printStackTrace();
+        CPPUNIT_ASSERT( false );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SocketFactoryTest::testNoDelay()
+{
+    try
+    {
+        MyServerThread serverThread;
+        serverThread.start();
+
+        concurrent::Thread::sleep( 40 );
+
+        util::SimpleProperties properties;
+
+        std::ostringstream ostream;
+
+        ostream << "127.0.0.1:" << port;
+
+        properties.setProperty( "soLinger", "false" );
+        properties.setProperty( "tcpNoDelay", "true" );
+
+        Socket* client = SocketFactory::createSocket(
+            ostream.str(), properties );
+
+        TcpSocket* tcpSock = dynamic_cast<TcpSocket*>( client );
+        CPPUNIT_ASSERT( tcpSock != NULL );
+        CPPUNIT_ASSERT( tcpSock->getTcpNoDelay() == true );
+
+        synchronized(&serverThread.mutex)
+        {
+            if(serverThread.getNumClients() != 1)
+            {
+                serverThread.mutex.wait(1000);
+            }
+        }
+
+        CPPUNIT_ASSERT( client->isConnected() );
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
+
+        client->close();
+
+        synchronized(&serverThread.mutex)
+        {
+            if(serverThread.getNumClients() != 0)
+            {
+                serverThread.mutex.wait(1000);
+            }
+        }
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 0 );
+
+        serverThread.stop();
+        serverThread.join();
+
+        delete client;
+    }
+    catch(exceptions::ActiveMQException ex)
+    {
+        CPPUNIT_ASSERT( false );
+    }
+}

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.h?view=diff&rev=533714&r1=533713&r2=533714
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.h
(original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketFactoryTest.h
Mon Apr 30 04:53:18 2007
@@ -22,11 +22,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include <activemq/network/Socket.h>
-#include <activemq/network/TcpSocket.h>
-#include <activemq/network/BufferedSocket.h>
 #include <activemq/network/ServerSocket.h>
-#include <activemq/network/SocketFactory.h>
-#include <activemq/util/SimpleProperties.h>
 #include <activemq/concurrent/Concurrent.h>
 #include <activemq/concurrent/Mutex.h>
 #include <activemq/concurrent/Thread.h>
@@ -40,53 +36,53 @@
    {
       CPPUNIT_TEST_SUITE( SocketFactoryTest );
       CPPUNIT_TEST( test );
+      CPPUNIT_TEST( testNoDelay );
       CPPUNIT_TEST_SUITE_END();
 
       static const int port = 23232;
-      
+
       class MyServerThread : public concurrent::Thread{
       private:
-      
+
          bool done;
          int numClients;
          std::string lastMessage;
-         
+
       public:
-      
+
          concurrent::Mutex mutex;
-         
+
       public:
          MyServerThread(){
             done = false;
             numClients = 0;
          }
          virtual ~MyServerThread(){
-            stop();        
+            stop();
          }
-         
+
          std::string getLastMessage(){
             return lastMessage;
          }
-         
+
          int getNumClients(){
             return numClients;
          }
-         
+
          virtual void stop(){
             done = true;
          }
-         
+
          virtual void run(){
             try{
                unsigned char buf[1000];
-               
+
                ServerSocket server;
                server.bind( "127.0.0.1", port );
-               
+
                network::Socket* socket = server.accept();
                server.close();
-               
-               //socket->setSoTimeout( 10 );
+
                socket->setSoLinger( false );
 
                synchronized(&mutex)
@@ -97,34 +93,34 @@
                }
 
                while( !done && socket != NULL ){
-                                    
+
                   io::InputStream* stream = socket->getInputStream();
                   memset( buf, 0, 1000 );
                   try{
                       stream->read( buf, 1000 );
-                    
+
                       lastMessage = (char*)buf;
-                    
+
                       if( strcmp( (char*)buf, "reply" ) == 0 ){
                           io::OutputStream* output = socket->getOutputStream();
                           output->write( (unsigned char*)"hello", strlen("hello" ) );
                       }
-                     
+
                   }catch( io::IOException& ex ){
                       done = true;
                   }
                }
-               
+
                socket->close();
                delete socket;
-               
+
                numClients--;
-               
+
                synchronized(&mutex)
                {
                    mutex.notifyAll();
                }
-               
+
             }catch( io::IOException& ex ){
                printf("%s\n", ex.getMessage().c_str() );
                CPPUNIT_ASSERT( false );
@@ -132,73 +128,16 @@
                CPPUNIT_ASSERT( false );
             }
          }
-         
+
       };
-      
+
    public:
-   
-   	SocketFactoryTest() {}
-   	virtual ~SocketFactoryTest() {}
-      
-      void test(void)
-      {
-         try
-         {
-            MyServerThread serverThread;
-            serverThread.start();
-         
-            concurrent::Thread::sleep( 40 );
-            
-            util::SimpleProperties properties;
-            
-            std::ostringstream ostream;
-            
-            ostream << "127.0.0.1:" << port;
-            
-            properties.setProperty("uri", ostream.str());
-            properties.setProperty("soLinger", "false");
-            //properties.setProperty("soTimeout", "5");
-
-            Socket* client = SocketFactory::createSocket(properties);
-
-            //BufferedSocket* buffSocket = dynamic_cast<BufferedSocket*>(client);
-
-            //CPPUNIT_ASSERT( buffSocket != NULL );
-
-            synchronized(&serverThread.mutex)
-            {
-                if(serverThread.getNumClients() != 1)
-                {
-                    serverThread.mutex.wait(1000);
-                }
-            }
-            
-            CPPUNIT_ASSERT( client->isConnected() );
-            
-            CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
-            
-            client->close();
-            
-            synchronized(&serverThread.mutex)
-            {
-                if(serverThread.getNumClients() != 0)
-                {
-                    serverThread.mutex.wait(1000);
-                }
-            }
 
-            CPPUNIT_ASSERT( serverThread.getNumClients() == 0 );
-            
-            serverThread.stop();
-            serverThread.join();
-
-            delete client;
-         }
-         catch(exceptions::ActiveMQException ex)
-         {
-            CPPUNIT_ASSERT( false );
-         }
-      }
+       SocketFactoryTest() {}
+       virtual ~SocketFactoryTest() {}
+
+       void test();
+       void testNoDelay();
 
    };
 

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.cpp?view=diff&rev=533714&r1=533713&r2=533714
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.cpp
(original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.cpp
Mon Apr 30 04:53:18 2007
@@ -18,3 +18,215 @@
 #include "SocketTest.h"
 
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::network::SocketTest );
+
+#include <activemq/network/TcpSocket.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::network;
+
+////////////////////////////////////////////////////////////////////////////////
+void SocketTest::testConnect() {
+
+    try{
+
+        MyServerThread serverThread;
+        serverThread.start();
+
+        concurrent::Thread::sleep( 40 );
+
+        TcpSocket client;
+
+        client.connect("127.0.0.1", port);
+        client.setSoLinger( false );
+
+        synchronized(&serverThread.mutex)
+        {
+           if(serverThread.getNumClients() != 1)
+           {
+              serverThread.mutex.wait(1000);
+           }
+        }
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
+
+        client.close();
+
+        synchronized(&serverThread.mutex)
+        {
+           if(serverThread.getNumClients() != 0)
+           {
+              serverThread.mutex.wait(1000);
+           }
+        }
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 0 );
+
+        serverThread.stop();
+        serverThread.join();
+
+    }catch( io::IOException& ex ){
+        printf( "%s\n", ex.getMessage().c_str() );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SocketTest::testTx() {
+
+    try{
+
+        MyServerThread serverThread;
+        serverThread.start();
+
+        concurrent::Thread::sleep( 10 );
+
+        TcpSocket client;
+
+        client.connect("127.0.0.1", port);
+        client.setSoLinger( false );
+
+        synchronized(&serverThread.mutex)
+        {
+           if(serverThread.getNumClients() != 1)
+           {
+              serverThread.mutex.wait(1000);
+           }
+        }
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
+
+        io::OutputStream* stream = client.getOutputStream();
+
+        std::string msg = "don't reply";
+        stream->write( (unsigned char*)msg.c_str(), msg.length() );
+
+        concurrent::Thread::sleep( 10 );
+
+        CPPUNIT_ASSERT( serverThread.getLastMessage() == msg );
+
+        client.close();
+
+        synchronized(&serverThread.mutex)
+        {
+           if(serverThread.getNumClients() != 0)
+           {
+              serverThread.mutex.wait(1000);
+           }
+        }
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 0 );
+
+        serverThread.stop();
+        serverThread.join();
+
+    }catch( io::IOException& ex ){
+        printf( "%s\n", ex.getMessage().c_str() );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SocketTest::testTrx() {
+
+    try{
+
+        MyServerThread serverThread;
+        serverThread.start();
+
+        concurrent::Thread::sleep( 10 );
+
+        TcpSocket client;
+
+        client.connect("127.0.0.1", port);
+        client.setSoLinger(false);
+
+        synchronized(&serverThread.mutex)
+        {
+           if(serverThread.getNumClients() != 1)
+           {
+              serverThread.mutex.wait(1000);
+           }
+        }
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
+
+        io::OutputStream* stream = client.getOutputStream();
+
+        std::string msg = "reply";
+        stream->write( (unsigned char*)msg.c_str(), msg.length() );
+
+        synchronized(&serverThread.mutex)
+        {
+           serverThread.mutex.wait(300);
+        }
+
+        unsigned char buf[500];
+        memset( buf, 0, 500 );
+        io::InputStream* istream = client.getInputStream();
+        std::size_t numRead = istream->read( buf, 500 );
+        CPPUNIT_ASSERT( numRead == 5 );
+        CPPUNIT_ASSERT( strcmp( (char*)buf, "hello" ) == 0 );
+
+        client.close();
+
+        serverThread.stop();
+        serverThread.join();
+
+    }catch( io::IOException& ex ){
+        printf( "%s\n", ex.getMessage().c_str() );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SocketTest::testTrxNoDelay() {
+
+    try{
+
+        MyServerThread serverThread;
+        serverThread.start();
+
+        concurrent::Thread::sleep( 10 );
+
+        TcpSocket client;
+
+        client.connect("127.0.0.1", port);
+        client.setSoLinger(false);
+        client.setTcpNoDelay(true);
+
+        CPPUNIT_ASSERT( client.getTcpNoDelay() == true );
+
+        synchronized(&serverThread.mutex)
+        {
+           if(serverThread.getNumClients() != 1)
+           {
+              serverThread.mutex.wait(1000);
+           }
+        }
+
+        CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
+
+        io::OutputStream* stream = client.getOutputStream();
+
+        std::string msg = "reply";
+        stream->write( (unsigned char*)msg.c_str(), msg.length() );
+
+        synchronized(&serverThread.mutex)
+        {
+           serverThread.mutex.wait(300);
+        }
+
+        unsigned char buf[500];
+        memset( buf, 0, 500 );
+        io::InputStream* istream = client.getInputStream();
+        std::size_t numRead = istream->read( buf, 500 );
+        CPPUNIT_ASSERT( numRead == 5 );
+        CPPUNIT_ASSERT( strcmp( (char*)buf, "hello" ) == 0 );
+
+        client.close();
+
+        serverThread.stop();
+        serverThread.join();
+
+    }catch( io::IOException& ex ){
+        printf( "%s\n", ex.getMessage().c_str() );
+    }
+}

Modified: activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.h?view=diff&rev=533714&r1=533713&r2=533714
==============================================================================
--- activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.h (original)
+++ activemq/activemq-cpp/tags/activemq-cpp-2.0.1/src/test/activemq/network/SocketTest.h Mon
Apr 30 04:53:18 2007
@@ -21,7 +21,6 @@
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 
-#include <activemq/network/TcpSocket.h>
 #include <activemq/network/ServerSocket.h>
 #include <activemq/concurrent/Concurrent.h>
 #include <activemq/concurrent/Mutex.h>
@@ -31,273 +30,129 @@
 
 namespace activemq{
 namespace network{
-	
-	class SocketTest : public CppUnit::TestFixture {
-		
-	  CPPUNIT_TEST_SUITE( SocketTest );
-	  CPPUNIT_TEST( testConnect );
-	  CPPUNIT_TEST( testTx );
-	  CPPUNIT_TEST( testTrx );
-	  CPPUNIT_TEST_SUITE_END();
-		
-	public:
-		
-		static const int port = 23232;
-		
-		class MyServerThread : public concurrent::Thread{
-		private:
-		
-			bool done;
-			int numClients;
-			std::string lastMessage;
-            
+
+    class SocketTest : public CppUnit::TestFixture {
+
+      CPPUNIT_TEST_SUITE( SocketTest );
+      CPPUNIT_TEST( testConnect );
+      CPPUNIT_TEST( testTx );
+      CPPUNIT_TEST( testTrx );
+      CPPUNIT_TEST( testTrxNoDelay );
+      CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        static const int port = 23232;
+
+        class MyServerThread : public concurrent::Thread{
+        private:
+
+            bool done;
+            int numClients;
+            std::string lastMessage;
+
         public:
-        
+
             concurrent::Mutex mutex;
-			
-		public:
-        
-			MyServerThread(){
-				done = false;
-				numClients = 0;
-			}
-            
-			virtual ~MyServerThread(){
-				stop();
-			}
-			
-			std::string getLastMessage(){
-				return lastMessage;
-			}
-			
-			int getNumClients(){
-				return numClients;
-			}
-			
-			virtual void stop(){
-				done = true;
-			}
-			
-			virtual void run(){
-				try{
-					unsigned char buf[1000];
-					
-					ServerSocket server;
-					server.bind( "127.0.0.1", port );
-					
-					Socket* socket = server.accept();
-					server.close();
-					
-					//socket->setSoTimeout( 10 );
-					socket->setSoLinger( false );
-					numClients++;
-               
+
+        public:
+
+            MyServerThread(){
+                done = false;
+                numClients = 0;
+            }
+
+            virtual ~MyServerThread(){
+                stop();
+            }
+
+            std::string getLastMessage(){
+                return lastMessage;
+            }
+
+            int getNumClients(){
+                return numClients;
+            }
+
+            virtual void stop(){
+                done = true;
+            }
+
+            virtual void run(){
+                try{
+                    unsigned char buf[1000];
+
+                    ServerSocket server;
+                    server.bind( "127.0.0.1", port );
+
+                    Socket* socket = server.accept();
+                    server.close();
+
+                    //socket->setSoTimeout( 10 );
+                    socket->setSoLinger( false );
+                    numClients++;
+
                     synchronized(&mutex)
                     {
                        mutex.notifyAll();
                     }
 
-					while( !done && socket != NULL ){
-												
-						io::InputStream* stream = socket->getInputStream();
-							
-						memset( buf, 0, 1000 );
-						try{
-							stream->read( buf, 1000 );
-							
-							lastMessage = (char*)buf;
-							
-							if( strcmp( (char*)buf, "reply" ) == 0 ){
-								io::OutputStream* output = socket->getOutputStream();
-								output->write( (unsigned char*)"hello", strlen("hello" ) );
+                    while( !done && socket != NULL ){
+
+                        io::InputStream* stream = socket->getInputStream();
+
+                        memset( buf, 0, 1000 );
+                        try{
+                            stream->read( buf, 1000 );
+
+                            lastMessage = (char*)buf;
+
+                            if( strcmp( (char*)buf, "reply" ) == 0 ){
+                                io::OutputStream* output = socket->getOutputStream();
+                                output->write( (unsigned char*)"hello", strlen("hello"
) );
 
                                   synchronized(&mutex)
                                   {
                                      mutex.notifyAll();
                                   }
-							}
-							
-						}catch( io::IOException& ex ){
-							done = true;
-						}
-					}
-					
-					socket->close();
-					delete socket;
-					
-					numClients--;
-					
+                            }
+
+                        }catch( io::IOException& ex ){
+                            done = true;
+                        }
+                    }
+
+                    socket->close();
+                    delete socket;
+
+                    numClients--;
+
                     synchronized(&mutex)
                     {
                         mutex.notifyAll();
                     }
 
-				}catch( io::IOException& ex ){
-					printf("%s\n", ex.getMessage().c_str() );
-					CPPUNIT_ASSERT( false );
-				}catch( ... ){
-					CPPUNIT_ASSERT( false );
-				}
-			}
-			
-		};
-		
-	public:
-	
-        virtual ~SocketTest(){}
-		void testConnect(){
-
-			try{
-				
-				MyServerThread serverThread;
-				serverThread.start();
-			
-				concurrent::Thread::sleep( 40 );
-				
-				TcpSocket client;				
-				
-				client.connect("127.0.0.1", port);
-				//client.setSoTimeout( 5 );
-				client.setSoLinger( false );
-				
-                synchronized(&serverThread.mutex)
-                {
-                   if(serverThread.getNumClients() != 1)
-                   {
-                      serverThread.mutex.wait(1000);
-                   }
-                }
-            
-				CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
-				
-				client.close();
-
-                synchronized(&serverThread.mutex)
-                {
-                   if(serverThread.getNumClients() != 0)
-                   {
-                      serverThread.mutex.wait(1000);
-                   }
+                }catch( io::IOException& ex ){
+                    printf("%s\n", ex.getMessage().c_str() );
+                    CPPUNIT_ASSERT( false );
+                }catch( ... ){
+                    CPPUNIT_ASSERT( false );
                 }
+            }
 
-				CPPUNIT_ASSERT( serverThread.getNumClients() == 0 );
-				
-				serverThread.stop();
-		 		serverThread.join();
-	 		
-			}catch( io::IOException& ex ){
-				printf( "%s\n", ex.getMessage().c_str() );
-			}
-		}
-		
-		void testTx(){
-			
-			try{
-				
-                MyServerThread serverThread;
-				serverThread.start();
-			
-				concurrent::Thread::sleep( 10 );
-				
-				TcpSocket client;				
-				
-				client.connect("127.0.0.1", port);
-				//client.setSoTimeout( 5 );
-				client.setSoLinger( false );
-								
-                synchronized(&serverThread.mutex)
-                {
-                   if(serverThread.getNumClients() != 1)
-                   {
-                      serverThread.mutex.wait(1000);
-                   }
-                }
+        };
 
-				CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
-				
-				io::OutputStream* stream = client.getOutputStream();
-				
-				std::string msg = "don't reply";
-				stream->write( (unsigned char*)msg.c_str(), msg.length() );				
-				
-				concurrent::Thread::sleep( 10 );
-				
-				CPPUNIT_ASSERT( serverThread.getLastMessage() == msg );
-				
-				client.close();
-				
-                synchronized(&serverThread.mutex)
-                {
-                   if(serverThread.getNumClients() != 0)
-                   {
-                      serverThread.mutex.wait(1000);
-                   }
-                }
+    public:
 
-				CPPUNIT_ASSERT( serverThread.getNumClients() == 0 );
-				
-				serverThread.stop();
-		 		serverThread.join();
-	 		
-			}catch( io::IOException& ex ){
-				printf( "%s\n", ex.getMessage().c_str() );
-			}
-		}
-		
-		void testTrx(){
-			
-			try{
-				
-                MyServerThread serverThread;
-				serverThread.start();
-			
-				concurrent::Thread::sleep( 10 );				
-				
-				TcpSocket client;				
-				
-				client.connect("127.0.0.1", port);
-				//client.setSoTimeout( 5 );
-				client.setSoLinger(false);
-				
-                synchronized(&serverThread.mutex)
-                {
-                   if(serverThread.getNumClients() != 1)
-                   {
-                      serverThread.mutex.wait(1000);
-                   }
-                }
+        virtual ~SocketTest() {}
 
-				CPPUNIT_ASSERT( serverThread.getNumClients() == 1 );
-				
-				io::OutputStream* stream = client.getOutputStream();
-				
-				std::string msg = "reply";
-				stream->write( (unsigned char*)msg.c_str(), msg.length() );				
-				
-                synchronized(&serverThread.mutex)
-                {
-                   serverThread.mutex.wait(300);
-                }
-				
-				unsigned char buf[500];
-				memset( buf, 0, 500 );
-				io::InputStream* istream = client.getInputStream();
-				std::size_t numRead = istream->read( buf, 500 );
-				CPPUNIT_ASSERT( numRead == 5 );
-				CPPUNIT_ASSERT( strcmp( (char*)buf, "hello" ) == 0 );
-				
-				client.close();
-				
-				serverThread.stop();
-				serverThread.join();
-	 		
-			}catch( io::IOException& ex ){
-				printf( "%s\n", ex.getMessage().c_str() );
-			}
-		}
+        void testConnect();
+        void testTx();
+        void testTrx();
+        void testTrxNoDelay();
+
+    };
 
-	};
-	
 }}
 
 #endif /*ACTIVEMQ_IO_SOCKETTEST_H_*/



Mime
View raw message