activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r620322 - in /activemq/activemq-cpp/trunk/src/test-integration: Makefile.am integration/TestRegistry.cpp integration/connector/stomp/CmsTemplateTest.cpp integration/connector/stomp/CmsTemplateTest.h
Date Sun, 10 Feb 2008 20:40:26 GMT
Author: nmittler
Date: Sun Feb 10 12:40:24 2008
New Revision: 620322

URL: http://svn.apache.org/viewvc?rev=620322&view=rev
Log:
AMQCPP-152 - Adding integ test for CmsTemplate + stomp

Added:
    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/Makefile.am
    activemq/activemq-cpp/trunk/src/test-integration/integration/TestRegistry.cpp

Modified: activemq/activemq-cpp/trunk/src/test-integration/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/Makefile.am?rev=620322&r1=620321&r2=620322&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/Makefile.am Sun Feb 10 12:40:24 2008
@@ -28,6 +28,7 @@
   integration/connector/openwire/OpenwireTransactionTest.cpp \
   integration/connector/openwire/OpenwireTempDestinationTest.cpp \
   integration/connector/stomp/AsyncSenderTest.cpp \
+  integration/connector/stomp/CmsTemplateTest.cpp \
   integration/connector/stomp/DurableTest.cpp \
   integration/connector/stomp/ExpirationTest.cpp \
   integration/connector/stomp/SimpleRollbackTest.cpp \

Modified: activemq/activemq-cpp/trunk/src/test-integration/integration/TestRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/integration/TestRegistry.cpp?rev=620322&r1=620321&r2=620322&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/integration/TestRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/integration/TestRegistry.cpp Sun Feb
10 12:40:24 2008
@@ -25,6 +25,7 @@
 #include "connector/openwire/OpenwireTransactionTest.h"
 
 #include "connector/stomp/AsyncSenderTest.h"
+#include "connector/stomp/CmsTemplateTest.h"
 #include "connector/stomp/DurableTest.h"
 #include "connector/stomp/ExpirationTest.h"
 #include "connector/stomp/SimpleRollbackTest.h"
