activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r630697 - in /activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp: CmsTemplateTest.cpp CmsTemplateTest.h
Date Sun, 24 Feb 2008 22:41:57 GMT
Author: nmittler
Date: Sun Feb 24 14:41:55 2008
New Revision: 630697

URL: http://svn.apache.org/viewvc?rev=630697&view=rev
Log: (empty)

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

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=630697&r1=630696&r2=630697&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 24 14:41:55 2008
@@ -89,14 +89,17 @@
               
         Receiver receiver( IntegrationCommon::getInstance().getStompURL(), 
                 false, 
-                "test", 
+                "testBasics", 
                 IntegrationCommon::defaultMsgCount);
         Thread rt(&receiver);
         rt.start();
         
+        // Wait for receiver thread to start.
+        decaf::lang::Thread::sleep(100);
+        
         Sender sender( IntegrationCommon::getInstance().getStompURL(), 
                 false, 
-                "test", 
+                "testBasics", 
                 IntegrationCommon::defaultMsgCount);
         Thread st(&sender);
         st.start();
@@ -110,64 +113,77 @@
         }
         CPPUNIT_ASSERT(
             numReceived == IntegrationCommon::defaultMsgCount );
+    } catch ( ActiveMQException e ) {
+        e.printStackTrace();
+        throw e;
     }
-    AMQ_CATCH_RETHROW( ActiveMQException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void CmsTemplateTest::testReceiveException()
 {
-    // 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");
-    try {                
-        cmsTemplate.receive();
-        CPPUNIT_FAIL("failed to throw expected exception");
-    }
-    catch( ActiveMQException& ex) {
-        // Expected.
+    try {
+        // 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("testReceive");
+        
+        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, 
+                "testReceive", 
+                1);
+        Thread st(&sender);
+        st.start();
+        
+        // Receive the message.
+        cms::Message* message = cmsTemplate.receive();
+        CPPUNIT_ASSERT(message != NULL);
+        delete message;
+    } catch ( ActiveMQException e ) {
+        e.printStackTrace();
+        throw e;
     }
-    
-    // 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()
 {
-    // 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");
-    try {                      
+    try {
+        // 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("testSend");
+        try {                      
+            TextMessageCreator msgCreator("hello world");
+            cmsTemplate.send(&msgCreator);
+            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);
         TextMessageCreator msgCreator("hello world");
         cmsTemplate.send(&msgCreator);
-        CPPUNIT_FAIL("failed to throw expected exception");
-    }
-    catch( ActiveMQException& ex) {
-        // Expected.
+    } catch ( ActiveMQException e ) {
+        e.printStackTrace();
+        throw e;
     }
-    
-    // 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);
 }

Modified: activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.h?rev=630697&r1=630696&r2=630697&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.h
(original)
+++ activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.h
Sun Feb 24 14:41:55 2008
@@ -73,8 +73,10 @@
                 cmsTemplate.setDefaultDestinationName(destName);
                 this->count = count;
             }
+            
             virtual ~Sender(){
             }
+            
             virtual void run() {                
                 try {
                     // Send a batch of messages.
@@ -83,7 +85,6 @@
                         cmsTemplate.send(&tmc);
                     }
                     
-                    decaf::lang::Thread::sleep(100);
                 } catch( cms::CMSException& ex) {
                     ex.printStackTrace();
                 }



Mime
View raw message