You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/05/02 00:20:28 UTC

svn commit: r1478219 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/wireformat/stomp/ test-integration/ test-integration/activemq/test/ test-integration/activemq/test/stomp/ test-integration/activemq/util/

Author: tabish
Date: Wed May  1 22:20:27 2013
New Revision: 1478219

URL: http://svn.apache.org/r1478219
Log:
fix and test for: https://issues.apache.org/jira/browse/AMQCPP-476

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.h   (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/TestRegistry.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp?rev=1478219&r1=1478218&r2=1478219&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp Wed May  1 22:20:27 2013
@@ -297,7 +297,7 @@ void StompFrame::readBody(decaf::io::Dat
             this->body.resize((std::size_t) content_length);
 
             // Read the Content Length now
-            in->read(&body[0], (int) body.size(), 0, content_length);
+            in->readFully(&body[0], body.size());
 
             // Content Length read, now pop the end terminator off (\0\n).
             if (in->readByte() != '\0') {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/Makefile.am?rev=1478219&r1=1478218&r2=1478219&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/Makefile.am Wed May  1 22:20:27 2013
@@ -18,6 +18,7 @@
 cc_sources = \
     TestRegistry.cpp \
     activemq/test/AsyncSenderTest.cpp \
+    activemq/test/BulkMessageTest.cpp \
     activemq/test/CmsConnectionStartStopTest.cpp \
     activemq/test/CmsSendWithAsyncCallbackTest.cpp \
     activemq/test/CmsTemplateTest.cpp \
@@ -58,6 +59,7 @@ cc_sources = \
     activemq/test/openwire/OpenwireVirtualTopicTest.cpp \
     activemq/test/openwire/OpenwireXATransactionsTest.cpp \
     activemq/test/stomp/StompAsyncSenderTest.cpp \
+    activemq/test/stomp/StompBulkMessageTest.cpp \
     activemq/test/stomp/StompCmsConnectionStartStopTest.cpp \
     activemq/test/stomp/StompCmsTemplateTest.cpp \
     activemq/test/stomp/StompDurableTest.cpp \
@@ -76,6 +78,7 @@ cc_sources = \
 
 h_sources = \
     activemq/test/AsyncSenderTest.h \
+    activemq/test/BulkMessageTest.h \
     activemq/test/CMSTestFixture.h \
     activemq/test/CmsConnectionStartStopTest.h \
     activemq/test/CmsSendWithAsyncCallbackTest.h \
@@ -117,6 +120,7 @@ h_sources = \
     activemq/test/openwire/OpenwireVirtualTopicTest.h \
     activemq/test/openwire/OpenwireXATransactionsTest.h \
     activemq/test/stomp/StompAsyncSenderTest.h \
+    activemq/test/stomp/StompBulkMessageTest.h \
     activemq/test/stomp/StompCmsConnectionStartStopTest.h \
     activemq/test/stomp/StompCmsTemplateTest.h \
     activemq/test/stomp/StompDurableTest.h \

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/TestRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/TestRegistry.cpp?rev=1478219&r1=1478218&r2=1478219&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/TestRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/TestRegistry.cpp Wed May  1 22:20:27 2013
@@ -39,8 +39,8 @@
 #include "activemq/test/openwire/OpenwireSlowListenerTest.h"
 #include "activemq/test/openwire/OpenwireVirtualTopicTest.h"
 #include "activemq/test/openwire/OpenwireXATransactionsTest.h"
-
 #include "activemq/test/stomp/StompAsyncSenderTest.h"
+#include "activemq/test/stomp/StompBulkMessageTest.h"
 #include "activemq/test/stomp/StompCmsTemplateTest.h"
 #include "activemq/test/stomp/StompCmsConnectionStartStopTest.h"
 #include "activemq/test/stomp/StompDurableTest.h"
@@ -79,6 +79,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( activem
 
 // Stomp Tests
 //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompAsyncSenderTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompBulkMessageTest );
 //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompCmsTemplateTest );
 //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompCmsConnectionStartStopTest );
 //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompDurableTest );

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.cpp?rev=1478219&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.cpp Wed May  1 22:20:27 2013
@@ -0,0 +1,111 @@
+/*
+ * 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 "BulkMessageTest.h"
+
+#include <activemq/util/CMSListener.h>
+#include <activemq/exceptions/ActiveMQException.h>
+
+#include <decaf/lang/Thread.h>
+#include <decaf/util/UUID.h>
+#include <decaf/lang/Pointer.h>
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::util;
+using namespace activemq::exceptions;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    class ProducerThread : public Thread {
+    private:
+
+        std::auto_ptr<activemq::util::CMSProvider> cmsProducerProvider;
+        int num;
+        int size;
+
+    private:
+
+        ProducerThread(const ProducerThread&);
+        ProducerThread& operator= (const ProducerThread&);
+
+    public:
+
+        ProducerThread(const std::string& brokerURL, const std::string& destinationName, const std::string& subscription, int num, int size) :
+            cmsProducerProvider(new activemq::util::CMSProvider(brokerURL, destinationName, subscription)), num(num), size(size) {
+        }
+
+        virtual ~ProducerThread() {}
+
+        virtual void run() {
+
+            cms::Session* session( cmsProducerProvider->getSession() );
+            Destination* destination = cmsProducerProvider->getDestination();
+            Pointer<MessageProducer> producer( session->createProducer( destination ) );
+            producer->setDeliveryMode( cms::DeliveryMode::NON_PERSISTENT );
+
+            std::string DATA = "abcdefghijklmnopqrstuvwxyz";
+            std::string body = "";
+            for( int i=0; i < size; i ++) {
+                body += DATA.at(i % DATA.length());
+            }
+
+            Pointer<BytesMessage> message;
+
+            for( int i = 0; i < num; ++i ) {
+                message.reset( session->createBytesMessage( (const unsigned char*) body.c_str(), body.length() ) );
+                producer->send( message.get() );
+            }
+        }
+    };
+}
+
+////////////////////////////////////////////////////////////////////////////////
+BulkMessageTest::BulkMessageTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+BulkMessageTest::~BulkMessageTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BulkMessageTest::testBulkMessageSendReceive() {
+
+    static const int MSG_COUNT = 5000;
+    static const int MSG_SIZE = 8192;
+
+    // Create CMS Object for consumer Comms
+    cms::Session* session( cmsProvider->getSession() );
+    cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+    Destination* destination = cmsProvider->getDestination();
+
+    ProducerThread thread( this->getBrokerURL(), cmsProvider->getDestinationName(), cmsProvider->getSubscription(), MSG_COUNT, MSG_SIZE );
+    thread.start();
+
+    Pointer<cms::Message> message;
+
+    for( int i = 0; i < MSG_COUNT ; ++i ) {
+        CPPUNIT_ASSERT_NO_THROW( message.reset( consumer->receive( 2000 ) ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+    }
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.h?rev=1478219&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.h Wed May  1 22:20:27 2013
@@ -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_TEST_BULKMESSAGETEST_H_
+#define _ACTIVEMQ_TEST_BULKMESSAGETEST_H_
+
+#include <activemq/test/CMSTestFixture.h>
+#include <activemq/util/IntegrationCommon.h>
+
+namespace activemq {
+namespace test {
+
+    class BulkMessageTest : public CMSTestFixture {
+    public:
+
+        BulkMessageTest();
+        virtual ~BulkMessageTest();
+
+        void testBulkMessageSendReceive();
+
+    };
+
+}}
+
+#endif /* _ACTIVEMQ_TEST_BULKMESSAGETEST_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/BulkMessageTest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.cpp?rev=1478219&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.cpp Wed May  1 22:20:27 2013
@@ -0,0 +1,32 @@
+/*
+ * 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 "StompBulkMessageTest.h"
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::test::stomp;
+
+////////////////////////////////////////////////////////////////////////////////
+StompBulkMessageTest::StompBulkMessageTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+StompBulkMessageTest::~StompBulkMessageTest() {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.h?rev=1478219&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.h Wed May  1 22:20:27 2013
@@ -0,0 +1,46 @@
+/*
+ * 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_TEST_STOMP_STOMPBULKMESSAGETESTER_H_
+#define _ACTIVEMQ_TEST_STOMP_STOMPBULKMESSAGETESTER_H_
+
+#include <activemq/test/BulkMessageTest.h>
+
+namespace activemq{
+namespace test{
+namespace stomp{
+
+    class StompBulkMessageTest : public BulkMessageTest {
+
+        CPPUNIT_TEST_SUITE( StompBulkMessageTest );
+        CPPUNIT_TEST( testBulkMessageSendReceive );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        StompBulkMessageTest();
+        virtual ~StompBulkMessageTest();
+
+        virtual std::string getBrokerURL() const {
+            return activemq::util::IntegrationCommon::getInstance().getStompURL();
+        }
+
+    };
+
+}}}
+
+#endif /*_ACTIVEMQ_TEST_STOMP_STOMPBULKMESSAGETESTER_H_*/

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.cpp?rev=1478219&r1=1478218&r2=1478219&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.cpp Wed May  1 22:20:27 2013
@@ -50,6 +50,18 @@ CMSProvider::CMSProvider(const std::stri
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+CMSProvider::CMSProvider(const std::string& brokerURL, const std::string& destinationName, const std::string& subscription, cms::Session::AcknowledgeMode ackMode) :
+    brokerURL(brokerURL), ackMode(ackMode), username(), password(), clientId(),
+    destinationName(), topic(true), durable(false), subscription(), connectionFactory(),
+    connection(), session(), consumer(), producer(), noDestProducer(), destination(), tempDestination() {
+
+    this->destinationName = destinationName;
+    this->subscription = subscription;
+
+    this->initialize();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 CMSProvider::~CMSProvider() {
     try{
         close();

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.h?rev=1478219&r1=1478218&r2=1478219&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/util/CMSProvider.h Wed May  1 22:20:27 2013
@@ -61,6 +61,11 @@ namespace util {
 
         CMSProvider(const std::string& brokerURL, cms::Session::AcknowledgeMode ackMode = cms::Session::AUTO_ACKNOWLEDGE);
 
+        CMSProvider(const std::string& brokerURL,
+                    const std::string& destinationName,
+                    const std::string& subscription,
+                    cms::Session::AcknowledgeMode ackMode = cms::Session::AUTO_ACKNOWLEDGE);
+
         virtual ~CMSProvider();
 
         virtual void close();