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 2008/02/09 18:34:37 UTC

svn commit: r620162 - in /activemq/activemq-cpp/trunk/src: main/activemq/cmsutil/ test/activemq/cmsutil/

Author: nmittler
Date: Sat Feb  9 09:34:33 2008
New Revision: 620162

URL: http://svn.apache.org/viewvc?rev=620162&view=rev
Log:
AMQCPP-152 - Adding unit test classes for CmsTemplate

Added:
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessage.h
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessageCreator.h
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/MessageContext.h
Modified:
    activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h
    activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/MessageCreator.h
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.h
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnection.h
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnectionFactory.h
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyProducer.h
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummySession.h
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp
    activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp

Modified: activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h Sat Feb  9 09:34:33 2008
@@ -33,6 +33,30 @@
     class ProducerCallback;
     class MessageCreator;
     
+    /**
+     * <code>CmsTemplate</code> simplifies performing synchronous CMS 
+     * operations.  This class is intended to be for CMS what Spring's 
+     * <code>JmsTemplate</code> is for JMS.  Provided with a CMS 
+     * <code>ConnectionFactory</code>, creates and manages all other 
+     * CMS resources internally.
+     * <p>
+     * Before using <code>CmsTemplate</code> the user must first set
+     * the destination (either by name or by setting the destiation 
+     * object directly) and then call <code>init</code> to initialize
+     * the object for use.
+     * <p>
+     * <code>CmsTemplate</code> allows the user to get access to a CMS
+     * <code>Session</code> through a user-defined <code>SessionCallback</code>.
+     * Similarly, if the user wants direct access to a CMS
+     * <code>MessageProducer</code>, it can provide a 
+     * <code>ProducerCallback</code>.  As a convenience, the user can bypass
+     * having to provide callbacks altogether for sending messages, by calling
+     * one of the <code>send</code> methods.
+     * 
+     * @see SessionCallback
+     * @see ProducerCallback
+     * @see MessageCreator
+     */
     class CmsTemplate : public CmsDestinationAccessor
     {
     public:

Modified: activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/MessageCreator.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/MessageCreator.h?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/MessageCreator.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/MessageCreator.h Sat Feb  9 09:34:33 2008
@@ -41,7 +41,7 @@
          * @throws cms::CMSException if thrown by CMS API methods
          */
         virtual cms::Message* createMessage(cms::Session* session ) 
-            throw (cms::CMSException);
+            throw (cms::CMSException) = 0;
     
     };
 

Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp Sat Feb  9 09:34:33 2008
@@ -43,7 +43,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void CmsDestinationAccessorTest::test() {
 
-    DummySession s;
+    DummySession s(NULL);
     
     // Create a queue destination
     cms::Destination* d = accessor->resolveDestinationName(&s, "hello");

Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp Sat Feb  9 09:34:33 2008
@@ -19,6 +19,7 @@
 #include <activemq/cmsutil/DynamicDestinationResolver.h>
 #include <activemq/cmsutil/ResourceLifecycleManager.h>
 #include "DummyConnectionFactory.h"
+#include "DummyMessageCreator.h"
 
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::cmsutil::CmsTemplateTest );
 
@@ -142,3 +143,27 @@
     }
 }
 
