activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r620362 - /activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.cpp
Date Mon, 11 Feb 2008 00:48:31 GMT
Author: nmittler
Date: Sun Feb 10 16:48:30 2008
New Revision: 620362

URL: http://svn.apache.org/viewvc?rev=620362&view=rev
Log:
AMQCPP-152 - Adding integ tests for CmsTemplate

Modified:
    activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.cpp

Modified: activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.cpp?rev=620362&r1=620361&r2=620362&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.cpp
Sun Feb 10 16:48:30 2008
@@ -117,31 +117,47 @@
 ////////////////////////////////////////////////////////////////////////////////
 void CmsTemplateTest::testReceiveException()
 {
-    try {
-        
-        activemq::core::ActiveMQConnectionFactory cf("tcp://localhost:61666"); // Invalid
URL (at least by default)
-        activemq::cmsutil::CmsTemplate cmsTemplate(&cf);
-        cmsTemplate.setDefaultDestinationName("hello");
-        cmsTemplate.init();
-        
+    // First, try receiving from a bad url
+    activemq::core::ActiveMQConnectionFactory cf("tcp://localhost:61666"); // Invalid URL
(at least by default)
+    activemq::cmsutil::CmsTemplate cmsTemplate(&cf);
+    cmsTemplate.setDefaultDestinationName("hello");
+    cmsTemplate.init();            
+    try {                
         cmsTemplate.receive();
         CPPUNIT_FAIL("failed to throw expected exception");
     }
     catch( ActiveMQException& ex) {
         // Expected.
     }
+    
+    // Now change to a good url and verify that we can reuse the same
+    // CmsTemplate successfully.
+    activemq::core::ActiveMQConnectionFactory cf2(IntegrationCommon::getInstance().getStompURL());
+    cmsTemplate.setConnectionFactory(&cf2);
+    
+    // Send 1 message.
+    Sender sender( IntegrationCommon::getInstance().getStompURL(), 
+            false, 
+            "hello", 
+            1);
+    Thread st(&sender);
+    st.start();
+    
+    // Receive the message.
+    cms::Message* message = cmsTemplate.receive();
+    CPPUNIT_ASSERT(message != NULL);
+    delete message;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void CmsTemplateTest::testSendException()
 {
-    try {
-        
-        activemq::core::ActiveMQConnectionFactory cf("tcp://localhost:61666"); // Invalid
URL (at least by default)
-        activemq::cmsutil::CmsTemplate cmsTemplate(&cf);
-        cmsTemplate.setDefaultDestinationName("hello");
-        cmsTemplate.init();
-        
+    // First, try sending to a bad url.
+    activemq::core::ActiveMQConnectionFactory cf("tcp://localhost:61666"); // Invalid URL
(at least by default)
+    activemq::cmsutil::CmsTemplate cmsTemplate(&cf);
+    cmsTemplate.setDefaultDestinationName("hello");
+    cmsTemplate.init();
+    try {                      
         TextMessageCreator msgCreator("hello world");
         cmsTemplate.send(&msgCreator);
         CPPUNIT_FAIL("failed to throw expected exception");
@@ -149,4 +165,11 @@
     catch( ActiveMQException& ex) {
         // Expected.
     }
+    
+    // Now change to a good url and verify that we can reuse the same
+    // CmsTemplate successfully.
+    activemq::core::ActiveMQConnectionFactory cf2(IntegrationCommon::getInstance().getStompURL());
+    cmsTemplate.setConnectionFactory(&cf2);
+    TextMessageCreator msgCreator("hello world");
+    cmsTemplate.send(&msgCreator);
 }



Mime
View raw message