@@ -42,6 +43,7 @@
 CPPUNIT_TEST_SUITE_REGISTRATION( integration::connector::openwire::OpenwireTransactionTest
);
 
 CPPUNIT_TEST_SUITE_REGISTRATION( integration::connector::stomp::AsyncSenderTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( integration::connector::stomp::CmsTemplateTest );
 CPPUNIT_TEST_SUITE_REGISTRATION( integration::connector::stomp::DurableTest );
 CPPUNIT_TEST_SUITE_REGISTRATION( integration::connector::stomp::ExpirationTest );
 CPPUNIT_TEST_SUITE_REGISTRATION( integration::connector::stomp::SimpleRollbackTest );

Added: 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=620322&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.cpp
(added)
+++ activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.cpp
Sun Feb 10 12:40:24 2008
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+
+#include "CmsTemplateTest.h"
+#include <integration/IntegrationCommon.h>
+
+#include <decaf/lang/Thread.h>
+#include <activemq/connector/stomp/StompConnector.h>
+#include <decaf/util/Properties.h>
+#include <activemq/transport/TransportFactory.h>
+#include <decaf/util/UUID.h>
+#include <decaf/util/Properties.h>
+#include <decaf/util/StringTokenizer.h>
+#include <activemq/connector/ConnectorFactoryMap.h>
+#include <decaf/net/SocketFactory.h>
+#include <activemq/transport/TransportFactory.h>
+#include <decaf/net/Socket.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <activemq/core/ActiveMQConnectionFactory.h>
+#include <activemq/core/ActiveMQConnection.h>
+#include <activemq/core/ActiveMQConsumer.h>
+#include <activemq/core/ActiveMQProducer.h>
+#include <decaf/util/StringTokenizer.h>
+#include <decaf/lang/Boolean.h>
+
+#include <cms/Connection.h>
+#include <cms/MessageConsumer.h>
+#include <cms/MessageProducer.h>
+#include <cms/MessageListener.h>
+#include <cms/Startable.h>
+#include <cms/Closeable.h>
+#include <cms/MessageListener.h>
+#include <cms/ExceptionListener.h>
+#include <cms/Topic.h>
+#include <cms/Queue.h>
+#include <cms/TemporaryTopic.h>
+#include <cms/TemporaryQueue.h>
+#include <cms/Session.h>
+#include <cms/BytesMessage.h>
+#include <cms/TextMessage.h>
+#include <cms/MapMessage.h>
+
+using namespace activemq::connector::stomp;
+using namespace activemq::transport;
+using namespace activemq::util;
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::core;
+using namespace activemq::util;
+using namespace activemq::connector;
+using namespace activemq::exceptions;
+using namespace decaf::net;
+using namespace activemq::transport;
+using namespace decaf::util::concurrent;
+using namespace decaf::lang;
+using namespace decaf::util;
+
+using namespace integration;
+using namespace integration::connector::stomp;
+using namespace activemq::cmsutil;
+
+////////////////////////////////////////////////////////////////////////////////
+void CmsTemplateTest::setUp() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CmsTemplateTest::tearDown() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CmsTemplateTest::testBasics()
+{
+    try {
+              
+        Receiver receiver( IntegrationCommon::getInstance().getStompURL(), 
+                false, 
+                "test", 
+                IntegrationCommon::defaultMsgCount);
+        Thread rt(&receiver);
+        rt.start();
+        
+        Sender sender( IntegrationCommon::getInstance().getStompURL(), 
+                false, 
+                "test", 
+                IntegrationCommon::defaultMsgCount);
+        Thread st(&sender);
+        st.start();
+        
+        st.join();
+        rt.join();
+        
+        unsigned int numReceived = receiver.getNumReceived();
+        if( IntegrationCommon::debug ) {
+            printf("received: %d\n", numReceived );
+        }
+        CPPUNIT_ASSERT(
+            numReceived == IntegrationCommon::defaultMsgCount );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+}

Added: 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=620322&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.h
(added)
+++ activemq/activemq-cpp/trunk/src/test-integration/integration/connector/stomp/CmsTemplateTest.h
Sun Feb 10 12:40:24 2008
@@ -0,0 +1,148 @@
+/*
+ * 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 _INTEGRATION_CONNECTOR_STOMP_CMSTEMPLATETEST_H_
+#define _INTEGRATION_CONNECTOR_STOMP_CMSTEMPLATETEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <integration/TestSupport.h>
+#include <activemq/core/ActiveMQConnectionFactory.h>
+#include <activemq/cmsutil/CmsTemplate.h>
+#include <activemq/cmsutil/MessageCreator.h>
+
+namespace integration{
+namespace connector{
+namespace stomp{
+
+    class CmsTemplateTest : public CppUnit::TestFixture
+    {
+        CPPUNIT_TEST_SUITE( CmsTemplateTest );
+        CPPUNIT_TEST( testBasics );
+        CPPUNIT_TEST_SUITE_END();
+        
+        class TextMessageCreator : public activemq::cmsutil::MessageCreator {
+        private:
+            std::string text;
+        public:
+            TextMessageCreator( const std::string& text) {
+                this->text = text;
+            }
+            virtual ~TextMessageCreator() {}
+            
+            std::string getText() const {
+                return text;
+            }
+            
+            virtual cms::Message* createMessage(cms::Session* session ) 
+                        throw (cms::CMSException) {
+                return session->createTextMessage(text);
+            } 
+        };
+        
+        class Sender : public decaf::lang::Runnable {
+        private:
+                    
+            activemq::core::ActiveMQConnectionFactory cf;
+            activemq::cmsutil::CmsTemplate cmsTemplate;
+            int count;
+            
+        public:
+            
+            Sender( const std::string& url, bool pubSub, const std::string& destName,
int count ) {
+                cf.setBrokerURL(url);
+                cmsTemplate.setConnectionFactory(&cf);
+                cmsTemplate.setPubSubDomain(pubSub);
+                cmsTemplate.setDefaultDestinationName(destName);
+                cmsTemplate.init();
+                this->count = count;
+            }
+            virtual ~Sender(){
+                cmsTemplate.destroy();
+            }
+            virtual void run() {                
+                try {
+                    // Send a batch of messages.
+                    TextMessageCreator tmc("hello world");
+                    for( int ix=0; ix<count; ++ix ) {
+                        cmsTemplate.send(&tmc);
+                    }
+                    
+                    decaf::lang::Thread::sleep(100);
+                } catch( cms::CMSException& ex) {
+                    ex.printStackTrace();
+                }
+            }
+        };
+        
+        class Receiver : public decaf::lang::Runnable {
+        private:
+            
+            activemq::core::ActiveMQConnectionFactory cf;
+            activemq::cmsutil::CmsTemplate cmsTemplate;
+            int count;
+            int numReceived;
+            
+        public:
+            
+            Receiver( const std::string& url, bool pubSub, const std::string& destName,
int count ) {
+                cf.setBrokerURL(url);
+                cmsTemplate.setConnectionFactory(&cf);
+                cmsTemplate.setPubSubDomain(pubSub);
+                cmsTemplate.setDefaultDestinationName(destName);
+                cmsTemplate.init();
+                this->count = count;
+            }
+            virtual ~Receiver(){
+                cmsTemplate.destroy();
+            }
+            int getNumReceived() const {
+                return numReceived;
+            }
+            virtual void run() {
+                
+                try {
+                    numReceived = 0;
+                    
+                    // Receive a batch of messages.
+                    for( int ix=0; ix<count; ++ix ) {
+                        cms::Message* message = cmsTemplate.receive();
+                        numReceived++;
+                        delete message;                    
+                    }
+                } catch( cms::CMSException& ex) {
+                    ex.printStackTrace();
+                }
+            }
+        };
+        
+    public:
+
+        CmsTemplateTest(){}
+        virtual ~CmsTemplateTest(){}
+
+        virtual void setUp();
+        virtual void tearDown();
+                
+        virtual void testBasics();
+
+    };
+
+}}}
+
+#endif /*_INTEGRATION_CONNECTOR_STOMP_CMSTEMPLATETEST_H_*/



Mime
View raw message