You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by nm...@apache.org on 2006/07/03 13:51:54 UTC

svn commit: r418749 [16/17] - in /incubator/activemq/trunk/activemq-cpp: ./ src/ src/main/ src/main/activemq/ src/main/activemq/concurrent/ src/main/activemq/connector/ src/main/activemq/connector/openwire/ src/main/activemq/connector/stomp/ src/main/a...

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketFactoryTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketFactoryTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketFactoryTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketFactoryTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,196 @@
+#ifndef _ACTIVEMQ_NETWORK_SOCKETFACTORYTEST_H_
+#define _ACTIVEMQ_NETWORK_SOCKETFACTORYTEST_H_
+
+#include <cppunit/TestFixture.h>
+#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>
+
+#include <sstream>
+
+namespace activemq{
+namespace network{
+
+   class SocketFactoryTest : public CppUnit::TestFixture
+   {
+      CPPUNIT_TEST_SUITE( SocketFactoryTest );
+      CPPUNIT_TEST( test );
+      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();        
+         }
+         
+         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)
+               {
+                   numClients++;
+
+                   mutex.notifyAll();
+               }
+
+               while( !done && socket != NULL ){
+                                    
+                  io::InputStream* stream = socket->getInputStream();
+                  if( stream->available() > 0 ){
+                     
+                     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;
+                     }                                      
+                     
+                  }else{
+                     Thread::sleep( 10 );
+                  }
+               }
+               
+               socket->close();
+               delete socket;
+               
+               numClients--;
+               
+               synchronized(&mutex)
+               {
+                   mutex.notifyAll();
+               }
+               
+            }catch( io::IOException& ex ){
+               printf("%s\n", ex.getMessage() );
+               CPPUNIT_ASSERT( false );
+            }catch( ... ){
+               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 );
+         }
+      }
+
+   };
+
+}}
+
+#endif /*_ACTIVEMQ_NETWORK_SOCKETFACTORYTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,3 @@
+#include "SocketTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::network::SocketTest );

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/network/SocketTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,296 @@
+#ifndef ACTIVEMQ_IO_SOCKETTEST_H_
+#define ACTIVEMQ_IO_SOCKETTEST_H_
+
+#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>
+#include <activemq/concurrent/Thread.h>
+#include <list>
+#include <string.h>
+
+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;
+            
+        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++;
+               
+                    synchronized(&mutex)
+                    {
+                       mutex.notifyAll();
+                    }
+
+					while( !done && socket != NULL ){
+												
+						io::InputStream* stream = socket->getInputStream();
+						if( stream->available() > 0 ){
+							
+							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;
+							}													
+							
+						}else{
+							Thread::sleep( 10 );
+						}
+					}
+					
+					socket->close();
+					delete socket;
+					
+					numClients--;
+					
+                    synchronized(&mutex)
+                    {
+                        mutex.notifyAll();
+                    }
+
+				}catch( io::IOException& ex ){
+					printf("%s\n", ex.getMessage() );
+					CPPUNIT_ASSERT( false );
+				}catch( ... ){
+					CPPUNIT_ASSERT( false );
+				}
+			}
+			
+		};
+		
+	public:
+	
+		virtual void setUp(){};	
+	 	virtual void tearDown(){	 			 		
+	 	};
+		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);
+                   }
+                }
+
+				CPPUNIT_ASSERT( serverThread.getNumClients() == 0 );
+				
+				serverThread.stop();
+		 		serverThread.join();
+	 		
+			}catch( io::IOException& ex ){
+				const char* error = ex.getMessage();
+				printf( "%s\n", error );
+			}
+		}
+		
+		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);
+                   }
+                }
+
+				CPPUNIT_ASSERT( serverThread.getNumClients() == 0 );
+				
+				serverThread.stop();
+		 		serverThread.join();
+	 		
+			}catch( io::IOException& ex ){
+				const char* error = ex.getMessage();
+				printf( "%s\n", error );
+			}
+		}
+		
+		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);
+                   }
+                }
+
+				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();
+				int 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 ){
+				const char* error = ex.getMessage();
+				printf( "%s\n", error );
+			}
+		}
+
+	};
+	
+}}
+
+#endif /*ACTIVEMQ_IO_SOCKETTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransport.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransport.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransport.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransport.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,230 @@
+#ifndef ACTIVEMQ_TANSPORT_DUMMYTRANSPORT_H_
+#define ACTIVEMQ_TANSPORT_DUMMYTRANSPORT_H_
+
+#include <activemq/transport/Transport.h>
+#include <activemq/concurrent/Concurrent.h>
+#include <activemq/transport/CommandListener.h>
+#include <activemq/transport/TransportExceptionListener.h>
+#include <activemq/transport/CommandIOException.h>
+#include <activemq/concurrent/Concurrent.h>
+#include <activemq/concurrent/Mutex.h>
+#include <activemq/concurrent/Thread.h>
+
+namespace activemq{
+namespace transport{
+    
+    class DummyTransport : public Transport{
+    
+    public:
+    
+        class ResponseBuilder{
+        public:
+            virtual ~ResponseBuilder(){}
+            
+            virtual Response* buildResponse( const Command* cmd ) = 0;
+        };
+
+        class InternalCommandListener : 
+            public CommandListener,
+            public concurrent::Thread
+        {
+        private:
+
+            DummyTransport* transport;
+            ResponseBuilder* responseBuilder;
+            concurrent::Mutex mutex;
+            Command* command;
+            bool done;
+
+        public:
+
+            InternalCommandListener(void) {
+                command = NULL;
+                transport = NULL;
+                responseBuilder = NULL;
+                done = false;
+                
+                this->start();
+            }
+
+            virtual ~InternalCommandListener() {
+                done = true;
+                synchronized( &mutex )
+                {
+                    mutex.notifyAll();
+                }
+                this->join();
+            }
+
+            void setTransport( DummyTransport* transport ){
+                this->transport = transport;
+            }
+
+            void setResponseBuilder( ResponseBuilder* responseBuilder ) {
+                this->responseBuilder = responseBuilder;
+            }
+
+            virtual void onCommand( Command* command )
+            {
+                synchronized( &mutex )
+                {
+                    this->command = command;
+                    
+                    mutex.notifyAll();
+                }                
+            }
+
+            void run(void)
+            {
+                try
+                {
+                    synchronized( &mutex )
+                    {
+                        while( !done )
+                        {
+                            mutex.wait();
+                            
+                            if( command == NULL )
+                            {
+                                continue;
+                            }
+                            
+                            concurrent::Thread::sleep( 100 );
+                            
+                            if( responseBuilder != NULL && 
+                                transport != NULL )
+                            {
+                                transport->fireCommand( 
+                                    responseBuilder->buildResponse( 
+                                        command ) );
+                                        
+                                command = NULL;
+                                
+                                return;
+                            }
+                        }
+                    }
+                }
+                AMQ_CATCHALL_NOTHROW()
+            }
+        };
+        
+    private:
+    
+        ResponseBuilder* responseBuilder;
+        CommandListener* commandListener;
+        CommandListener* outgoingCommandListener;
+        TransportExceptionListener* exceptionListener;
+        unsigned int nextCommandId;
+        concurrent::Mutex commandIdMutex;
+        bool own;
+        InternalCommandListener defaultListener;
+        
+    public:
+    
+        DummyTransport( ResponseBuilder* responseBuilder , 
+                        bool own = false,
+                        bool useDefOutgoing = false ){
+            
+            this->responseBuilder = NULL;
+            this->commandListener = NULL;
+            this->outgoingCommandListener = NULL;
+            this->exceptionListener = NULL;
+            this->responseBuilder = responseBuilder;
+            this->own = own;
+            this->nextCommandId = 0;
+            if( useDefOutgoing )
+            {
+                this->outgoingCommandListener = &defaultListener;
+                this->defaultListener.setTransport( this );
+                this->defaultListener.setResponseBuilder( responseBuilder );
+            }
+        }
+        
+        virtual ~DummyTransport(){
+            if( own ){
+                delete responseBuilder;
+            }
+        }
+        
+        void setResponseBuilder( ResponseBuilder* responseBuilder ){
+            this->responseBuilder = responseBuilder;
+        }
+        
+        unsigned int getNextCommandId() throw (exceptions::ActiveMQException){
+            
+            try{
+                synchronized( &commandIdMutex ){
+                    return ++nextCommandId;
+                }
+                
+                // Should never get here, but some compilers aren't
+                // smart enough to figure out we'll never get here.
+                return 0;
+            }
+            AMQ_CATCHALL_THROW( transport::CommandIOException )
+        }
+        
+        virtual void oneway( Command* command ) 
+                throw(CommandIOException, exceptions::UnsupportedOperationException)
+        {            
+            if( outgoingCommandListener != NULL ){
+                
+                command->setCommandId( getNextCommandId() );
+                command->setResponseRequired( false );
+                outgoingCommandListener->onCommand( command );
+                return;
+            }
+        }
+        
+        virtual Response* request( Command* command ) 
+            throw(CommandIOException, 
+                  exceptions::UnsupportedOperationException)
+        {
+            if( responseBuilder != NULL ){
+                command->setCommandId( getNextCommandId() );
+                command->setResponseRequired( true );
+                return responseBuilder->buildResponse( command );
+            }
+            
+            throw CommandIOException( __FILE__, __LINE__,
+                "no response builder available" );
+        }
+        
+        virtual void setCommandListener( CommandListener* listener ){
+            this->commandListener = listener;
+        }
+        
+        virtual void setOutgoingCommandListener( CommandListener* listener ){
+            outgoingCommandListener = listener;
+        }
+        
+        virtual void setCommandReader( CommandReader* reader ){}
+        
+        virtual void setCommandWriter( CommandWriter* writer ){}
+        
+        virtual void setTransportExceptionListener( 
+            TransportExceptionListener* listener )
+        {
+            this->exceptionListener = listener;
+        }
+        
+        virtual void fireCommand( Command* cmd ){
+            if( commandListener != NULL ){
+                commandListener->onCommand( cmd );
+            }
+        }
+        
+        virtual void fireException( const exceptions::ActiveMQException& ex ){
+            if( exceptionListener != NULL ){
+                exceptionListener->onTransportException( this, ex );
+            }
+        }
+        
+        virtual void start() throw (cms::CMSException){}
+        virtual void close() throw (cms::CMSException){}
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_TANSPORT_DUMMYTRANSPORT_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransportFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransportFactory.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransportFactory.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransportFactory.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "DummyTransportFactory.h"
+#include <activemq/support/LibraryInit.h>
+
+using namespace activemq;
+using namespace activemq::transport;
+
+////////////////////////////////////////////////////////////////////////////////
+//TransportFactoryMapRegistrar DummyTransportFactory::registrar(
+//    "dummy", new DummyTransportFactory());
+//

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransportFactory.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransportFactory.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransportFactory.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/DummyTransportFactory.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 ACTIVEMQ_TRANSPORT_DUMMYTRANSPORTFACTORY_H_
+#define ACTIVEMQ_TRANSPORT_DUMMYTRANSPORTFACTORY_H_
+
+#include <activemq/transport/DummyTransport.h>
+#include <activemq/transport/TransportFactory.h>
+#include <activemq/transport/TransportFactoryMapRegistrar.h>
+#include <activemq/connector/stomp/StompResponseBuilder.h>
+#include <activemq/support/LibraryInit.h>
+
+namespace activemq{
+namespace transport{
+    
+    /**
+     * Manufactures DummyTransports, which are objects that
+     * read from input streams and write to output streams.
+     */
+    class DummyTransportFactory : public TransportFactory{
+    private:
+    
+ //       static TransportFactoryMapRegistrar registrar;
+        
+    public:
+        
+        virtual ~DummyTransportFactory(){}
+        
+        /**
+         * Creates a Transport instance. 
+         * @param properties The properties for the transport.
+         */
+        virtual Transport* createTransport( 
+            const activemq::util::Properties& properties )
+        {
+            std::string wireFormat = 
+                properties.getProperty( "wireFormat", "stomp" );
+
+            DummyTransport::ResponseBuilder* builder = NULL;
+
+            if( wireFormat == "stomp" )
+            {
+                builder = new connector::stomp::StompResponseBuilder(
+                    properties.getProperty( 
+                        "transport.sessionId", "testSessionId" ) );
+            }
+            
+            return new DummyTransport( builder, true );
+        }
+
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_DUMMYTRANSPORTFACTORY_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,4 @@
+#include "IOTransportTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::IOTransportTest );
+

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,328 @@
+#ifndef ACTIVEMQ_COMMANDS_IOTRANSPORTTEST_H_
+#define ACTIVEMQ_COMMANDS_IOTRANSPORTTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/transport/IOTransport.h>
+#include <activemq/transport/CommandListener.h>
+#include <activemq/transport/CommandReader.h>
+#include <activemq/transport/CommandWriter.h>
+#include <activemq/transport/Command.h>
+#include <activemq/transport/TransportExceptionListener.h>
+#include <activemq/concurrent/Concurrent.h>
+#include <activemq/io/ByteArrayInputStream.h>
+#include <activemq/io/ByteArrayOutputStream.h>
+#include <activemq/concurrent/Thread.h>
+#include <activemq/concurrent/Mutex.h>
+
+namespace activemq{
+namespace transport{
+
+    class IOTransportTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( IOTransportTest );
+        CPPUNIT_TEST( testStartClose );
+        CPPUNIT_TEST( testRead );
+        CPPUNIT_TEST( testWrite );
+        CPPUNIT_TEST( testException );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+    
+        class MyCommand : public Command{
+        public:
+            MyCommand(){ c = 0; }
+            virtual ~MyCommand(){}
+            
+            char c;
+            
+            virtual void setCommandId( const unsigned int id ){}
+            virtual unsigned int getCommandId() const{ return 0; }
+            
+            virtual void setResponseRequired( const bool required ){}
+            virtual bool isResponseRequired() const{ return false; }
+        };
+        
+        class MyCommandListener : public CommandListener{
+        public:
+            MyCommandListener(){}
+            virtual ~MyCommandListener(){}
+            
+            std::string str;
+            virtual void onCommand( Command* command ){
+                const MyCommand* cmd = dynamic_cast<const MyCommand*>(command);
+                str += cmd->c;
+            }
+        };
+        
+        class MyCommandReader : public CommandReader{
+        private:
+       
+            /**
+             * The target input stream.
+             */
+            io::InputStream* inputStream;
+            
+        public:
+            MyCommandReader(){ throwException = false; }
+            virtual ~MyCommandReader(){}
+            
+            bool throwException;
+    
+            virtual void setInputStream(io::InputStream* is){
+                inputStream = is;
+            }
+
+            virtual io::InputStream* getInputStream(void){
+                return inputStream;
+            }
+
+            virtual Command* readCommand( void ) throw (CommandIOException){
+              
+                try{
+                    if( throwException ){
+                        throw CommandIOException();
+                    }
+                    
+                    synchronized( inputStream ){
+                        MyCommand* command = new MyCommand();
+                        command->c = inputStream->read();
+                        return command;
+                    }
+                    
+                    assert(false);
+                    return NULL;
+                }catch( exceptions::ActiveMQException& ex ){
+                    CommandIOException cx( ex );
+                    cx.setMark( __FILE__, __LINE__ );
+                    throw cx;
+                }
+            }
+
+            virtual int read(unsigned char* buffer, int count) 
+                throw( io::IOException ) {
+                return 0;
+            }
+           
+            virtual unsigned char readByte() throw(io::IOException) {
+                return 0;
+            }
+        };
+        
+        class MyCommandWriter : public CommandWriter{
+        private:
+        
+            /**
+             * Target output stream.
+             */
+            io::OutputStream* outputStream;
+            
+        public:
+            virtual ~MyCommandWriter(){}
+
+            virtual void setOutputStream(io::OutputStream* os){
+                outputStream = os;
+            }
+          
+            virtual io::OutputStream* getOutputStream(void){
+                return outputStream;
+            }
+
+            virtual void writeCommand( const Command* command ) 
+                throw (CommandIOException)
+            {
+                try{
+                    synchronized( outputStream ){
+                                            
+                        const MyCommand* m = 
+                            dynamic_cast<const MyCommand*>(command);
+                        outputStream->write( m->c );                    
+                    }
+                }catch( exceptions::ActiveMQException& ex ){
+                    CommandIOException cx( ex );
+                    cx.setMark( __FILE__, __LINE__ );
+                    throw cx;
+                }
+            }
+
+            virtual void write(const unsigned char* buffer, int count) 
+                throw(io::IOException) {}
+           
+            virtual void writeByte(unsigned char v) throw(io::IOException) {}
+        };
+        
+        class MyExceptionListener : public TransportExceptionListener{
+        public:
+        
+            Transport* transport;
+            concurrent::Mutex mutex;
+            
+            MyExceptionListener(){
+                transport = NULL;
+            }
+            virtual ~MyExceptionListener(){}
+            
+            virtual void onTransportException( Transport* source, const exceptions::ActiveMQException& ex ){
+                transport = source;
+
+                synchronized(&mutex)
+                {
+                   mutex.notify();
+                }
+            }
+        };        
+    
+    public:
+
+        virtual void setUp(){}; 
+        virtual void tearDown(){};
+        
+        // This will just test that we can start and stop the 
+        // transport without any exceptions.
+        void testStartClose(){
+            
+            io::ByteArrayInputStream is;
+            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();
+            
+            concurrent::Thread::sleep( 50 );
+            
+            transport.close();
+        }
+        
+        void testRead(){
+            
+            io::ByteArrayInputStream is;
+            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();
+            
+            concurrent::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__ );
+            }
+            
+            concurrent::Thread::sleep( 100 );
+            
+            CPPUNIT_ASSERT( listener.str == "1234567890" );
+            
+            transport.close();
+        }
+        
+        void testWrite(){
+            
+            io::ByteArrayInputStream is;
+            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.getByteArray();
+            int size = os.getByteArraySize();
+            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(){
+            
+            io::ByteArrayInputStream is;
+            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 );
+            
+            transport.close();
+        }
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_COMMANDS_IOTRANSPORTTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/ResponseCorrelatorTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/ResponseCorrelatorTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/ResponseCorrelatorTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/ResponseCorrelatorTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,4 @@
+#include "ResponseCorrelatorTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::ResponseCorrelatorTest );
+

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/ResponseCorrelatorTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/ResponseCorrelatorTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/ResponseCorrelatorTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/ResponseCorrelatorTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,625 @@
+#ifndef ACTIVEMQ_COMMANDS_RESPONSECORRELATORTEST_H_
+#define ACTIVEMQ_COMMANDS_RESPONSECORRELATORTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/transport/ResponseCorrelator.h>
+#include <activemq/transport/ExceptionResponse.h>
+#include <activemq/concurrent/Thread.h>
+#include <activemq/concurrent/Concurrent.h>
+#include <activemq/exceptions/UnsupportedOperationException.h>
+#include <queue>
+
+namespace activemq{
+namespace transport{
+
+    class ResponseCorrelatorTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( ResponseCorrelatorTest );
+        CPPUNIT_TEST( testBasics );
+        CPPUNIT_TEST( testOneway );
+        CPPUNIT_TEST( testExceptionResponse );
+        CPPUNIT_TEST( testTransportException );
+        CPPUNIT_TEST( testMultiRequests );
+        CPPUNIT_TEST_SUITE_END();    
+    
+    public:
+    
+        class MyCommand : public Command{
+        private:
+        
+            unsigned int commandId;
+            bool responseRequired;
+            
+        public:
+        
+            virtual void setCommandId( const unsigned int id ){
+                commandId = id;
+            }
+            virtual unsigned int getCommandId() const{
+                return commandId;
+            }
+            
+            virtual void setResponseRequired( const bool required ){
+                responseRequired = required;
+            }
+            virtual bool isResponseRequired() const{
+                return responseRequired;
+            }
+        };
+        
+        class MyResponse : public Response{
+        private:
+        
+            unsigned int commandId;
+            bool responseRequired;
+            unsigned int corrId;
+            
+        public:
+        
+            virtual void setCommandId( const unsigned int id ){
+                commandId = id;
+            }
+            virtual unsigned int getCommandId() const{
+                return commandId;
+            }
+            
+            virtual void setResponseRequired( const bool required ){
+                responseRequired = required;
+            }
+            virtual bool isResponseRequired() const{
+                return responseRequired;
+            }
+        
+            virtual unsigned int getCorrelationId() const{
+                return corrId;
+            }
+            virtual void setCorrelationId( const unsigned int corrId ){
+                this->corrId = corrId;
+            }
+        };
+        
+        class MyExceptionResponse : public ExceptionResponse{
+        public:
+        
+            unsigned int commandId;
+            bool responseRequired;
+            unsigned int corrId;
+            BrokerError error;
+            
+        public:
+        
+            virtual void setCommandId( const unsigned int id ){
+                commandId = id;
+            }
+            virtual unsigned int getCommandId() const{
+                return commandId;
+            }
+            
+            virtual void setResponseRequired( const bool required ){
+                responseRequired = required;
+            }
+            virtual bool isResponseRequired() const{
+                return responseRequired;
+            }
+        
+            virtual unsigned int getCorrelationId() const{
+                return corrId;
+            }
+            virtual void setCorrelationId( const unsigned int corrId ){
+                this->corrId = corrId;
+            }
+            virtual const BrokerError* getException() const{
+                return &error;
+            }
+        };
+        
+        class MyTransport 
+        : 
+            public Transport,
+            public concurrent::Runnable{
+        public:
+            CommandReader* reader;
+            CommandWriter* writer;
+            CommandListener* listener;
+            TransportExceptionListener* exListener;
+            concurrent::Thread* thread;
+            concurrent::Mutex mutex;
+            concurrent::Mutex startedMutex;
+            bool done;
+            std::queue<Command*> requests;
+            
+        public:
+        
+            MyTransport(){
+                reader = NULL;
+                writer = NULL;
+                listener = NULL;
+                exListener = NULL;
+                thread = NULL;
+                done = false;
+            }
+            
+            virtual ~MyTransport(){
+                
+                close();
+            }
+            
+            virtual void oneway( Command* command ) 
+                throw(CommandIOException, exceptions::UnsupportedOperationException)
+            {
+                synchronized( &mutex ){
+                    requests.push( command );
+                    mutex.notifyAll();
+                }
+            }
+            
+            virtual Response* request( Command* command ) 
+                throw(CommandIOException, exceptions::UnsupportedOperationException)
+            {
+                throw exceptions::UnsupportedOperationException( 
+                    __FILE__, 
+                    __LINE__, 
+                    "stuff" );
+            }
+            
+            virtual void setCommandListener( CommandListener* listener ){
+                this->listener = listener;
+            }
+            
+            virtual void setCommandReader( CommandReader* reader ){
+                this->reader = reader;
+            }
+            
+            virtual void setCommandWriter( CommandWriter* writer ){
+                this->writer = writer;
+            }
+            
+            virtual void setTransportExceptionListener( 
+                TransportExceptionListener* listener )
+            {
+                this->exListener = listener;
+            }
+            
+            virtual void start() throw( cms::CMSException ){
+                close();
+                
+                done = false;
+                
+                thread = new concurrent::Thread( this );
+                thread->start();
+            }
+            
+            virtual void close() throw( cms::CMSException ){
+                
+                done = true;
+                
+                if( thread != NULL ){                    
+                    synchronized( &mutex ){
+                        mutex.notifyAll();
+                    }
+                    thread->join();
+                    delete thread;
+                    thread = NULL;
+                }
+            }
+            
+            virtual Response* createResponse( Command* command ){
+                
+                MyResponse* resp = new MyResponse();
+                resp->setCorrelationId( command->getCommandId() );
+                resp->setResponseRequired( false );
+                return resp;
+            }
+            
+            virtual void run(){
+                
+                try{
+
+                    synchronized(&startedMutex)
+                    {
+                       startedMutex.notifyAll();
+                    }
+
+                    synchronized( &mutex ){
+                        
+                        while( !done ){
+                            
+                            if( requests.empty() ){
+                                mutex.wait();
+                            }else{
+                                
+                                Command* cmd = requests.front();
+                                requests.pop();
+                                
+                                // Only send a response if one is required.
+                                Response* resp = NULL;
+                                if( cmd->isResponseRequired() ){
+                                    resp = createResponse( cmd );
+                                }
+                                
+                                mutex.unlock();
+                                
+                                // Send both the response and the original
+                                // command back to the correlator.
+                                if( listener != NULL ){
+                                    if( resp != NULL ){
+                                        listener->onCommand( resp );
+                                    }
+                                    listener->onCommand( cmd );
+                                }
+                                
+                                mutex.lock();
+                            }
+                        }
+                    }
+                }catch( exceptions::ActiveMQException& ex ){
+                    if( exListener ){
+                        exListener->onTransportException( this, ex );
+                    }
+                }
+                catch( ... ){                    
+                    if( exListener ){
+                        exceptions::ActiveMQException ex( __FILE__, __LINE__, "stuff" );
+                        exListener->onTransportException( this, ex );
+                    }
+                }
+            }
+        };
+        
+        class MyExceptionResponseTransport : public MyTransport{
+        public:
+        
+            MyExceptionResponseTransport(){}            
+            virtual ~MyExceptionResponseTransport(){}
+            
+            virtual Response* createResponse( Command* command ){
+                
+                MyExceptionResponse* resp = new MyExceptionResponse();
+                resp->setCorrelationId( command->getCommandId() );
+                resp->setResponseRequired( false );
+                resp->error = BrokerError( __FILE__, __LINE__, 
+                    "some bad broker stuff" );
+                return resp;
+            }
+        };
+        
+        class MyBrokenTransport : public MyTransport{
+        public:
+        
+            MyBrokenTransport(){}            
+            virtual ~MyBrokenTransport(){}
+            
+            virtual Response* createResponse( Command* command ){                
+                throw exceptions::ActiveMQException( __FILE__, __LINE__,
+                    "bad stuff" );
+            }
+        };
+        
+        class MyListener 
+        : 
+            public CommandListener,
+            public TransportExceptionListener{
+                
+        public:
+            
+            int exCount;
+            std::set<int> commands;
+            concurrent::Mutex mutex;
+            
+        public:
+        
+            MyListener(){
+                exCount = 0;
+            }
+            virtual ~MyListener(){}
+            virtual void onCommand( Command* command ){
+                
+                synchronized( &mutex ){
+                    commands.insert( command->getCommandId() );
+
+                    mutex.notify(); 
+                }
+            }
+            
+            virtual void onTransportException( 
+                Transport* source, 
+                const exceptions::ActiveMQException& ex )
+            {
+                synchronized( &mutex ){
+                    exCount++;
+                }
+            }
+        };
+        
+        class RequestThread : public concurrent::Thread{
+        public:
+        
+            Transport* transport;
+            MyCommand cmd;
+            Response* resp;
+        public:
+        
+            RequestThread(){
+                transport = NULL;
+                resp = NULL;
+            }
+            virtual ~RequestThread(){
+                join();
+                
+                if( resp != NULL ){
+                    delete resp;
+                    resp = NULL;
+                }
+            }
+            
+            void setTransport( Transport* transport ){
+                this->transport = transport;
+            }
+            
+            void run(){
+                
+                try{                    
+                    resp = transport->request(&cmd);                    
+                }catch( ... ){
+                    CPPUNIT_ASSERT( false );
+                }
+            }
+        };
+        
+    public:
+
+        virtual void setUp(){}; 
+        virtual void tearDown(){};
+        
+        void testBasics(){
+            
+            try{
+                
+                MyListener listener;
+                MyTransport transport;
+                ResponseCorrelator correlator( &transport, false );
+                correlator.setCommandListener( &listener );
+                correlator.setTransportExceptionListener( &listener );
+                CPPUNIT_ASSERT( transport.listener == &correlator );
+                CPPUNIT_ASSERT( transport.exListener == &correlator );
+                
+                // Give the thread a little time to get up and running.
+                synchronized(&transport.startedMutex)
+                {
+                    // Start the transport.
+                    correlator.start();
+                    transport.startedMutex.wait();
+                }
+                
+                // Send one request.
+                MyCommand cmd;
+                Response* resp = correlator.request( &cmd );
+                CPPUNIT_ASSERT( resp != NULL );
+                CPPUNIT_ASSERT( dynamic_cast<ExceptionResponse*>(resp) == NULL );
+                CPPUNIT_ASSERT( resp->getCorrelationId() == cmd.getCommandId() );
+                
+                // Wait to get the message back asynchronously.
+                concurrent::Thread::sleep( 100 );
+                
+                // Since our transport relays our original command back at us as a
+                // non-response message, check to make sure we received it and that
+                // it is the original command.
+                CPPUNIT_ASSERT( listener.commands.size() == 1 );                
+                CPPUNIT_ASSERT( listener.exCount == 0 );
+                
+                correlator.close();
+                
+                // Destroy the response.
+                delete resp;
+            }
+            AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+            AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+        }
+        
+        void testOneway(){
+            
+            try{
+                
+                MyListener listener;
+                MyTransport transport;
+                ResponseCorrelator correlator( &transport, false );
+                correlator.setCommandListener( &listener );
+                correlator.setTransportExceptionListener( &listener );
+                CPPUNIT_ASSERT( transport.listener == &correlator );
+                CPPUNIT_ASSERT( transport.exListener == &correlator );
+                
+                // Give the thread a little time to get up and running.
+                synchronized(&transport.startedMutex)
+                {
+                    // Start the transport.
+                    correlator.start(); 
+                    
+                    transport.startedMutex.wait();
+                }
+                
+                // Send many oneway request (we'll get them back asynchronously).
+                const unsigned int numCommands = 1000;
+                MyCommand commands[numCommands];                
+                for( unsigned int ix=0; ix<numCommands; ix++ ){
+                    correlator.oneway( &commands[ix] );
+                }
+                
+                // Give the thread a little time to get all the messages back.
+                concurrent::Thread::sleep( 500 );
+                
+                // Make sure we got them all back.
+                CPPUNIT_ASSERT( listener.commands.size() == numCommands );
+                CPPUNIT_ASSERT( listener.exCount == 0 );
+                
+                correlator.close();
+            }
+            AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+            AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+        }
+        
+        void testExceptionResponse(){
+            
+            try{
+                
+                MyListener listener;
+                MyExceptionResponseTransport transport;
+                ResponseCorrelator correlator( &transport, false );
+                correlator.setCommandListener( &listener );
+                correlator.setTransportExceptionListener( &listener );
+                CPPUNIT_ASSERT( transport.listener == &correlator );
+                CPPUNIT_ASSERT( transport.exListener == &correlator );
+                                                               
+                // Give the thread a little time to get up and running.
+                synchronized(&transport.startedMutex)
+                {
+                    // Start the transport.
+                    correlator.start();
+                    
+                    transport.startedMutex.wait();
+                }
+                
+                // Send one request.
+                MyCommand cmd;
+                Response* resp = correlator.request( &cmd );
+                CPPUNIT_ASSERT( resp != NULL );
+                CPPUNIT_ASSERT( dynamic_cast<ExceptionResponse*>(resp) != NULL );
+                CPPUNIT_ASSERT( resp->getCorrelationId() == cmd.getCommandId() );
+                
+                // Wait to make sure we get the exception.
+                concurrent::Thread::sleep( 100 );
+                
+                // Since our transport relays our original command back at us as a
+                // non-response message, check to make sure we received it and that
+                // it is the original command.
+                CPPUNIT_ASSERT( listener.commands.size() == 1 );                
+                CPPUNIT_ASSERT( listener.exCount == 1 );
+                
+                correlator.close();
+                
+                // Destroy the response.
+                delete resp;                              
+            }
+            AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+            AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+        }
+        
+        void testTransportException(){
+            
+            try{
+                
+                MyListener listener;
+                MyBrokenTransport transport;
+                ResponseCorrelator correlator( &transport, false );
+                correlator.setCommandListener( &listener );
+                correlator.setTransportExceptionListener( &listener );
+                CPPUNIT_ASSERT( transport.listener == &correlator );
+                CPPUNIT_ASSERT( transport.exListener == &correlator );
+                
+                // Give the thread a little time to get up and running.
+                synchronized(&transport.startedMutex)
+                {
+                    // Start the transport.
+                    correlator.start();
+                    
+                    transport.startedMutex.wait();
+                }
+                
+                // Send one request.                
+                MyCommand cmd;
+                try{
+                    correlator.request( &cmd );
+                    CPPUNIT_ASSERT(false);
+                }catch( CommandIOException& ex ){
+                    // Expected.
+                }
+                
+                // Wait to make sure we get the asynchronous message back.
+                concurrent::Thread::sleep( 100 );
+                
+                // Since our transport relays our original command back at us as a
+                // non-response message, check to make sure we received it and that
+                // it is the original command.
+                CPPUNIT_ASSERT( listener.commands.size() == 0 );                
+                CPPUNIT_ASSERT( listener.exCount == 1 );
+                
+                correlator.close();
+            }
+            AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+            AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+        }
+        
+        void testMultiRequests(){
+            
+            try{
+                
+                MyListener listener;
+                MyTransport transport;
+                ResponseCorrelator correlator( &transport, false );
+                correlator.setCommandListener( &listener );
+                correlator.setTransportExceptionListener( &listener );
+                CPPUNIT_ASSERT( transport.listener == &correlator );
+                CPPUNIT_ASSERT( transport.exListener == &correlator );
+                
+                // Start the transport.
+                correlator.start();                               
+                
+                // Make sure the start command got down to the thread.
+                CPPUNIT_ASSERT( transport.thread != NULL );
+                
+                // Give the thread a little time to get up and running.
+                synchronized(&transport.startedMutex)
+                {
+                    transport.startedMutex.wait(500);
+                }
+                
+                // Start all the requester threads.
+                const unsigned int numRequests = 100;
+                RequestThread requesters[numRequests];
+                for( unsigned int ix=0; ix<numRequests; ++ix ){
+                    requesters[ix].setTransport( &correlator );
+                    requesters[ix].start();
+                }
+                
+                // Make sure we got all the responses and that they were all
+                // what we expected.
+                for( unsigned int ix=0; ix<numRequests; ++ix ){
+                    requesters[ix].join();
+                    CPPUNIT_ASSERT( requesters[ix].resp != NULL );
+                    CPPUNIT_ASSERT( requesters[ix].cmd.getCommandId() == requesters[ix].resp->getCorrelationId() );
+                }
+
+                concurrent::Thread::sleep( 25 );
+                synchronized( &listener.mutex )
+                {
+                    unsigned int count = 0;
+
+                    while( listener.commands.size() != numRequests )
+                    {
+                        listener.mutex.wait( 45 );
+
+                        ++count;
+
+                        if( count == numRequests ) {
+                            break;
+                        }
+                    }
+                }
+
+                // Since our transport relays our original command back at us as a
+                // non-response message, check to make sure we received it and that
+                // it is the original command.
+                CPPUNIT_ASSERT( listener.commands.size() == numRequests );                
+                CPPUNIT_ASSERT( listener.exCount == 0 );
+                
+                correlator.close();
+            }
+            AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+            AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+        }
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_COMMANDS_RESPONSECORRELATORTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapRegistrarTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapRegistrarTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapRegistrarTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapRegistrarTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,3 @@
+#include "TransportFactoryMapRegistrarTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::TransportFactoryMapRegistrarTest );

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapRegistrarTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapRegistrarTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapRegistrarTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapRegistrarTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,43 @@
+#ifndef ACTIVEMQ_TRANSPORT_CONNECTORFACTORYMAPREGISTRARTEST_H_
+#define ACTIVEMQ_TRANSPORT_CONNECTORFACTORYMAPREGISTRARTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/transport/TransportFactoryMap.h>
+#include <activemq/transport/TransportFactoryMapRegistrar.h>
+
+namespace activemq{
+namespace transport{
+	
+	class TransportFactoryMapRegistrarTest : public CppUnit::TestFixture {
+		
+	  CPPUNIT_TEST_SUITE( TransportFactoryMapRegistrarTest );
+	  CPPUNIT_TEST( test );
+	  CPPUNIT_TEST_SUITE_END();
+	  
+	public:
+	
+		class TestTransportFactory : public TransportFactory
+		{
+		public:
+		
+		   virtual Transport* createTransport(
+		      const activemq::util::Properties& properties ) { return NULL; };
+		};
+		
+		void test(){
+			
+			{
+				TransportFactoryMapRegistrar registrar("Test", new TestTransportFactory());
+			
+				CPPUNIT_ASSERT( TransportFactoryMap::getInstance().lookup("Test") != NULL);
+			}
+			
+			CPPUNIT_ASSERT( TransportFactoryMap::getInstance().lookup( "Test" ) == NULL );
+		}
+	};
+	
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_CONNECTORFACTORYMAPREGISTRARTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,4 @@
+#include "TransportFactoryMapTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::TransportFactoryMapTest );
+

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/TransportFactoryMapTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,60 @@
+#ifndef ACTIVEMQ_TRANSPORT_TRANSPORTFACTORYMAPTEST_H_
+#define ACTIVEMQ_TRANSPORT_TRANSPORTFACTORYMAPTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/transport/TransportFactoryMap.h>
+#include <activemq/transport/TransportFactory.h>
+
+namespace activemq{
+namespace transport{
+	
+	class TransportFactoryMapTest : public CppUnit::TestFixture {
+		
+	  CPPUNIT_TEST_SUITE( TransportFactoryMapTest );
+	  CPPUNIT_TEST( test );
+	  CPPUNIT_TEST_SUITE_END();	  
+		
+	public:
+	
+		class TestTransportFactory : public TransportFactory
+		{
+		public:
+		
+		   virtual Transport* createTransport(
+		      const activemq::util::Properties& properties) { return NULL; };
+		};
+		
+		void test(){
+			
+			TransportFactoryMap& factMap = 
+                TransportFactoryMap::getInstance();
+			TestTransportFactory testFactory;
+			
+			factMap.registerTransportFactory( "test", &testFactory );
+			
+			CPPUNIT_ASSERT( factMap.lookup( "test" ) == &testFactory );
+			
+			std::vector<std::string> names;
+			CPPUNIT_ASSERT( factMap.getFactoryNames( names ) >= 1 );
+			
+            bool found = false;
+            for( unsigned int i = 0; i < names.size(); ++i )
+            {
+                if( names[i] == "test" )
+                {
+                    found = true;
+                    break;
+                }
+            }
+			CPPUNIT_ASSERT( found );
+			
+			factMap.unregisterTransportFactory( "test" );
+			CPPUNIT_ASSERT( factMap.lookup( "test" ) == NULL );			
+		}
+	};
+	
+}}
+
+#endif /*ACTIVEMQ_TRANSPORT_TRANSPORTFACTORYMAPTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/BooleanTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/BooleanTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/BooleanTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/BooleanTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,3 @@
+#include "BooleanTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::BooleanTest );

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/BooleanTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/BooleanTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/BooleanTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/BooleanTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,47 @@
+#ifndef _ACTIVEMQ_UTIL_BOOLEANTEST_H_
+#define _ACTIVEMQ_UTIL_BOOLEANTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/util/Boolean.h>
+
+namespace activemq{
+namespace util{
+
+    class BooleanTest : public CppUnit::TestFixture
+    {
+        CPPUNIT_TEST_SUITE( BooleanTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+    	BooleanTest() {}
+    	virtual ~BooleanTest() {}
+
+        virtual void test(void)
+        {
+            bool x = Boolean::parseBoolean("false");
+            bool y = Boolean::parseBoolean("true");
+            bool z = Boolean::parseBoolean("false");
+            
+            CPPUNIT_ASSERT( x == false );
+            CPPUNIT_ASSERT( y == true );
+            CPPUNIT_ASSERT( z == false );
+            
+            std::string x1 = Boolean::toString( x );
+            std::string y1 = Boolean::toString( y );
+            std::string z1 = Boolean::toString( z );
+
+            CPPUNIT_ASSERT( x1 == "false" );
+            CPPUNIT_ASSERT( y1 == "true" );
+            CPPUNIT_ASSERT( z1 == "false" );
+
+        }
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_BOOLEANTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/GuidTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/GuidTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/GuidTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/GuidTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,3 @@
+#include "GuidTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::GuidTest );

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/GuidTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/GuidTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/GuidTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/GuidTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,78 @@
+#ifndef _ACTIVEMQ_UTIL_GUIDTEST_H_
+#define _ACTIVEMQ_UTIL_GUIDTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/util/Guid.h>
+
+namespace activemq{
+namespace util{
+
+   class GuidTest : public CppUnit::TestFixture 
+   {
+     CPPUNIT_TEST_SUITE( GuidTest );
+     CPPUNIT_TEST( test );
+     CPPUNIT_TEST_SUITE_END();
+
+   public:
+   
+   	virtual ~GuidTest() {}
+   
+      void test(void)
+      {
+         util::Guid guid; 
+   
+         guid.createGUID();
+         
+         CPPUNIT_ASSERT( guid.toString() == (std::string)guid );
+
+         Guid copy = guid;
+
+         CPPUNIT_ASSERT( guid == copy );
+         CPPUNIT_ASSERT( !(guid < copy) );
+         CPPUNIT_ASSERT( guid <= copy );
+         CPPUNIT_ASSERT( !(guid > copy) );
+         CPPUNIT_ASSERT( guid >= copy );
+
+         std::string less = "0f2bd21c-9fee-4067-d739-c4d84a5d7f62";
+         std::string more = "1f2bd21c-9fee-4067-d739-c4d84a5d7f62";
+
+         CPPUNIT_ASSERT( less < more );
+         CPPUNIT_ASSERT( less <= more );
+         CPPUNIT_ASSERT( !(less > more) );
+         CPPUNIT_ASSERT( !(less >= more) );
+
+         less = more;
+         
+         CPPUNIT_ASSERT( less == more );
+   
+         const unsigned char* bytes = guid.toBytes();
+
+         Guid bytesGUID;
+         bytesGUID.fromBytes(bytes);
+
+         CPPUNIT_ASSERT( guid == bytesGUID );
+
+         delete bytes;
+
+         Guid bytesGUID2;
+         bytesGUID2.fromBytes((const unsigned char*)guid);
+         
+         CPPUNIT_ASSERT( guid == bytesGUID2 );
+   
+         Guid stringGUID(guid.toString());
+   
+         CPPUNIT_ASSERT( stringGUID == guid );
+
+         Guid stringGUID2(guid.toString().c_str());
+   
+         CPPUNIT_ASSERT( stringGUID2 == guid );
+         CPPUNIT_ASSERT( !(stringGUID2 != guid) );
+
+      }
+   };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_GUIDTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/IntegerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/IntegerTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/IntegerTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/IntegerTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,4 @@
+#include "IntegerTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::IntegerTest );
+

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/IntegerTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/IntegerTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/IntegerTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/IntegerTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,47 @@
+#ifndef INTEGERTEST_H_
+#define INTEGERTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/util/Integer.h>
+
+namespace activemq{
+namespace util{
+
+    class IntegerTest : public CppUnit::TestFixture
+    {
+        CPPUNIT_TEST_SUITE( IntegerTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+    	IntegerTest(void) {}
+    	virtual ~IntegerTest(void) {}
+
+        virtual void test(void)
+        {
+            int x = Integer::parseInt("12");
+            int y = Integer::parseInt("12.1");
+            int z = Integer::parseInt("42 24");
+            
+            CPPUNIT_ASSERT( x == 12 );
+            CPPUNIT_ASSERT( y == 12 );
+            CPPUNIT_ASSERT( z == 42 );
+            
+            std::string x1 = Integer::toString( x );
+            std::string y1 = Integer::toString( y );
+            std::string z1 = Integer::toString( z );
+
+            CPPUNIT_ASSERT( x1 == "12" );
+            CPPUNIT_ASSERT( y1 == "12" );
+            CPPUNIT_ASSERT( z1 == "42" );
+
+        }
+
+    };
+
+}}
+
+#endif /*INTEGERTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/LongTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/LongTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/LongTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/LongTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,3 @@
+#include "LongTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::LongTest );

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/LongTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/LongTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/LongTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/LongTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,47 @@
+#ifndef _ACTIVEMQ_UTIL_LONGTEST_H_
+#define _ACTIVEMQ_UTIL_LONGTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/util/Long.h>
+
+namespace activemq{
+namespace util{
+
+    class LongTest : public CppUnit::TestFixture
+    {
+        CPPUNIT_TEST_SUITE( LongTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+    	LongTest() {}
+    	virtual ~LongTest() {}
+
+        virtual void test(void)
+        {
+            long x = Long::parseLong("12");
+            long y = Long::parseLong("12.1");
+            long z = Long::parseLong("42 24");
+            
+            CPPUNIT_ASSERT( x == 12 );
+            CPPUNIT_ASSERT( y == 12 );
+            CPPUNIT_ASSERT( z == 42 );
+            
+            std::string x1 = Long::toString( x );
+            std::string y1 = Long::toString( y );
+            std::string z1 = Long::toString( z );
+
+            CPPUNIT_ASSERT( x1 == "12" );
+            CPPUNIT_ASSERT( y1 == "12" );
+            CPPUNIT_ASSERT( z1 == "42" );
+
+        }
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_LONGTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/QueueTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/QueueTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/QueueTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/QueueTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,3 @@
+#include "QueueTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::QueueTest );

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/QueueTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/QueueTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/QueueTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/QueueTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,50 @@
+#ifndef _ACTIVEMQ_UTIL_QUEUETEST_H_
+#define _ACTIVEMQ_UTIL_QUEUETEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/util/Queue.h>
+
+namespace activemq{
+namespace util{
+
+   class QueueTest : public CppUnit::TestFixture {
+
+     CPPUNIT_TEST_SUITE( QueueTest );
+     CPPUNIT_TEST( test );
+     CPPUNIT_TEST_SUITE_END();
+
+   public:
+
+   	virtual ~QueueTest() {}
+    
+      void test()
+      {
+         Queue<char> q;
+         
+         CPPUNIT_ASSERT( q.empty() == true );
+         CPPUNIT_ASSERT( q.size() == 0 );
+
+         q.push('a');
+    
+         CPPUNIT_ASSERT( q.front() == 'a' );
+         
+         q.pop();
+         
+         CPPUNIT_ASSERT( q.empty() == true );
+         
+         q.push('b');
+         q.push('c');
+         
+         CPPUNIT_ASSERT( q.size() == 2 );
+         
+         CPPUNIT_ASSERT( q.front() == 'b' );
+         CPPUNIT_ASSERT( q.back() == 'c' );
+
+      }
+   };
+    
+}}
+
+#endif /*_ACTIVEMQ_UTIL_QUEUETEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,3 @@
+#include "StringTokenizerTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::StringTokenizerTest );

Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.h?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.h Mon Jul  3 04:51:36 2006
@@ -0,0 +1,99 @@
+#ifndef _ACTIVEMQ_UTIL_STRINGTOKENIZERTEST_H_
+#define _ACTIVEMQ_UTIL_STRINGTOKENIZERTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/util/StringTokenizer.h>
+
+namespace activemq{
+namespace util{
+
+   class StringTokenizerTest : public CppUnit::TestFixture 
+   {
+     CPPUNIT_TEST_SUITE( StringTokenizerTest );
+     CPPUNIT_TEST( test );
+     CPPUNIT_TEST_SUITE_END();
+   public:
+
+   	virtual ~StringTokenizerTest() {}
+
+      void test()
+      {
+         StringTokenizer tokenizer("stomp://127.0.0.1:23232", "://");
+         CPPUNIT_ASSERT( tokenizer.countTokens() == 3 );
+         CPPUNIT_ASSERT( tokenizer.nextToken() == "stomp" );
+         CPPUNIT_ASSERT( tokenizer.nextToken() == "127.0.0.1" );
+         CPPUNIT_ASSERT( tokenizer.nextToken() == "23232" );
+
+         StringTokenizer tokenizer1("::://stomp://127.0.0.1:23232:", ":/");
+         CPPUNIT_ASSERT( tokenizer1.countTokens() == 3 );
+         CPPUNIT_ASSERT( tokenizer1.nextToken() == "stomp" );
+         CPPUNIT_ASSERT( tokenizer1.nextToken() == "127.0.0.1" );
+         CPPUNIT_ASSERT( tokenizer1.nextToken() == "23232" );
+
+         StringTokenizer tokenizer2("test");
+         CPPUNIT_ASSERT( tokenizer2.countTokens() == 1 );
+         CPPUNIT_ASSERT( tokenizer2.hasMoreTokens() == true );
+         CPPUNIT_ASSERT( tokenizer2.nextToken() == "test" );
+         CPPUNIT_ASSERT( tokenizer2.hasMoreTokens() == false );
+
+         StringTokenizer tokenizer3(":", ":");
+         CPPUNIT_ASSERT( tokenizer3.countTokens() == 0 );
+         CPPUNIT_ASSERT( tokenizer3.hasMoreTokens() == false );
+         CPPUNIT_ASSERT( tokenizer3.nextToken(" ") == ":" );
+
+         try
+         {
+            tokenizer3.nextToken();
+
+            CPPUNIT_ASSERT( false );
+         }
+         catch(exceptions::NoSuchElementException ex)
+         {
+            CPPUNIT_ASSERT( true );
+         }
+
+         StringTokenizer tokenizer4("the quick brown fox");
+         CPPUNIT_ASSERT( tokenizer4.countTokens() == 4 );
+         CPPUNIT_ASSERT( tokenizer4.hasMoreTokens() == true );
+         CPPUNIT_ASSERT( tokenizer4.nextToken() == "the" );
+         CPPUNIT_ASSERT( tokenizer4.nextToken() == "quick" );
+         CPPUNIT_ASSERT( tokenizer4.nextToken() == "brown" );
+         CPPUNIT_ASSERT( tokenizer4.nextToken() == "fox" );
+         CPPUNIT_ASSERT( tokenizer4.countTokens() == 0 );
+         CPPUNIT_ASSERT( tokenizer4.hasMoreTokens() == false );
+
+         StringTokenizer tokenizer5("the:quick:brown:fox", ":", true);
+         CPPUNIT_ASSERT( tokenizer5.countTokens() == 7 );
+         CPPUNIT_ASSERT( tokenizer5.hasMoreTokens() == true );
+         CPPUNIT_ASSERT( tokenizer5.nextToken() == "the" );
+         CPPUNIT_ASSERT( tokenizer5.nextToken() == ":" );
+         CPPUNIT_ASSERT( tokenizer5.nextToken() == "quick" );
+         CPPUNIT_ASSERT( tokenizer5.nextToken() == ":" );
+         CPPUNIT_ASSERT( tokenizer5.nextToken() == "brown" );
+         CPPUNIT_ASSERT( tokenizer5.nextToken() == ":" );
+         CPPUNIT_ASSERT( tokenizer5.nextToken() == "fox" );
+         CPPUNIT_ASSERT( tokenizer5.countTokens() == 0 );
+         CPPUNIT_ASSERT( tokenizer5.hasMoreTokens() == false );
+
+         std::vector<std::string> myArray;
+         StringTokenizer tokenizer6("the:quick:brown:fox", ":");
+         CPPUNIT_ASSERT( tokenizer6.countTokens() == 4 );
+         CPPUNIT_ASSERT( tokenizer6.toArray(myArray) == 4 );
+         CPPUNIT_ASSERT( tokenizer6.countTokens() == 0 );
+         tokenizer6.reset();
+         CPPUNIT_ASSERT( tokenizer6.countTokens() == 4 );
+         tokenizer6.reset("the:quick:brown:fox", "$");
+         CPPUNIT_ASSERT( tokenizer6.countTokens() == 1 );
+         tokenizer6.reset("this$is$a$test");
+         CPPUNIT_ASSERT( tokenizer6.countTokens() == 4 );
+         tokenizer6.reset("this$is$a$test", "$", true);
+         CPPUNIT_ASSERT( tokenizer6.countTokens() == 7 );
+
+      }
+   };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_STRINGTOKENIZERTEST_H_*/

Added: incubator/activemq/trunk/activemq-cpp/src/test/main.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/main.cpp?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/main.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/main.cpp Mon Jul  3 04:51:36 2006
@@ -0,0 +1,19 @@
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/TestResult.h>
+
+int main( int argc, char **argv)
+{
+    CppUnit::TextUi::TestRunner runner;
+    CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
+    runner.addTest( registry.makeTest() );
+
+    // Shows a message as each test starts
+    CppUnit::BriefTestProgressListener listener;
+    runner.eventManager().addListener( &listener );
+    
+    bool wasSuccessful = runner.run( "", false );
+    return !wasSuccessful;
+}
+

Added: incubator/activemq/trunk/activemq-cpp/todo.txt
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/todo.txt?rev=418749&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/todo.txt (added)
+++ incubator/activemq/trunk/activemq-cpp/todo.txt Mon Jul  3 04:51:36 2006
@@ -0,0 +1,36 @@
+Client Side:
+
+* Work out platform independent build system
+* Complete Logging API
+* Add Destination URL like parameter processing
+* investigate the 999 (1000) messages bug in the broker
+
+
+* integration test against real AMQ broker                  (DONE)
+* finish unit testing of core api                           (DONE)
+* refactoring of core API                                   (DONE)
+* Resolve static initialization when used as a library.     (DONE)
+* Add Message Cloning to the Commands tests.                (DONE)
+* enforce connected state in stomp connector                (DONE)
+* Add setting username & password to connect command		(DONE)
+* Dummy Transport that acts like a broker 					(DONE)
+* Update Session Manager to use Transport not Connector  	(DONE)
+* Add Transport Factory Lookup Method 						(DONE)
+* Connector Interfaces Cleanup                          	(DONE)
+
+Server Side:
+
+* Implement Connected as a response 						(DONE)
+* Implement use of JMSType in all messages 					(DONE)
+* Add Content Length to all outgoing messages 				(DONE)
+
+Nice to Haves:
+
+* Add Connection Id support to Stomp Transport on Broker
+* Add Consumer Id support to Stomp Transport on Broker
+* implement selector algorithm - always pass null selector to broker,
+  current implementation is limited to using the selector on the
+  first consumer that is subscribed to a Topic.
+* Add Durable Subscriptions to Stomp Connector.             (DONE)
+
+