Author: tabish
Date: Sun Mar 7 18:15:39 2010
New Revision: 920052
URL: http://svn.apache.org/viewvc?rev=920052&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-287
Compression Integration tests and a few fixes for issues found while testing.
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.cpp
(with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.h
(with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.cpp
(with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.h
(with props)
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.h
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/Makefile.am
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/TestRegistry.cpp
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp?rev=920052&r1=920051&r2=920052&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMapMessage.cpp
Sun Mar 7 18:15:39 2010
@@ -109,6 +109,7 @@
OutputStream* os = bytesOut;
if( this->connection != NULL &&
this->connection->isUseCompression() ) {
+ this->compressed = true;
os = new DeflaterOutputStream( os, true );
}
@@ -163,7 +164,7 @@
InputStream* is = new ByteArrayInputStream( getContent() );
- if( isCompressed() == true ) {
+ if( isCompressed() ) {
is = new InflaterInputStream( is, true );
is = new BufferedInputStream( is, true );
}
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h?rev=920052&r1=920051&r2=920052&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h
Sun Mar 7 18:15:39 2010
@@ -43,13 +43,9 @@
std::auto_ptr<wireformat::openwire::utils::MessagePropertyInterceptor>
propertiesInterceptor;
- protected:
-
- activemq::core::ActiveMQConnection* connection;
-
public:
- ActiveMQMessageTemplate() : commands::Message(), connection( NULL ) {
+ ActiveMQMessageTemplate() : commands::Message() {
this->propertiesInterceptor.reset(
new wireformat::openwire::utils::MessagePropertyInterceptor(
this, &this->getMessageProperties() ) );
@@ -57,14 +53,6 @@
virtual ~ActiveMQMessageTemplate() {}
- activemq::core::ActiveMQConnection* getConnection() const {
- return this->connection;
- }
-
- void setConnection( activemq::core::ActiveMQConnection* connection ) {
- this->connection = connection;
- }
-
public: // cms::Message related methods
/**
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.cpp?rev=920052&r1=920051&r2=920052&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.cpp
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.cpp
Sun Mar 7 18:15:39 2010
@@ -16,6 +16,8 @@
*/
#include <activemq/commands/Message.h>
+#include <activemq/core/ActiveMQAckHandler.h>
+#include <activemq/core/ActiveMQConnection.h>
#include <activemq/exceptions/ActiveMQException.h>
#include <activemq/state/CommandVisitor.h>
#include <activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h>
@@ -45,6 +47,7 @@
this->readOnlyBody = false;
this->readOnlyProperties = false;
+ this->connection = NULL;
this->groupID = "";
this->groupSequence = 0;
this->correlationId = "";
@@ -129,6 +132,7 @@
this->setAckHandler( srcPtr->getAckHandler() );
this->setReadOnlyBody( srcPtr->isReadOnlyBody() );
this->setReadOnlyProperties( srcPtr->isReadOnlyProperties() );
+ this->setConnection( srcPtr->getConnection() );
}
////////////////////////////////////////////////////////////////////////////////
@@ -283,15 +287,6 @@
stream << "BrokerInTime = " << this->getBrokerInTime();
stream << ", ";
stream << "BrokerOutTime = " << this->getBrokerOutTime();
-
- stream << ", ";
- stream << " ackHandler = " << ackHandler.get() << std::endl;
- stream << ", ";
- stream << " properties = " << this->properties.toString() << std::endl;
- stream << ", ";
- stream << " readOnlyBody = " << this->readOnlyBody << std::endl;
- stream << ", ";
- stream << " readOnlyProperties = " << this->readOnlyBody << std::endl;
stream << " }";
return stream.str();
@@ -847,7 +842,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-decaf::lang::Pointer<commands::Command> Message::visit(
activemq::state::CommandVisitor* visitor )
+decaf::lang::Pointer<commands::Command> Message::visit(
activemq::state::CommandVisitor* visitor )
throw( activemq::exceptions::ActiveMQException ) {
return visitor->processMessage( this );
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.h?rev=920052&r1=920051&r2=920052&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.h
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/Message.h
Sun Mar 7 18:15:39 2010
@@ -41,6 +41,7 @@
namespace activemq{
namespace core{
class ActiveMQAckHandler;
+ class ActiveMQConnection;
}
namespace commands{
@@ -74,6 +75,8 @@
protected:
+ core::ActiveMQConnection* connection;
+
static const unsigned int DEFAULT_MESSAGE_SIZE = 1024;
protected:
@@ -204,6 +207,24 @@
}
/**
+ * Sets the ActiveMQConnection instance that this Command was created
from
+ * when the session create methods are called to create a Message..
+ * @param handler ActiveMQConnection parent for this message
+ */
+ void setConnection( core::ActiveMQConnection* connection ) {
+ this->connection = connection;
+ }
+
+ /**
+ * Gets the ActiveMQConnection instance that this Command was created
from
+ * when the session create methods are called to create a Message..
+ * @returns the ActiveMQConnection parent for this Message or NULL if
not set.
+ */
+ core::ActiveMQConnection* getConnection() const {
+ return this->connection;
+ }
+
+ /**
* Returns the Size of this message in Bytes.
* @returns number of bytes this message equates to.
*/
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=920052&r1=920051&r2=920052&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
Sun Mar 7 18:15:39 2010
@@ -22,6 +22,7 @@
activemq/test/DurableTest.cpp \
activemq/test/ExpirationTest.cpp \
activemq/test/JmsMessageGroupsTest.cpp \
+ activemq/test/MessageCompressionTest.cpp \
activemq/test/SimpleRollbackTest.cpp \
activemq/test/SimpleTest.cpp \
activemq/test/SlowListenerTest.cpp \
@@ -34,6 +35,7 @@
activemq/test/openwire/OpenwireExpirationTest.cpp \
activemq/test/openwire/OpenwireIndividualAckTest.cpp \
activemq/test/openwire/OpenwireJmsMessageGroupsTest.cpp \
+ activemq/test/openwire/OpenwireMessageCompressionTest.cpp \
activemq/test/openwire/OpenwireSimpleRollbackTest.cpp \
activemq/test/openwire/OpenwireSimpleTest.cpp \
activemq/test/openwire/OpenwireSlowListenerTest.cpp \
@@ -63,6 +65,7 @@
activemq/test/DurableTest.h \
activemq/test/ExpirationTest.h \
activemq/test/JmsMessageGroupsTest.h \
+ activemq/test/MessageCompressionTest.h \
activemq/test/SimpleRollbackTest.h \
activemq/test/SimpleTest.h \
activemq/test/SlowListenerTest.h \
@@ -75,6 +78,7 @@
activemq/test/openwire/OpenwireExpirationTest.h \
activemq/test/openwire/OpenwireIndividualAckTest.h \
activemq/test/openwire/OpenwireJmsMessageGroupsTest.h \
+ activemq/test/openwire/OpenwireMessageCompressionTest.h \
activemq/test/openwire/OpenwireSimpleRollbackTest.h \
activemq/test/openwire/OpenwireSimpleTest.h \
activemq/test/openwire/OpenwireSlowListenerTest.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=920052&r1=920051&r2=920052&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
Sun Mar 7 18:15:39 2010
@@ -21,6 +21,7 @@
#include "activemq/test/openwire/OpenwireDurableTest.h"
#include "activemq/test/openwire/OpenwireExpirationTest.h"
#include "activemq/test/openwire/OpenwireIndividualAckTest.h"
+#include "activemq/test/openwire/OpenwireMessageCompressionTest.h"
#include "activemq/test/openwire/OpenwireSimpleRollbackTest.h"
#include "activemq/test/openwire/OpenwireSimpleTest.h"
#include "activemq/test/openwire/OpenwireTransactionTest.h"
@@ -40,19 +41,20 @@
#include "activemq/test/stomp/StompJmsMessageGroupsTest.h"
// Openwire Tests
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireAsyncSenderTest );
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireClientAckTest );
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireCmsTemplateTest );
-CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireDurableTest
);
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireExpirationTest );
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireIndividualAckTest );
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireSimpleRollbackTest );
-CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireSimpleTest
);
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireTransactionTest );
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireSlowListenerTest );
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireTempDestinationTest );
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireJmsMessageGroupsTest );
-CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireVirtualTopicTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireAsyncSenderTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireClientAckTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireCmsTemplateTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireDurableTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireExpirationTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireIndividualAckTest );
+CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireMessageCompressionTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireSimpleRollbackTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireSimpleTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireTransactionTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireSlowListenerTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireTempDestinationTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireJmsMessageGroupsTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION(
activemq::test::openwire::OpenwireVirtualTopicTest );
// Stomp Tests
//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompAsyncSenderTest
);
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.cpp?rev=920052&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.cpp
(added)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.cpp
Sun Mar 7 18:15:39 2010
@@ -0,0 +1,297 @@
+/*
+ * 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 "MessageCompressionTest.h"
+
+#include <activemq/util/CMSListener.h>
+#include <activemq/exceptions/ActiveMQException.h>
+#include <activemq/core/ActiveMQConnection.h>
+#include <activemq/commands/Message.h>
+
+#include <decaf/lang/Thread.h>
+#include <decaf/util/UUID.h>
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::commands;
+using namespace activemq::core;
+using namespace activemq::test;
+using namespace activemq::util;
+using namespace activemq::exceptions;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace{
+
+ string TEST_CLIENT_ID = "MessageCompressionTestClientId";
+ string DESTINATION_NAME = "MessageCompressionTestDest";
+
+ // The following text should compress well
+ const string TEXT = std::string()
+ + "The quick red fox jumped over the lazy brown dog. " +
"The quick red fox jumped over the lazy brown dog. "
+ + "The quick red fox jumped over the lazy brown dog. " +
"The quick red fox jumped over the lazy brown dog. "
+ + "The quick red fox jumped over the lazy brown dog. " +
"The quick red fox jumped over the lazy brown dog. "
+ + "The quick red fox jumped over the lazy brown dog. " +
"The quick red fox jumped over the lazy brown dog. "
+ + "The quick red fox jumped over the lazy brown dog. " +
"The quick red fox jumped over the lazy brown dog. "
+ + "The quick red fox jumped over the lazy brown dog. " +
"The quick red fox jumped over the lazy brown dog. "
+ + "The quick red fox jumped over the lazy brown dog. " +
"The quick red fox jumped over the lazy brown dog. "
+ + "The quick red fox jumped over the lazy brown dog. " +
"The quick red fox jumped over the lazy brown dog. "
+ + "The quick red fox jumped over the lazy brown dog. ";
+
+ bool a = true;
+ unsigned char b = 123;
+ char c = 'c';
+ short d = 0x1234;
+ int e = 0x12345678;
+ long long f = 0x1234567812345678;
+ string g = "Hello World!";
+ bool h = false;
+ unsigned char i = 0xFF;
+ short j = -0x1234;
+ int k = -0x12345678;
+ long long l = -0x1234567812345678;
+ float m = 2.1F;
+ double n = 2.3;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+MessageCompressionTest::MessageCompressionTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+MessageCompressionTest::~MessageCompressionTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageCompressionTest::testTextMessageCompression() {
+
+ ActiveMQConnection* connection =
+ dynamic_cast<ActiveMQConnection*>( this->cmsProvider->getConnection()
);
+
+ CPPUNIT_ASSERT( connection != NULL );
+ CPPUNIT_ASSERT_MESSAGE( "Compression not enabled.",
connection->isUseCompression() );
+
+ Session* session = this->cmsProvider->getSession();
+
+ std::auto_ptr<TextMessage> sent( session->createTextMessage( TEXT ) );
+
+ cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+ cms::MessageProducer* producer = cmsProvider->getProducer();
+ producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+ // Send some text messages
+ producer->send( sent.get() );
+
+ auto_ptr<cms::Message> message( consumer->receive( 2000 ) );
+ CPPUNIT_ASSERT( message.get() != NULL );
+
+ TextMessage* recvd = dynamic_cast<TextMessage*>( message.get() );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not a TextMessage", recvd !=
NULL );
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Received text differs from sent text.",
+ sent->getText(), recvd->getText() );
+
+ commands::Message* amqMsg = dynamic_cast<commands::Message*>(
message.get() );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not an AMQ message type",
amqMsg != NULL );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not compressed.",
amqMsg->isCompressed() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageCompressionTest::testBytesMessageCompression() {
+
+ ActiveMQConnection* connection =
+ dynamic_cast<ActiveMQConnection*>( this->cmsProvider->getConnection()
);
+
+ CPPUNIT_ASSERT( connection != NULL );
+ CPPUNIT_ASSERT_MESSAGE( "Compression not enabled.",
connection->isUseCompression() );
+
+ Session* session = this->cmsProvider->getSession();
+
+ std::auto_ptr<BytesMessage> sent( session->createBytesMessage() );
+
+ cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+ cms::MessageProducer* producer = cmsProvider->getProducer();
+ producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+ sent->writeBoolean( a );
+ sent->writeByte( b );
+ sent->writeChar( c );
+ sent->writeShort( d );
+ sent->writeInt( e );
+ sent->writeLong( f );
+ sent->writeString( g );
+ sent->writeBoolean( h );
+ sent->writeByte( i );
+ sent->writeShort( j );
+ sent->writeInt( k );
+ sent->writeLong( l );
+ sent->writeFloat( m );
+ sent->writeDouble( n );
+
+ // Send some text messages
+ producer->send( sent.get() );
+
+ auto_ptr<cms::Message> message( consumer->receive( 2000 ) );
+ CPPUNIT_ASSERT( message.get() != NULL );
+
+ BytesMessage* recvd = dynamic_cast<BytesMessage*>( message.get() );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not a BytesMessage", recvd
!= NULL );
+
+ CPPUNIT_ASSERT_EQUAL( a, recvd->readBoolean() );
+ CPPUNIT_ASSERT_EQUAL( b, recvd->readByte() );
+ CPPUNIT_ASSERT_EQUAL( c, recvd->readChar() );
+ CPPUNIT_ASSERT_EQUAL( d, recvd->readShort() );
+ CPPUNIT_ASSERT_EQUAL( e, recvd->readInt() );
+ CPPUNIT_ASSERT_EQUAL( f, recvd->readLong() );
+ CPPUNIT_ASSERT_EQUAL( g, recvd->readString() );
+ CPPUNIT_ASSERT_EQUAL( h, recvd->readBoolean() );
+ CPPUNIT_ASSERT_EQUAL( i, recvd->readByte() );
+ CPPUNIT_ASSERT_EQUAL( j, recvd->readShort() );
+ CPPUNIT_ASSERT_EQUAL( k, recvd->readInt() );
+ CPPUNIT_ASSERT_EQUAL( l, recvd->readLong() );
+ CPPUNIT_ASSERT_EQUAL( m, recvd->readFloat() );
+ CPPUNIT_ASSERT_EQUAL( n, recvd->readDouble() );
+
+ commands::Message* amqMsg = dynamic_cast<commands::Message*>(
message.get() );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not an AMQ message type",
amqMsg != NULL );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not compressed.",
amqMsg->isCompressed() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageCompressionTest::testStreamMessageCompression() {
+
+ ActiveMQConnection* connection =
+ dynamic_cast<ActiveMQConnection*>( this->cmsProvider->getConnection()
);
+
+ CPPUNIT_ASSERT( connection != NULL );
+ CPPUNIT_ASSERT_MESSAGE( "Compression not enabled.",
connection->isUseCompression() );
+
+ Session* session = this->cmsProvider->getSession();
+
+ std::auto_ptr<StreamMessage> sent( session->createStreamMessage() );
+
+ cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+ cms::MessageProducer* producer = cmsProvider->getProducer();
+ producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+ sent->writeBoolean( a );
+ sent->writeByte( b );
+ sent->writeChar( c );
+ sent->writeShort( d );
+ sent->writeInt( e );
+ sent->writeLong( f );
+ sent->writeString( g );
+ sent->writeBoolean( h );
+ sent->writeByte( i );
+ sent->writeShort( j );
+ sent->writeInt( k );
+ sent->writeLong( l );
+ sent->writeFloat( m );
+ sent->writeDouble( n );
+
+ // Send some text messages
+ producer->send( sent.get() );
+
+ auto_ptr<cms::Message> message( consumer->receive( 2000 ) );
+ CPPUNIT_ASSERT( message.get() != NULL );
+
+ StreamMessage* recvd = dynamic_cast<StreamMessage*>( message.get() );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not a StreamMessage", recvd
!= NULL );
+
+ CPPUNIT_ASSERT_EQUAL( a, recvd->readBoolean() );
+ CPPUNIT_ASSERT_EQUAL( b, recvd->readByte() );
+ CPPUNIT_ASSERT_EQUAL( c, recvd->readChar() );
+ CPPUNIT_ASSERT_EQUAL( d, recvd->readShort() );
+ CPPUNIT_ASSERT_EQUAL( e, recvd->readInt() );
+ CPPUNIT_ASSERT_EQUAL( f, recvd->readLong() );
+ CPPUNIT_ASSERT_EQUAL( g, recvd->readString() );
+ CPPUNIT_ASSERT_EQUAL( h, recvd->readBoolean() );
+ CPPUNIT_ASSERT_EQUAL( i, recvd->readByte() );
+ CPPUNIT_ASSERT_EQUAL( j, recvd->readShort() );
+ CPPUNIT_ASSERT_EQUAL( k, recvd->readInt() );
+ CPPUNIT_ASSERT_EQUAL( l, recvd->readLong() );
+ CPPUNIT_ASSERT_EQUAL( m, recvd->readFloat() );
+ CPPUNIT_ASSERT_EQUAL( n, recvd->readDouble() );
+
+ commands::Message* amqMsg = dynamic_cast<commands::Message*>(
message.get() );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not an AMQ message type",
amqMsg != NULL );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not compressed.",
amqMsg->isCompressed() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageCompressionTest::testMapMessageCompression() {
+
+ ActiveMQConnection* connection =
+ dynamic_cast<ActiveMQConnection*>( this->cmsProvider->getConnection()
);
+
+ CPPUNIT_ASSERT( connection != NULL );
+ CPPUNIT_ASSERT_MESSAGE( "Compression not enabled.",
connection->isUseCompression() );
+
+ Session* session = this->cmsProvider->getSession();
+
+ std::auto_ptr<MapMessage> sent( session->createMapMessage() );
+
+ cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+ cms::MessageProducer* producer = cmsProvider->getProducer();
+ producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+ sent->setBoolean( "a", a );
+ sent->setByte( "b", b );
+ sent->setChar( "c", c );
+ sent->setShort( "d", d );
+ sent->setInt( "e", e );
+ sent->setLong( "f", f );
+ sent->setString( "g", g );
+ sent->setBoolean( "h", h );
+ sent->setByte( "i", i );
+ sent->setShort( "j", j );
+ sent->setInt( "k", k );
+ sent->setLong( "l", l );
+ sent->setFloat( "m", m );
+ sent->setDouble( "n", n );
+
+ // Send some text messages
+ producer->send( sent.get() );
+
+ auto_ptr<cms::Message> message( consumer->receive( 2000 ) );
+ CPPUNIT_ASSERT( message.get() != NULL );
+
+ MapMessage* recvd = dynamic_cast<MapMessage*>( message.get() );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not a MapMessage", recvd !=
NULL );
+
+ CPPUNIT_ASSERT_EQUAL( a, recvd->getBoolean( "a" ) );
+ CPPUNIT_ASSERT_EQUAL( b, recvd->getByte( "b" ) );
+ CPPUNIT_ASSERT_EQUAL( c, recvd->getChar( "c" ) );
+ CPPUNIT_ASSERT_EQUAL( d, recvd->getShort( "d" ) );
+ CPPUNIT_ASSERT_EQUAL( e, recvd->getInt( "e" ) );
+ CPPUNIT_ASSERT_EQUAL( f, recvd->getLong( "f" ) );
+ CPPUNIT_ASSERT_EQUAL( g, recvd->getString( "g" ) );
+ CPPUNIT_ASSERT_EQUAL( h, recvd->getBoolean( "h" ) );
+ CPPUNIT_ASSERT_EQUAL( i, recvd->getByte( "i" ) );
+ CPPUNIT_ASSERT_EQUAL( j, recvd->getShort( "j" ) );
+ CPPUNIT_ASSERT_EQUAL( k, recvd->getInt( "k" ) );
+ CPPUNIT_ASSERT_EQUAL( l, recvd->getLong( "l" ) );
+ CPPUNIT_ASSERT_EQUAL( m, recvd->getFloat( "m" ) );
+ CPPUNIT_ASSERT_EQUAL( n, recvd->getDouble( "n" ) );
+
+ commands::Message* amqMsg = dynamic_cast<commands::Message*>(
message.get() );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not an AMQ message type",
amqMsg != NULL );
+ CPPUNIT_ASSERT_MESSAGE( "Received message was not compressed.",
amqMsg->isCompressed() );
+}
Propchange:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.h?rev=920052&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.h
(added)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.h
Sun Mar 7 18:15:39 2010
@@ -0,0 +1,42 @@
+/*
+ * 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_MESSAGECOMPRESSIONTEST_H_
+#define _ACTIVEMQ_TEST_MESSAGECOMPRESSIONTEST_H_
+
+#include <activemq/test/CMSTestFixture.h>
+#include <activemq/util/IntegrationCommon.h>
+
+namespace activemq {
+namespace test {
+
+ class MessageCompressionTest : public CMSTestFixture {
+ public:
+
+ MessageCompressionTest();
+ virtual ~MessageCompressionTest();
+
+ void testTextMessageCompression();
+ void testBytesMessageCompression();
+ void testStreamMessageCompression();
+ void testMapMessageCompression();
+
+ };
+
+}}
+
+#endif /* _ACTIVEMQ_TEST_MESSAGECOMPRESSIONTEST_H_ */
Propchange:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/MessageCompressionTest.h
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.cpp?rev=920052&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.cpp
(added)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.cpp
Sun Mar 7 18:15:39 2010
@@ -0,0 +1,30 @@
+/*
+ * 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 "OpenwireMessageCompressionTest.h"
+
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::test::openwire;
+
+////////////////////////////////////////////////////////////////////////////////
+OpenwireMessageCompressionTest::OpenwireMessageCompressionTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+OpenwireMessageCompressionTest::~OpenwireMessageCompressionTest() {
+}
Propchange:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.h?rev=920052&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.h
(added)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.h
Sun Mar 7 18:15:39 2010
@@ -0,0 +1,51 @@
+/*
+ * 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_OPENWIRE_OPENWIREMESSAGECOMPRESSIONTEST_H_
+#define _ACTIVEMQ_TEST_OPENWIRE_OPENWIREMESSAGECOMPRESSIONTEST_H_
+
+#include <activemq/test/MessageCompressionTest.h>
+
+namespace activemq {
+namespace test {
+namespace openwire {
+
+ class OpenwireMessageCompressionTest : public MessageCompressionTest {
+ private:
+
+ CPPUNIT_TEST_SUITE( OpenwireMessageCompressionTest );
+ CPPUNIT_TEST( testTextMessageCompression );
+ CPPUNIT_TEST( testBytesMessageCompression );
+ CPPUNIT_TEST( testStreamMessageCompression );
+ CPPUNIT_TEST( testMapMessageCompression );
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ OpenwireMessageCompressionTest();
+ virtual ~OpenwireMessageCompressionTest();
+
+ virtual std::string getBrokerURL() const {
+ return
activemq::util::IntegrationCommon::getInstance().getOpenwireURL() +
+ "&connection.useCompression=true";
+ }
+
+ };
+
+}}}
+
+#endif /* _ACTIVEMQ_TEST_OPENWIRE_OPENWIREMESSAGECOMPRESSIONTEST_H_ */
Propchange:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireMessageCompressionTest.h
------------------------------------------------------------------------------
svn:eol-style = native