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/04 02:51:16 UTC
svn commit: r618145 - in /activemq/activemq-cpp/trunk/src:
main/activemq/cmsutil/CmsTemplate.cpp main/activemq/cmsutil/CmsTemplate.h
test/activemq/cmsutil/CmsTemplateTest.cpp
Author: nmittler
Date: Sun Feb 3 17:51:13 2008
New Revision: 618145
URL: http://svn.apache.org/viewvc?rev=618145&view=rev
Log:
AMQCPP-152 - Adding tests for CmsTemplate
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h
activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp
Modified: activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp?rev=618145&r1=618144&r2=618145&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp Sun Feb 3 17:51:13 2008
@@ -230,8 +230,12 @@
producer = session->createProducer(dest);
}
+ // Set the default values on the producer.
producer->setDisableMessageID(!isMessageIdEnabled());
producer->setDisableMessageTimeStamp(!isMessageTimestampEnabled());
+ producer->setTimeToLive(getTimeToLive());
+ producer->setDeliveryMode(getDeliveryMode());
+ producer->setPriority(getPriority());
return producer;
}
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=618145&r1=618144&r2=618145&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h Sun Feb 3 17:51:13 2008
@@ -212,7 +212,7 @@
/**
* Sets the name of the default destination to be used from send/receive operations.
- * Calling this method will set the <code>defaultDestination</code> to NULL.
+ * Calling this method will set the <code>defaultDestination</code> property to NULL.
* The destination type (topic/queue) is determined by the
* <code>pubSubDomain</code> property.
*
@@ -220,8 +220,10 @@
* the name of the destination for send/receive to by default.
*/
virtual void setDefaultDestinationName(const std::string& defaultDestinationName) {
- this->defaultDestination = NULL;
- this->defaultDestinationName = defaultDestinationName;
+ if( defaultDestinationName != this->defaultDestinationName ) {
+ this->defaultDestination = NULL;
+ this->defaultDestinationName = defaultDestinationName;
+ }
}
/**
@@ -233,6 +235,20 @@
*/
virtual const std::string getDefaultDestinationName() const {
return this->defaultDestinationName;
+ }
+
+ /**
+ * Indicates whether the default destination is a topic (true) or a queue (false).
+ * Calling this method will set the <code>defaultDestination</code> property to NULL.
+ *
+ * @param pubSubDomain
+ * indicates whether to use pub-sub messaging (topics).
+ */
+ virtual void setPubSubDomain( bool pubSubDomain ) {
+ if( pubSubDomain != isPubSubDomain() ) {
+ this->defaultDestination = NULL;
+ CmsDestinationAccessor::setPubSubDomain(pubSubDomain);
+ }
}
virtual void setMessageIdEnabled(bool messageIdEnabled) {
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=618145&r1=618144&r2=618145&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp Sun Feb 3 17:51:13 2008
@@ -75,19 +75,68 @@
void CmsTemplateTest::testExecuteProducer() {
try {
+
+ cmsTemplate->setPubSubDomain(false);
+
+ // Set the pass-thru values that will be applied to the producer.
+ cmsTemplate->setDeliveryMode(1);
+ cmsTemplate->setTimeToLive(100);
+ cmsTemplate->setPriority(5);
+ cmsTemplate->setMessageTimestampEnabled(true);
+ cmsTemplate->setMessageIdEnabled(true);
// Test basics.
MyProducerCallback callback;
cmsTemplate->execute(&callback);
CPPUNIT_ASSERT(callback.session != NULL);
CPPUNIT_ASSERT(callback.producer != NULL);
+
+ // Check the pass-thru values from CmsTemplate
+ CPPUNIT_ASSERT_EQUAL(1, callback.producer->getDeliveryMode());
+ CPPUNIT_ASSERT_EQUAL(100LL, callback.producer->getTimeToLive());
+ CPPUNIT_ASSERT_EQUAL(5, callback.producer->getPriority());
+ CPPUNIT_ASSERT_EQUAL(false, callback.producer->getDisableMessageID());
+ CPPUNIT_ASSERT_EQUAL(false, callback.producer->getDisableMessageTimeStamp());
// Try again and make sure we have the same producer
MyProducerCallback callback2;
cmsTemplate->execute(&callback2);
CPPUNIT_ASSERT(callback2.session == callback.session);
- CPPUNIT_ASSERT(callback2.producer == callback.producer);
+ CPPUNIT_ASSERT(callback2.producer == callback.producer);
+
+ // Change to topics and make sure it's a different producer.
+ cmsTemplate->setPubSubDomain(true);
+ MyProducerCallback callback3;
+ cmsTemplate->execute(&callback3);
+ CPPUNIT_ASSERT(callback3.session == callback.session);
+ CPPUNIT_ASSERT(callback3.producer != callback.producer);
+
+ // Now change destination name and make sure it's different yet again.
+ cmsTemplate->setDefaultDestinationName("fred");
+ MyProducerCallback callback4;
+ cmsTemplate->execute(&callback4);
+ CPPUNIT_ASSERT(callback4.session == callback.session);
+ CPPUNIT_ASSERT(callback4.producer != callback3.producer);
+
+ // Change the pass-thru values
+ cmsTemplate->setDeliveryMode(0);
+ cmsTemplate->setTimeToLive(1000);
+ cmsTemplate->setPriority(7);
+ cmsTemplate->setMessageTimestampEnabled(false);
+ cmsTemplate->setMessageIdEnabled(false);
+ // Now with the producer from the test 4, verify that the pass-thru
+ // values are changed.
+ MyProducerCallback callback5;
+ cmsTemplate->execute(&callback5);
+ CPPUNIT_ASSERT(callback5.session == callback.session);
+ CPPUNIT_ASSERT(callback5.producer == callback4.producer);
+ CPPUNIT_ASSERT_EQUAL(0, callback5.producer->getDeliveryMode());
+ CPPUNIT_ASSERT_EQUAL(1000LL, callback5.producer->getTimeToLive());
+ CPPUNIT_ASSERT_EQUAL(7, callback5.producer->getPriority());
+ CPPUNIT_ASSERT_EQUAL(true, callback5.producer->getDisableMessageID());
+ CPPUNIT_ASSERT_EQUAL(true, callback5.producer->getDisableMessageTimeStamp());
+
} catch( cms::CMSException& e) {
e.printStackTrace();
}