+////////////////////////////////////////////////////////////////////////////////
+void CmsTemplateTest::testSend() {
+    
+    try {
+        
+        MessageContext* messageContext = cf->getMessageContext();
+        
+        MySendListener listener;
+        messageContext->setSendListener(&listener);
+        
+        DummyMessageCreator msgCreator;
+        
+        cmsTemplate->send(&msgCreator);
+        
+        const cms::Queue* q = dynamic_cast<const cms::Queue*>(listener.dest);
+        CPPUNIT_ASSERT(q != NULL);
+        CPPUNIT_ASSERT_EQUAL((std::string)"test", q->getQueueName());
+        CPPUNIT_ASSERT_EQUAL(4, listener.priority);
+        CPPUNIT_ASSERT_EQUAL(4, listener.priority);
+                
+    } catch( cms::CMSException& e) {
+        e.printStackTrace();
+    }
+}

Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.h?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.h (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.h Sat Feb  9 09:34:33 2008
@@ -24,6 +24,8 @@
 #include <activemq/cmsutil/CmsTemplate.h>
 #include <activemq/cmsutil/SessionCallback.h>
 #include <activemq/cmsutil/ProducerCallback.h>
+#include <activemq/cmsutil/DummyMessageCreator.h>
+#include <activemq/cmsutil/MessageContext.h>
 
 namespace activemq{
 namespace cmsutil{
@@ -35,12 +37,42 @@
         CPPUNIT_TEST_SUITE( CmsTemplateTest );
         CPPUNIT_TEST( testExecuteSession );
         CPPUNIT_TEST( testExecuteProducer );
+        CPPUNIT_TEST( testSend );
         CPPUNIT_TEST_SUITE_END();               
              
 
         CmsTemplate* cmsTemplate;
         DummyConnectionFactory* cf;
         
+        class MySendListener : public MessageContext::SendListener {
+        public:
+            
+            const cms::Destination* dest;
+            cms::Message* message;
+            int deliveryMode;
+            int priority;
+            long long ttl;
+                    
+            MySendListener() {
+                dest = NULL;
+                message = NULL;
+                deliveryMode = 0;
+                priority = 0;
+                ttl = 0LL;
+            }
+            virtual ~MySendListener(){}
+            
+            virtual void onSend(const cms::Destination* destination,
+                cms::Message* message, int deliveryMode, int priority, 
+                long long timeToLive) {
+                this->dest = destination;
+                this->message = message;
+                this->deliveryMode = deliveryMode;
+                this->priority = priority;
+                this->ttl = timeToLive;
+            }
+        };
+        
         class MySessionCallback : public SessionCallback {
         public:
             
@@ -87,6 +119,7 @@
         
         void testExecuteSession();
         void testExecuteProducer();
+        void testSend();
     };
 
 }}

Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnection.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnection.h?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnection.h (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnection.h Sat Feb  9 09:34:33 2008
@@ -24,14 +24,20 @@
 namespace activemq {
 namespace cmsutil {
 
+    class MessageContext;
+
     class DummyConnection : public cms::Connection {
     private:
         
         cms::ExceptionListener* listener;
         std::string clientId;
+        MessageContext* messageContext;
         
     public:
 
+        DummyConnection(MessageContext* messageContext ) {
+            this->messageContext = messageContext;
+        }
         virtual ~DummyConnection() {}
 
         virtual void close() throw( cms::CMSException ) {            
@@ -44,13 +50,13 @@
         }
 
         virtual cms::Session* createSession() throw ( cms::CMSException ) {
-            return new DummySession();
+            return new DummySession(messageContext);
         }
                 
         virtual cms::Session* createSession( cms::Session::AcknowledgeMode ackMode ) 
             throw ( cms::CMSException ) {
             
-            DummySession* s = new DummySession();
+            DummySession* s = new DummySession(messageContext);
             s->setAcknowledgeMode(ackMode);
             return s;
         }

Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnectionFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnectionFactory.h?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnectionFactory.h (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyConnectionFactory.h Sat Feb  9 09:34:33 2008
@@ -20,26 +20,30 @@
 
 #include <cms/ConnectionFactory.h>
 #include <activemq/cmsutil/DummyConnection.h>
+#include <activemq/cmsutil/MessageContext.h>
 
 namespace activemq {
 namespace cmsutil {
 
     class DummyConnectionFactory : public cms::ConnectionFactory {
+    private:
+        
+        MessageContext messageContext;
         
     public:
-
+        
         virtual ~DummyConnectionFactory() {}
 
         virtual cms::Connection* createConnection() throw ( cms::CMSException ) {
             
-            return new DummyConnection();
+            return new DummyConnection(&messageContext);
         }
 
         virtual cms::Connection* createConnection( const std::string& username,
                                                    const std::string& password )
             throw ( cms::CMSException ) {
             
-            return new DummyConnection();
+            return new DummyConnection(&messageContext);
         }
 
         virtual cms::Connection* createConnection( const std::string& username,
@@ -47,11 +51,16 @@
                                                    const std::string& clientId )
             throw ( cms::CMSException ) {
             
-            DummyConnection* c = new DummyConnection();
+            DummyConnection* c = new DummyConnection(&messageContext);
             c->setClientID(clientId);
             
             return c;
         }
+        
+        MessageContext* getMessageContext() {
+            return &messageContext;
+        }
+        
     };
     
 }}

Added: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessage.h?rev=620162&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessage.h (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessage.h Sat Feb  9 09:34:33 2008
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACTIVEMQ_CMSUTIL_DUMMYMESSAGE_H_
+#define ACTIVEMQ_CMSUTIL_DUMMYMESSAGE_H_
+
+#include <cms/Message.h>
+
+namespace activemq{
+namespace cmsutil{
+   
+    class DummyMessage : public cms::Message
+    {         
+    public:
+   
+        virtual ~DummyMessage(){}
+      
+        virtual Message* clone() const { return NULL; }               
+        
+        virtual void acknowledge() const throw( cms::CMSException ){}
+      
+        virtual void clearBody(){}
+        
+        virtual void clearProperties(){}
+  
+        virtual std::vector<std::string> getPropertyNames() const {
+            return std::vector<std::string>();
+        }
+        
+        virtual bool propertyExists( const std::string& name ) const {
+            return false;
+        }
+        
+        virtual bool getBooleanProperty( const std::string& name ) const 
+            throw( cms::CMSException ) {
+            return false;
+        }
+        
+        virtual unsigned char getByteProperty( const std::string& name ) const 
+            throw( cms::CMSException ) {
+            return (unsigned char)0;
+        }
+        virtual double getDoubleProperty( const std::string& name ) const 
+            throw( cms::CMSException ) {
+            return 0.0;
+        }
+        
+        virtual float getFloatProperty( const std::string& name ) const 
+            throw( cms::CMSException ) {
+            return 0.0f;
+        }
+            
+        virtual int getIntProperty( const std::string& name ) const 
+            throw( cms::CMSException ) {
+            return 0;
+        }
+        virtual long long getLongProperty( const std::string& name ) const 
+            throw( cms::CMSException ) {
+            return 0LL;
+        }
+          
+        virtual short getShortProperty( const std::string& name ) const 
+            throw( cms::CMSException ) {
+            return 0;
+        }
+            
+        virtual std::string getStringProperty( const std::string& name ) const 
+            throw( cms::CMSException ) {
+            return "";
+        }
+        
+        virtual void setBooleanProperty( const std::string& name,
+            bool value ) throw( cms::CMSException ) {}
+            
+        virtual void setByteProperty( const std::string& name,
+            unsigned char value ) throw( cms::CMSException ) {}
+            
+        virtual void setDoubleProperty( const std::string& name,
+            double value ) throw( cms::CMSException ) {}
+            
+        virtual void setFloatProperty( const std::string& name,
+            float value ) throw( cms::CMSException ) {}
+            
+        
+        virtual void setIntProperty( const std::string& name,
+            int value ) throw( cms::CMSException ) {}
+            
+        virtual void setLongProperty( const std::string& name,
+            long long value ) throw( cms::CMSException ) {}
+            
+        virtual void setShortProperty( const std::string& name,
+            short value ) throw( cms::CMSException ) {}
+            
+        virtual void setStringProperty( const std::string& name,
+            const std::string& value ) throw( cms::CMSException ) {}
+      
+        virtual std::string getCMSCorrelationID() const {return "";}
+
+        virtual void setCMSCorrelationID( const std::string& correlationId ) {}
+
+        virtual int getCMSDeliveryMode() const { return 0; }
+
+        virtual void setCMSDeliveryMode( int mode ) {}
+      
+        virtual const cms::Destination* getCMSDestination() const { return NULL; }
+      
+        virtual void setCMSDestination( const cms::Destination* destination ) {}
+              
+        virtual long long getCMSExpiration() const { return 0LL; }
+      
+        virtual void setCMSExpiration( long long expireTime ) {}
+              
+        virtual std::string getCMSMessageID() const { return ""; }
+        
+        virtual void setCMSMessageID( const std::string& id ) {}
+      
+        virtual int getCMSPriority() const { return 0; }
+      
+        virtual void setCMSPriority( int priority ) {}
+
+        virtual bool getCMSRedelivered() const { return false; }
+      
+        virtual void setCMSRedelivered( bool redelivered ) {}
+
+        virtual const cms::Destination* getCMSReplyTo() const { return NULL; }
+      
+        virtual void setCMSReplyTo( const cms::Destination* destination ) {}
+        
+        virtual long long getCMSTimestamp() const { return 0LL; }
+      
+        virtual void setCMSTimestamp( long long timeStamp ) {}
+
+        virtual std::string getCMSType() const { return ""; }
+      
+        virtual void setCMSType( const std::string& type ) {}
+        
+    };
+}}
+
+#endif /*ACTIVEMQ_CMSUTIL_DUMMYMESSAGE_H_*/

Added: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessageCreator.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessageCreator.h?rev=620162&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessageCreator.h (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyMessageCreator.h Sat Feb  9 09:34:33 2008
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACTIVEMQ_CMSUTIL_DUMMYMESSAGECREATOR_H_
+#define ACTIVEMQ_CMSUTIL_DUMMYMESSAGECREATOR_H_
+
+#include <activemq/cmsutil/MessageCreator.h>
+#include <activemq/cmsutil/DummyMessage.h>
+
+namespace activemq {
+namespace cmsutil {
+
+    class DummyMessageCreator : public MessageCreator {
+    public:
+        
+        virtual ~DummyMessageCreator() {}
+        
+        virtual cms::Message* createMessage(cms::Session* session ) 
+                    throw (cms::CMSException) {
+            return new DummyMessage();
+        }
+    };
+}}
+
+#endif /*ACTIVEMQ_CMSUTIL_DUMMYMESSAGECREATOR_H_*/

Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyProducer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyProducer.h?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyProducer.h (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummyProducer.h Sat Feb  9 09:34:33 2008
@@ -19,26 +19,31 @@
 #define ACTIVEMQ_CMSUTIL_DUMMYPRODUCER_H_
 
 #include <cms/MessageProducer.h>
+#include <activemq/cmsutil/MessageContext.h>
 
 namespace activemq {
 namespace cmsutil {
 
     class DummyProducer : public cms::MessageProducer {  
     private:
+        const cms::Destination* dest;
         int deliveryMode;
         bool disableMessageId;
         bool disableMessageTimestamp;
         int priority;
         long long ttl;
+        MessageContext* messageContext;
         
     public:
 
-        DummyProducer() {
+        DummyProducer(MessageContext* messageContext, const cms::Destination* dest) {
             deliveryMode = 1;
             disableMessageId = false;
             disableMessageTimestamp = false;
             priority = 4;
             ttl = 0L;
+            this->dest = dest;
+            this->messageContext = messageContext;
         }
         virtual ~DummyProducer() {}
               
@@ -53,7 +58,8 @@
          *      The message to be sent.
          * @throws cms::CMSException
          */
-        virtual void send( cms::Message* message ) throw ( cms::CMSException ){            
+        virtual void send( cms::Message* message ) throw ( cms::CMSException ){
+            send(message, deliveryMode, priority, ttl);
         }
 
         /**
@@ -71,8 +77,10 @@
          * @throws cms::CMSException
          */
         virtual void send( cms::Message* message, int deliveryMode, int priority, 
-            long long timeToLive) throw ( cms::CMSException ){            
-            }
+            long long timeToLive) throw ( cms::CMSException ){
+            
+            send(dest, message, deliveryMode, priority, timeToLive);
+        }
             
         /**
          * Sends the message to the designated destination, but does
@@ -86,7 +94,9 @@
          * @throws cms::CMSException
          */
         virtual void send( const cms::Destination* destination,
-                           cms::Message* message ) throw ( cms::CMSException ){}
+                           cms::Message* message ) throw ( cms::CMSException ){
+            send(dest, message, deliveryMode, priority, ttl);
+        }
                            
         /**
          * Sends the message to the designated destination, but does
@@ -106,7 +116,10 @@
          */     
         virtual void send( const cms::Destination* destination,
             cms::Message* message, int deliveryMode, int priority, 
-            long long timeToLive) throw ( cms::CMSException ){}
+            long long timeToLive) throw ( cms::CMSException ){
+            
+            messageContext->send(destination, message, deliveryMode, priority, timeToLive);
+        }
             
         /** 
          * Sets the delivery mode for this Producer

Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummySession.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummySession.h?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummySession.h (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DummySession.h Sat Feb  9 09:34:33 2008
@@ -26,16 +26,20 @@
 namespace activemq {
 namespace cmsutil {
 
+    class MessageContext;
+
     class DummySession : public cms::Session {
     
     private:
         
         cms::Session::AcknowledgeMode mode;
+        MessageContext* messageContext;
         
     public:
 
-        DummySession() {
+        DummySession(MessageContext* messageContext) {
             this->mode = cms::Session::AUTO_ACKNOWLEDGE;
+            this->messageContext = messageContext;
         }
         
         virtual ~DummySession() {}
@@ -71,7 +75,7 @@
                 throw ( cms::CMSException ) { return NULL; }
 
         virtual cms::MessageProducer* createProducer( const cms::Destination* destination )
-            throw ( cms::CMSException ) { return new DummyProducer(); }
+            throw ( cms::CMSException ) { return new DummyProducer(messageContext, destination); }
 
         virtual cms::Queue* createQueue( const std::string& queueName )
             throw ( cms::CMSException ) {

Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp Sat Feb  9 09:34:33 2008
@@ -32,7 +32,7 @@
     DynamicDestinationResolver resolver;
     resolver.setResourceLifecycleManager(&mgr);
     
-    DummySession session;
+    DummySession session(NULL);
     
     // Test topic
     cms::Destination* testTopic = dynamic_cast<cms::Topic*>(resolver.resolveDestinationName(&session, 
@@ -64,7 +64,7 @@
     DynamicDestinationResolver resolver;
     resolver.setResourceLifecycleManager(&mgr);
     
-    DummySession session;
+    DummySession session(NULL);
     
     // Queue topic
     cms::Destination* testQueue = dynamic_cast<cms::Queue*>(resolver.resolveDestinationName(&session, 

Added: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/MessageContext.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/MessageContext.h?rev=620162&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/MessageContext.h (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/MessageContext.h Sat Feb  9 09:34:33 2008
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACTIVEMQ_CMSUTIL_MESSAGECONTEXT_H_
+#define ACTIVEMQ_CMSUTIL_MESSAGECONTEXT_H_
+
+#include <cms/Destination.h>
+#include <cms/Message.h>
+
+namespace activemq {
+namespace cmsutil {
+
+    class MessageContext {
+        
+    public:
+            
+        class SendListener {
+        public:
+            
+            virtual ~SendListener(){}
+            
+            virtual void onSend(const cms::Destination* destination,
+                cms::Message* message, int deliveryMode, int priority, 
+                long long timeToLive) = 0;
+        };
+        
+    private:
+        
+        SendListener* listener;
+        
+    public:
+        
+        MessageContext() {
+            listener = NULL;
+        }
+        virtual ~MessageContext(){}
+            
+        void setSendListener(SendListener* listener) {
+            this->listener = listener;
+        }
+        
+        void send(const cms::Destination* destination,
+            cms::Message* message, int deliveryMode, int priority, 
+            long long timeToLive) {
+            
+            if( listener != NULL ) {
+                listener->onSend(destination, message, deliveryMode, priority, timeToLive);
+            }
+        }
+    };
+}}
+
+#endif /*ACTIVEMQ_CMSUTIL_MESSAGECONTEXT_H_*/

Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp?rev=620162&r1=620161&r2=620162&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp Sat Feb  9 09:34:33 2008
@@ -25,7 +25,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void SessionPoolTest::testTakeSession() {
     
-    DummyConnection connection;
+    DummyConnection connection(NULL);
     ResourceLifecycleManager mgr;
     
     SessionPool pool(&connection, cms::Session::AUTO_ACKNOWLEDGE, &mgr);
@@ -45,7 +45,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void SessionPoolTest::testReturnSession() {
     
-    DummyConnection connection;
+    DummyConnection connection(NULL);
     ResourceLifecycleManager mgr;
     
     SessionPool pool(&connection, cms::Session::AUTO_ACKNOWLEDGE, &mgr);
@@ -68,7 +68,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void SessionPoolTest::testCloseSession() {
     
-    DummyConnection connection;
+    DummyConnection connection(NULL);
     ResourceLifecycleManager mgr;
     
     SessionPool pool(&connection, cms::Session::AUTO_ACKNOWLEDGE, &mgr);