activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r517831 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/core/ main/cms/ test-integration/integration/ test-integration/integration/connector/openwire/ test-integration/integration/connector/stomp/
Date Tue, 13 Mar 2007 19:49:33 GMT
Author: tabish
Date: Tue Mar 13 12:49:32 2007
New Revision: 517831

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

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionFactory.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireExpirationTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleRollbackTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/ExpirationTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleRollbackTest.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp?view=diff&rev=517831&r1=517830&r2=517831
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
Tue Mar 13 12:49:32 2007
@@ -39,41 +39,64 @@
 using namespace activemq::transport;
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQConnectionFactory::ActiveMQConnectionFactory(void)
+ActiveMQConnectionFactory::ActiveMQConnectionFactory()
 {
     brokerURL = "tcp://localhost:61616";
-    
+
     this->username = "";
     this->password = "";
-    this->clientId = "";
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 ActiveMQConnectionFactory::ActiveMQConnectionFactory(
     const std::string& url,
     const std::string& username,
-    const std::string& password,
-    const std::string& clientId )
+    const std::string& password )
 {
     brokerURL = url;
 
     this->username = username;
     this->password = password;
-    this->clientId = clientId;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-cms::Connection* ActiveMQConnectionFactory::createConnection(void) 
-throw ( cms::CMSException )
+cms::Connection* ActiveMQConnectionFactory::createConnection()
+    throw ( cms::CMSException )
+{
+    return createConnection( brokerURL, username, password, Guid::createGUIDString() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms::Connection* ActiveMQConnectionFactory::createConnection(
+    const std::string& username,
+    const std::string& password )
+        throw ( cms::CMSException )
 {
-    return createConnection( username, password, clientId );
+    this->setUsername( username );
+    this->setPassword( password );
+
+    return createConnection( brokerURL, username, password, Guid::createGUIDString() );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 cms::Connection* ActiveMQConnectionFactory::createConnection(
     const std::string& username,
     const std::string& password,
-    const std::string& clientId ) 
+    const std::string& clientId )
+        throw ( cms::CMSException )
+{
+    this->setUsername( username );
+    this->setPassword( password );
+
+    return createConnection( brokerURL, username, password, clientId );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms::Connection* ActiveMQConnectionFactory::createConnection(
+    const std::string& url,
+    const std::string& username,
+    const std::string& password,
+    const std::string& clientId )
        throw ( cms::CMSException )
 {
     // Declared here so that they can be deleted in the catch block
@@ -82,65 +105,59 @@
     Connector* connector = NULL;
     ActiveMQConnectionData* connectionData = NULL;
     ActiveMQConnection* connection = NULL;
-    
-    this->username = username;
-    this->password = password;
-    this->clientId = clientId;
+    std::string clientIdLocal = clientId;
 
     try
     {
         properties = new SimpleProperties;
 
         // if no Client Id specified, create one
-        if( this->clientId == "" )
+        if( clientIdLocal == "" )
         {
-            this->clientId = Guid::createGUIDString();
+            clientIdLocal = Guid::createGUIDString();
         }
 
         // Store login data in the properties
-        properties->setProperty( 
+        properties->setProperty(
             ActiveMQConstants::toString(
-                ActiveMQConstants::PARAM_USERNAME ), 
-            this->username );
-        properties->setProperty( 
+                ActiveMQConstants::PARAM_USERNAME ), username );
+        properties->setProperty(
             ActiveMQConstants::toString(
-                ActiveMQConstants::PARAM_PASSWORD ), 
-            this->password );
-        properties->setProperty( 
+                ActiveMQConstants::PARAM_PASSWORD ), password );
+        properties->setProperty(
             ActiveMQConstants::toString(
-                ActiveMQConstants::PARAM_CLIENTID ), 
-            this->clientId );
+                ActiveMQConstants::PARAM_CLIENTID ), clientIdLocal );
 
         // Parse out the properties from the URI
-        parseURL( brokerURL, *properties );
+        parseURL( url, *properties );
 
         // Create the Transport that the Connector will use.
-        string factoryName = 
+        string factoryName =
             properties->getProperty( "transport", "tcp" );
-        TransportFactory* factory = 
+        TransportFactory* factory =
             TransportFactoryMap::getInstance().lookup( factoryName );
         if( factory == NULL ){
-            throw ActiveMQException( 
-                __FILE__, __LINE__, 
+            throw ActiveMQException(
+                __FILE__, __LINE__,
                 "ActiveMQConnectionFactory::createConnection - "
                 "unknown transport factory" );
         }
-        
+
         // Create the transport.
         transport = factory->createTransport( *properties );
         if( transport == NULL ){
-            throw ActiveMQException( 
-                __FILE__, __LINE__, 
+            throw ActiveMQException(
+                __FILE__, __LINE__,
                 "ActiveMQConnectionFactory::createConnection - "
                 "failed creating new Transport" );
         }
 
         // What wire format are we using, defaults to Stomp
-        std::string wireFormat = 
+        std::string wireFormat =
             properties->getProperty( "wireFormat", "stomp" );
 
         // Now try and find a factory to create the Connector
-        ConnectorFactory* connectorfactory = 
+        ConnectorFactory* connectorfactory =
             ConnectorFactoryMap::getInstance()->lookup( wireFormat );
 
         if( connectorfactory == NULL )
@@ -161,7 +178,7 @@
                 "ActiveMQConnectionFactory::createConnection - "
                 "Failed to Create the Connector" );
         }
-        
+
         // Start the Connector
         connector->start();
 
@@ -171,7 +188,7 @@
 
         // Create and Return the new connection object.
         connection = new ActiveMQConnection( connectionData );
-        
+
         return connection;
     }
     catch( exceptions::ActiveMQException& ex )
@@ -182,13 +199,13 @@
         delete connector;
         delete transport;
         delete properties;
-        
+
         throw ex;
     }
     catch( ... )
     {
-        exceptions::ActiveMQException ex( 
-            __FILE__, __LINE__, 
+        exceptions::ActiveMQException ex(
+            __FILE__, __LINE__,
             "ActiveMQConnectionFactory::create - "
             "caught unknown exception" );
 
@@ -202,28 +219,28 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConnectionFactory::parseURL( const std::string& URI, 
+void ActiveMQConnectionFactory::parseURL( const std::string& URI,
                                           Properties& properties )
     throw ( exceptions::IllegalArgumentException )
 {
     try
     {
-        StringTokenizer tokenizer(URI, ":/");
-    
+        StringTokenizer tokenizer( URI, ":/" );
+
         std::vector<std::string> tokens;
-    
+
         // Require that there be three tokens at the least, these are
         // transport, url, port.
         if( tokenizer.countTokens() < 3 )
         {
             throw exceptions::IllegalArgumentException(
                 __FILE__, __LINE__,
-                (string("ActiveMQConnectionFactory::parseURL - "
-                        "Marlformed URI: ") + URI).c_str());
+                (string( "ActiveMQConnectionFactory::parseURL - "
+                         "Marlformed URI: ") + URI).c_str() );
         }
 
         // First element should be the Transport Type, following that is the
-        // URL and any params.  
+        // URL and any params.
         properties.setProperty( "transport", tokenizer.nextToken() );
 
         // Parse URL and Port as one item, optional params follow the ?
@@ -232,12 +249,12 @@
         properties.setProperty( "uri", tokenizer.nextToken("&?").substr(3) );
 
         // Now get all the optional parameters and store them as properties
-        int count = tokenizer.toArray(tokens);
-        
+        int count = tokenizer.toArray( tokens );
+
         for( int i = 0; i < count; ++i )
         {
             tokenizer.reset( tokens[i], "=" );
-    
+
             if( tokenizer.countTokens() != 2 )
             {
                 throw exceptions::IllegalArgumentException(
@@ -245,12 +262,12 @@
                     ( string( "ActiveMQConnectionFactory::parseURL - "
                               "Marlformed Parameter = " ) + tokens[i] ).c_str() );
             }
-            
+
             // Get them in order, passing both as nextToken calls in the
             // set Property can cause reversed order.
             string key   = tokenizer.nextToken();
             string value = tokenizer.nextToken();
-    
+
             // Store this param as a property
             properties.setProperty( key, value );
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h?view=diff&rev=517831&r1=517830&r2=517831
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h
Tue Mar 13 12:49:32 2007
@@ -30,62 +30,75 @@
     class ActiveMQConnectionFactory : public cms::ConnectionFactory
     {
     private:
-   
+
         // The user name this factory will use to connect
         std::string username;
-      
+
         // The password this factory will use to connect
         std::string password;
-      
-        // The client id to assign to the connection created
-        std::string clientId;
-      
+
         // The URL of the Broker, the default is:
         // "tcp://localhost:61616"
         std::string brokerURL;
 
     public:
 
-   	    ActiveMQConnectionFactory(void);
+   	    ActiveMQConnectionFactory();
 
         /**
          * Constructor
          * @param url the URL of the Broker we are connecting to.
          * @param username to authenticate with, defaults to ""
          * @param password to authenticate with, defaults to ""
-         * @param clientId to assign to connection, defaults to ""
          */
         ActiveMQConnectionFactory( const std::string& url,
                                    const std::string& username = "",
-                                   const std::string& password = "",
-                                   const std::string& clientId = "" );
+                                   const std::string& password = "" );
 
-   	    virtual ~ActiveMQConnectionFactory(void) {}
+   	    virtual ~ActiveMQConnectionFactory() {}
 
         /**
-         * Creates a connection with the default user identity. The 
-         * connection is created in stopped mode. No messages will be 
-         * delivered until the Connection.start method is explicitly 
-         * called. 
+         * Creates a connection with the default user identity. The
+         * connection is created in stopped mode. No messages will be
+         * delivered until the Connection.start method is explicitly
+         * called.
          * @returns a Connection Pointer
          * @throws CMSException
          */
-        virtual cms::Connection* createConnection(void) throw ( cms::CMSException );
+        virtual cms::Connection* createConnection()
+            throw ( cms::CMSException );
 
         /**
-         * Creates a connection with the specified user identity. The 
-         * connection is created in stopped mode. No messages will be 
-         * delivered until the Connection.start method is explicitly called.
-         * @param username to authenticate with, defaults to ""
-         * @param password to authenticate with, defaults to ""
-         * @param clientId to assign to connection, defaults to ""
-         * @throw CMSException.
+         * Creates a connection with the specified user identity. The
+         * connection is created in stopped mode. No messages will be
+         * delivered until the Connection.start method is explicitly
+         * called.
+         * @param username to authenticate with, resets internal to new value
+         * @param password to authenticate with, resets internal to new value
+         * @returns a Connection Pointer
+         * @throws CMSException
+         */
+        virtual cms::Connection* createConnection( const std::string& username,
+                                                   const std::string& password )
+            throw ( cms::CMSException );
+
+        /**
+         * Creates a connection with the specified user identity. The
+         * connection is created in stopped mode. No messages will be
+         * delivered until the Connection.start method is explicitly
+         * called.
+         * @param username to authenticate with, resets internal to new value
+         * @param password to authenticate with, resets internal to new value
+         * @param clientId to assign to connection if "" then a random cleint
+         *        Id is created for this connection.
+         * @returns a Connection Pointer
+         * @throws CMSException
          */
         virtual cms::Connection* createConnection( const std::string& username,
                                                    const std::string& password,
-                                                   const std::string& clientId = "" )
+                                                   const std::string& clientId )
             throw ( cms::CMSException );
-                                       
+
         /**
          * Sets the username that should be used when creating a new connection
          * @param username string
@@ -93,16 +106,16 @@
         virtual void setUsername( const std::string& username ){
             this->username = username;
         }
-      
+
         /**
          * Gets the username that this factory will use when creating a new
          * connection instance.
          * @return username string, "" for default credentials
          */
-        virtual const std::string& getUsername(void) const {
+        virtual const std::string& getUsername() const {
             return username;
         }
-      
+
         /**
          * Sets the password that should be used when creating a new connection
          * @param password string
@@ -110,52 +123,52 @@
         virtual void setPassword( const std::string& password ){
             this->password = password;
         }
-      
+
         /**
          * Gets the password that this factory will use when creating a new
          * connection instance.
          * @return password string, "" for default credentials
          */
-        virtual const std::string& getPassword(void) const {
+        virtual const std::string& getPassword() const {
             return password;
         }
 
         /**
-         * Sets the Broker URL that should be used when creating a new 
+         * Sets the Broker URL that should be used when creating a new
          * connection instance
          * @param brokerURL string
          */
         virtual void setBrokerURL( const std::string& brokerURL ){
             this->brokerURL = brokerURL;
         }
-      
+
         /**
          * Gets the Broker URL that this factory will use when creating a new
          * connection instance.
          * @return brokerURL string
          */
-        virtual const std::string& getBrokerURL(void) const {
+        virtual const std::string& getBrokerURL() const {
             return brokerURL;
         }
 
+    public:
+
         /**
-         * Sets the Client Id that should be used when creating a new 
-         * connection instance
-         * @param clientId string
-         */
-        virtual void setClientId( const std::string& clientId ){
-            this->clientId = clientId;
-        }
-      
-        /**
-         * Gets the Client Id that this factory will use when creating a new
-         * connection instance.
-         * @return clientId string
+         * Creates a connection with the specified user identity. The
+         * connection is created in stopped mode. No messages will be
+         * delivered until the Connection.start method is explicitly called.
+         * @param url the URL of the Broker we are connecting to.
+         * @param username to authenticate with
+         * @param password to authenticate with
+         * @param clientId to assign to connection, defaults to ""
+         * @throw CMSException.
          */
-        virtual const std::string& getClientId(void) const {
-            return clientId;
-        }
-      
+        static cms::Connection* createConnection( const std::string& url,
+                                                  const std::string& username,
+                                                  const std::string& password,
+                                                  const std::string& clientId = "" )
+            throw ( cms::CMSException );
+
     protected:
 
         /**
@@ -165,10 +178,10 @@
          * @param properties a Properties object to set the parsed values in
          * @throws IllegalArgumentException if the passed URI is invalid
          */
-        virtual void parseURL( const std::string& URI, 
-                               util::Properties& properties )
+        static void parseURL( const std::string& URI,
+                              util::Properties& properties )
             throw ( exceptions::IllegalArgumentException );
-         
+
     };
 
 }}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionFactory.h?view=diff&rev=517831&r1=517830&r2=517831
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionFactory.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionFactory.h Tue Mar 13 12:49:32
2007
@@ -35,29 +35,45 @@
         virtual ~ConnectionFactory() {}
 
         /**
-         * Creates a connection with the default user identity. The 
-         * connection is created in stopped mode. No messages will be 
-         * delivered until the Connection.start method is explicitly 
-         * called. 
+         * Creates a connection with the default user identity. The
+         * connection is created in stopped mode. No messages will be
+         * delivered until the Connection.start method is explicitly
+         * called.
          * @return Pointer to a connection object, caller owns the pointer
          * @throws CMSException
          */
         virtual Connection* createConnection() throw ( CMSException ) = 0;
 
         /**
-         * Creates a connection with the specified user identity. The 
-         * connection is created in stopped mode. No messages will be 
-         * delivered until the Connection.start method is explicitly called.
-         * @param username - name to login with
-         * @param password - password to authenticate with
-         * @param clientId - User provided Client Id 
-         * @return Pointer to a connection object, caller owns the pointer
-         * @throw CMSException.
+         * Creates a connection with the default specified identity. The
+         * connection is created in stopped mode. No messages will be
+         * delivered until the Connection.start method is explicitly
+         * called.
+         * @param username to authenticate with, resets internal to new value
+         * @param password to authenticate with, resets internal to new value
+         * @returns a Connection Pointer
+         * @throws CMSException
+         */
+        virtual cms::Connection* createConnection( const std::string& username,
+                                                   const std::string& password )
+            throw ( cms::CMSException ) = 0;
+
+        /**
+         * Creates a connection with the specified user identity. The
+         * connection is created in stopped mode. No messages will be
+         * delivered until the Connection.start method is explicitly
+         * called.
+         * @param username to authenticate with, resets internal to new value
+         * @param password to authenticate with, resets internal to new value
+         * @param clientId to assign to connection if "" then a random cleint
+         *        Id is created for this connection.
+         * @returns a Connection Pointer
+         * @throws CMSException
          */
-        virtual Connection* createConnection( const std::string& username,
-                                              const std::string& password,
-                                              const std::string& clientId) 
-                                                  throw ( CMSException ) = 0;
+        virtual cms::Connection* createConnection( const std::string& username,
+                                                   const std::string& password,
+                                                   const std::string& clientId )
+            throw ( cms::CMSException ) = 0;
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp?view=diff&rev=517831&r1=517830&r2=517831
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.cpp
Tue Mar 13 12:49:32 2007
@@ -41,10 +41,8 @@
 
 using namespace integration;
 
-TestSupport::TestSupport( const string& brokerUrl, cms::Session::AcknowledgeMode ackMode
 )
-: 
-    connectionFactory( NULL ),
-    connection( NULL ),
+TestSupport::TestSupport( const string& brokerUrl, cms::Session::AcknowledgeMode ackMode
)
+ :  connection( NULL ),
     session( NULL )
 {
     this->ackMode = ackMode;
@@ -63,37 +61,32 @@
             session->close();
             delete session;
         }
-        
+
         if( connection != NULL ) {
             connection->close();
             delete connection;
         }
-
-        if( connectionFactory != NULL ) {
-            delete connectionFactory;
-        }
     }
     AMQ_CATCH_NOTHROW( ActiveMQException )
     AMQ_CATCHALL_NOTHROW( )
-    
+
     session = NULL;
     connection = NULL;
-    connectionFactory = NULL;
 }
 
 void TestSupport::initialize(){
     try
     {
         numReceived = 0;
-    
+
         // Now create the connection
-        connection = createDetachedConnection( 
+        connection = createDetachedConnection(
             "", "", Guid().createGUIDString() );
-    
-        // Set ourself as a recipient of Exceptions        
+
+        // Set ourself as a recipient of Exceptions
         connection->setExceptionListener( this );
         connection->start();
-        
+
         // Create a Session
         session = connection->createSession( ackMode );
     }
@@ -108,15 +101,10 @@
 
     try
     {
-    
-        if( connectionFactory == NULL ) {
-            // Create a Factory
-            connectionFactory = new ActiveMQConnectionFactory( brokerUrl );
-        }
-
         // Now create the connection
-        cms::Connection* connection = connectionFactory->createConnection(
-            username, password, clientId );
+        cms::Connection* connection =
+            ActiveMQConnectionFactory::createConnection(
+                brokerUrl, username, password, clientId );
 
         return connection;
     }
@@ -124,12 +112,12 @@
     AMQ_CATCHALL_THROW( ActiveMQException )
 }
 
-void TestSupport::doSleep(void) 
+void TestSupport::doSleep(void)
 {
     Thread::sleep( IntegrationCommon::defaultDelay );
 }
 
-unsigned int TestSupport::produceTextMessages( 
+unsigned int TestSupport::produceTextMessages(
     cms::MessageProducer& producer,
     unsigned int count )
 {
@@ -138,16 +126,16 @@
         // Send some text messages.
         ostringstream stream;
         string text = "this is a test text message: id = ";
-        
-        cms::TextMessage* textMsg = 
+
+        cms::TextMessage* textMsg =
             session->createTextMessage();
 
         unsigned int realCount = 0;
-                     
+
         for( unsigned int ix=0; ix<count; ++ix ){
             stream << text << ix << ends;
-            textMsg->setText( stream.str().c_str() );        
-            stream.str("");  
+            textMsg->setText( stream.str().c_str() );
+            stream.str("");
             producer.send( textMsg );
             doSleep();
             ++realCount;
@@ -158,10 +146,10 @@
         return realCount;
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )    
+    AMQ_CATCHALL_THROW( ActiveMQException )
 }
 
-unsigned int TestSupport::produceBytesMessages( 
+unsigned int TestSupport::produceBytesMessages(
     cms::MessageProducer& producer,
     unsigned int count )
 {
@@ -178,13 +166,13 @@
         buf[6] = 5;
         buf[7] = 6;
 
-        cms::BytesMessage* bytesMsg = 
+        cms::BytesMessage* bytesMsg =
             session->createBytesMessage();
         bytesMsg->setBodyBytes( buf, 10 );
 
         unsigned int realCount = 0;
-        for( unsigned int ix=0; ix<count; ++ix ){                
-            producer.send( bytesMsg ); 
+        for( unsigned int ix=0; ix<count; ++ix ){
+            producer.send( bytesMsg );
             doSleep();
             ++realCount;
         }
@@ -194,7 +182,7 @@
         return realCount;
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )    
+    AMQ_CATCHALL_THROW( ActiveMQException )
 }
 
 void TestSupport::waitForMessages( unsigned int count )
@@ -204,11 +192,11 @@
         synchronized( &mutex )
         {
             int stopAtZero = count + 5;
-            
+
             while( numReceived < count )
             {
                 mutex.wait( 500 );
-                
+
                 if( --stopAtZero == 0 )
                 {
                     break;
@@ -217,7 +205,7 @@
         }
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
-    AMQ_CATCHALL_THROW( ActiveMQException )    
+    AMQ_CATCHALL_THROW( ActiveMQException )
 }
 
 void TestSupport::onException( const cms::CMSException& error )
@@ -234,11 +222,11 @@
             CPPUNIT_ASSERT_MESSAGE(ex.getStackTraceString(), false );
         }
     }
-    
+
     // Got a text message.
-    const cms::TextMessage* txtMsg = 
+    const cms::TextMessage* txtMsg =
         dynamic_cast<const cms::TextMessage*>(message);
-        
+
     if( txtMsg != NULL )
     {
         std::string text = txtMsg->getText();
@@ -254,18 +242,18 @@
         {
             mutex.notifyAll();
         }
-        
+
         return;
     }
-    
+
     // Got a bytes msg.
-    const cms::BytesMessage* bytesMsg = 
+    const cms::BytesMessage* bytesMsg =
         dynamic_cast<const cms::BytesMessage*>(message);
 
     if( bytesMsg != NULL )
     {
         const unsigned char* bytes = bytesMsg->getBodyBytes();
-        
+
         string transcode( (const char*)bytes, bytesMsg->getBodyLength() );
 
         if( IntegrationCommon::debug ) {
@@ -273,14 +261,14 @@
         }
 
         numReceived++;
-        
+
         // Signal that we got one
         synchronized( &mutex )
         {
             mutex.notifyAll();
         }
-        
+
         return;
     }
-    
+
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.h?view=diff&rev=517831&r1=517830&r2=517831
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/TestSupport.h
Tue Mar 13 12:49:32 2007
@@ -32,44 +32,44 @@
     class TestSupport : public cms::ExceptionListener, public cms::MessageListener
     {
     public:
-    
+
     	TestSupport( const std::string& brokerUrl,
                      cms::Session::AcknowledgeMode ackMode = cms::Session::AUTO_ACKNOWLEDGE
);
     	virtual ~TestSupport();
-    
+
         virtual void initialize();
         virtual void close();
-        
+
         virtual activemq::concurrent::Mutex& getMutex() {
             return mutex;
         }
-        
+
         virtual std::string getBrokerUrl() const {
             return brokerUrl;
         }
-        
+
         virtual cms::Connection* getConnection() {
             return connection;
         }
-        
+
         virtual cms::Session* getSession() {
             return session;
         }
-        
+
         virtual unsigned int getNumReceived() const {
             return numReceived;
         }
-        
+
         virtual void setNumReceived( unsigned int numReceived ) {
             this->numReceived = numReceived;
         }
-        
+
         virtual void doSleep();
 
-        virtual unsigned int produceTextMessages( 
+        virtual unsigned int produceTextMessages(
             cms::MessageProducer& producer,
             unsigned int count );
-        virtual unsigned int produceBytesMessages( 
+        virtual unsigned int produceBytesMessages(
             cms::MessageProducer& producer,
             unsigned int count );
 
@@ -84,9 +84,8 @@
             const std::string& clientId );
 
     public:
-        
+
         std::string brokerUrl;
-        cms::ConnectionFactory* connectionFactory;
         cms::Connection* connection;
         cms::Session* session;
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireExpirationTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireExpirationTest.cpp?view=diff&rev=517831&r1=517830&r2=517831
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireExpirationTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireExpirationTest.cpp
Tue Mar 13 12:49:32 2007
@@ -198,14 +198,10 @@
         user="default";
         passwd="";
         sID="lsgID";
-        
-        // Create a ConnectionFactory
-        ActiveMQConnectionFactory* connectionFactory =
-           new ActiveMQConnectionFactory("tcp://localhost:61613?wireFormat=stomp",user,passwd,sID);
 
         // Create a Connection
-        connection = connectionFactory->createConnection();
-        delete connectionFactory;
+        connection = ActiveMQConnectionFactory::createConnection(
+            "tcp://localhost:61613?wireFormat=stomp", user, passwd, sID );
         connection->start();
 
         // Create a Session
@@ -213,7 +209,7 @@
 
         // Create the destination (Topic or Queue)
         string t = topic + "?consumer.retroactive=true";
-        
+
         destination = session->createTopic( t );
 
         consumer = session->createConsumer( destination );
@@ -270,7 +266,7 @@
     }catch (CMSException& e) {}
     connection = NULL;
 }
-    
+
 void OpenwireExpirationTest::testExpired()
 {
     string topic = Guid().createGUID();
@@ -278,14 +274,14 @@
     Thread producerThread( &producer );
     producerThread.start();
     producerThread.join();
-    
+
     Thread::sleep( 100 );
 
     Consumer consumer( topic, 2000 );
     Thread consumerThread( &consumer );
     consumerThread.start();
     consumerThread.join();
-    
+
     Thread::sleep( 100 );
 
     CPPUNIT_ASSERT_EQUAL( 0, consumer.getNumReceived() );
@@ -299,14 +295,14 @@
     Thread producerThread( &producer );
     producerThread.start();
     producerThread.join();
-    
+
     Consumer consumer( topic, 3000 );
     Thread consumerThread( &consumer );
     consumerThread.start();
     consumerThread.join();
 
     Thread::sleep( 50 );
-    
+
     CPPUNIT_ASSERT_EQUAL( 2, consumer.getNumReceived() );
 }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleRollbackTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleRollbackTest.cpp?view=diff&rev=517831&r1=517830&r2=517831
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleRollbackTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/openwire/OpenwireSimpleRollbackTest.cpp
Tue Mar 13 12:49:32 2007
@@ -89,20 +89,19 @@
 
         // Default amount to send and receive
         msgCount = 1;
-    
+
         // Create a Factory
         connectionFactory = new ActiveMQConnectionFactory( url );
 
         // Now create the connection
-        connection = connectionFactory->createConnection(
-            "", "", Guid().createGUIDString() );
-    
-        // Set ourself as a recipient of Exceptions        
+        connection = connectionFactory->createConnection();
+
+        // Set ourself as a recipient of Exceptions
         connection->setExceptionListener( this );
         connection->start();
-        
+
         // Create a Session
-        session = connection->createSession( 
+        session = connection->createSession(
             cms::Session::SESSION_TRANSACTED );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -130,23 +129,23 @@
     {
         // Create CMS Object for Comms
         cms::Topic* topic = session->createTopic(Guid::createGUIDString());
-        cms::MessageConsumer* consumer = 
-            session->createConsumer( topic );            
+        cms::MessageConsumer* consumer =
+            session->createConsumer( topic );
         consumer->setMessageListener( this );
-        cms::MessageProducer* producer = 
+        cms::MessageProducer* producer =
             session->createProducer( topic );
 
-        cms::TextMessage* textMsg = 
+        cms::TextMessage* textMsg =
             session->createTextMessage();
 
         for( size_t ix = 0; ix < msgCount; ++ix )
         {
             ostringstream lcStream;
-            lcStream << "SimpleTest - Message #" << ix << ends;       
    
+            lcStream << "SimpleTest - Message #" << ix << ends;
             textMsg->setText( lcStream.str() );
             producer->send( textMsg );
         }
-        
+
         delete textMsg;
 
         Thread::sleep( 100 );
@@ -158,11 +157,11 @@
         for( size_t ix = 0; ix < msgCount; ++ix )
         {
             ostringstream lcStream;
-            lcStream << "SimpleTest - Message #" << ix << ends;       
    
+            lcStream << "SimpleTest - Message #" << ix << ends;
             textMsg->setText( lcStream.str() );
             producer->send( textMsg );
         }
-        
+
         delete textMsg;
 
         Thread::sleep( 500 );
@@ -189,7 +188,7 @@
             printf( "Shutting Down\n" );
         }
 
-        delete producer;                      
+        delete producer;
         delete consumer;
         delete topic;
     }
@@ -208,48 +207,48 @@
     try
     {
         // Got a text message.
-        const cms::TextMessage* txtMsg = 
+        const cms::TextMessage* txtMsg =
             dynamic_cast<const cms::TextMessage*>(message);
-            
+
         if( txtMsg != NULL )
         {
             if( IntegrationCommon::debug ) {
                 printf("received text msg: %s\n", txtMsg->getText().c_str() );
             }
-    
+
             numReceived++;
-    
+
             // Signal that we got one
             synchronized( &mutex )
             {
                 mutex.notifyAll();
             }
-    
+
             return;
         }
-        
+
         // Got a bytes msg.
-        const cms::BytesMessage* bytesMsg = 
+        const cms::BytesMessage* bytesMsg =
             dynamic_cast<const cms::BytesMessage*>(message);
-    
+
         if( bytesMsg != NULL )
         {
             const unsigned char* bytes = bytesMsg->getBodyBytes();
-            
+
             string transcode( (const char*)bytes, bytesMsg->getBodyLength() );
 
             if( IntegrationCommon::debug ) {
                 printf("Received Bytes Message: %s", transcode.c_str() );
             }
-    
+
             numReceived++;
-            
+
             // Signal that we got one
             synchronized( &mutex )
             {
                 mutex.notifyAll();
             }
-    
+
             return;
         }
     }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/ExpirationTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/ExpirationTest.cpp?view=diff&rev=517831&r1=517830&r2=517831
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/ExpirationTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/ExpirationTest.cpp
Tue Mar 13 12:49:32 2007
@@ -198,14 +198,11 @@
         user="default";
         passwd="";
         sID="lsgID";
-        
-        // Create a ConnectionFactory
-        ActiveMQConnectionFactory* connectionFactory =
-           new ActiveMQConnectionFactory("tcp://localhost:61613?wireFormat=stomp",user,passwd,sID);
 
         // Create a Connection
-        connection = connectionFactory->createConnection();
-        delete connectionFactory;
+        connection = ActiveMQConnectionFactory::createConnection(
+            "tcp://localhost:61613?wireFormat=stomp", user, passwd, sID );
+
         connection->start();
 
         // Create a Session
@@ -213,7 +210,7 @@
 
         // Create the destination (Topic or Queue)
         string t = topic + "?consumer.retroactive=true";
-        
+
         destination = session->createTopic( t );
 
         consumer = session->createConsumer( destination );
@@ -270,7 +267,7 @@
     }catch (CMSException& e) {}
     connection = NULL;
 }
-    
+
 void ExpirationTest::testExpired()
 {
     string topic = Guid().createGUID();
@@ -278,14 +275,14 @@
     Thread producerThread( &producer );
     producerThread.start();
     producerThread.join();
-    
+
     Thread::sleep( 100 );
 
     Consumer consumer( topic, 2000 );
     Thread consumerThread( &consumer );
     consumerThread.start();
     consumerThread.join();
-    
+
     Thread::sleep( 100 );
 
     CPPUNIT_ASSERT_EQUAL( 0, consumer.getNumReceived() );
@@ -299,14 +296,14 @@
     Thread producerThread( &producer );
     producerThread.start();
     producerThread.join();
-    
+
     Consumer consumer( topic, 3000 );
     Thread consumerThread( &consumer );
     consumerThread.start();
     consumerThread.join();
 
     Thread::sleep( 50 );
-    
+
     CPPUNIT_ASSERT_EQUAL( 2, consumer.getNumReceived() );
 }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleRollbackTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleRollbackTest.cpp?view=diff&rev=517831&r1=517830&r2=517831
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleRollbackTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/connector/stomp/SimpleRollbackTest.cpp
Tue Mar 13 12:49:32 2007
@@ -89,20 +89,19 @@
 
         // Default amount to send and receive
         msgCount = 1;
-    
+
         // Create a Factory
         connectionFactory = new ActiveMQConnectionFactory( url );
 
         // Now create the connection
-        connection = connectionFactory->createConnection(
-            "", "", Guid().createGUIDString() );
-    
-        // Set ourself as a recipient of Exceptions        
+        connection = connectionFactory->createConnection();
+
+        // Set ourself as a recipient of Exceptions
         connection->setExceptionListener( this );
         connection->start();
-        
+
         // Create a Session
-        session = connection->createSession( 
+        session = connection->createSession(
             cms::Session::SESSION_TRANSACTED );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
@@ -130,23 +129,23 @@
     {
         // Create CMS Object for Comms
         cms::Topic* topic = session->createTopic("mytopic");
-        cms::MessageConsumer* consumer = 
-            session->createConsumer( topic );            
+        cms::MessageConsumer* consumer =
+            session->createConsumer( topic );
         consumer->setMessageListener( this );
-        cms::MessageProducer* producer = 
+        cms::MessageProducer* producer =
             session->createProducer( topic );
 
-        cms::TextMessage* textMsg = 
+        cms::TextMessage* textMsg =
             session->createTextMessage();
 
         for( size_t ix = 0; ix < msgCount; ++ix )
         {
             ostringstream lcStream;
-            lcStream << "SimpleTest - Message #" << ix << ends;       
    
+            lcStream << "SimpleTest - Message #" << ix << ends;
             textMsg->setText( lcStream.str() );
             producer->send( textMsg );
         }
-        
+
         delete textMsg;
 
         Thread::sleep( 100 );
@@ -158,11 +157,11 @@
         for( size_t ix = 0; ix < msgCount; ++ix )
         {
             ostringstream lcStream;
-            lcStream << "SimpleTest - Message #" << ix << ends;       
    
+            lcStream << "SimpleTest - Message #" << ix << ends;
             textMsg->setText( lcStream.str() );
             producer->send( textMsg );
         }
-        
+
         delete textMsg;
 
         Thread::sleep( 500 );
@@ -189,7 +188,7 @@
             printf( "Shutting Down\n" );
         }
 
-        delete producer;                      
+        delete producer;
         delete consumer;
         delete topic;
     }
@@ -208,48 +207,48 @@
     try
     {
         // Got a text message.
-        const cms::TextMessage* txtMsg = 
+        const cms::TextMessage* txtMsg =
             dynamic_cast<const cms::TextMessage*>(message);
-            
+
         if( txtMsg != NULL )
         {
             if( IntegrationCommon::debug ) {
                 printf("received text msg: %s\n", txtMsg->getText().c_str() );
             }
-    
+
             numReceived++;
-    
+
             // Signal that we got one
             synchronized( &mutex )
             {
                 mutex.notifyAll();
             }
-    
+
             return;
         }
-        
+
         // Got a bytes msg.
-        const cms::BytesMessage* bytesMsg = 
+        const cms::BytesMessage* bytesMsg =
             dynamic_cast<const cms::BytesMessage*>(message);
-    
+
         if( bytesMsg != NULL )
         {
             const unsigned char* bytes = bytesMsg->getBodyBytes();
-            
+
             string transcode( (const char*)bytes, bytesMsg->getBodyLength() );
 
             if( IntegrationCommon::debug ) {
                 printf("Received Bytes Message: %s", transcode.c_str() );
             }
-    
+
             numReceived++;
-            
+
             // Signal that we got one
             synchronized( &mutex )
             {
                 mutex.notifyAll();
             }
-    
+
             return;
         }
     }



Mime
View raw message