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 2015/08/05 00:19:57 UTC
activemq-cpp git commit: another round of warnings fixes.
Repository: activemq-cpp
Updated Branches:
refs/heads/master 4cbb7aacd -> 22408e32a
another round of warnings fixes.
Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/22408e32
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/22408e32
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/22408e32
Branch: refs/heads/master
Commit: 22408e32a87860d2b7caa9131810b6e525fbdcf9
Parents: 4cbb7aa
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Aug 4 18:19:45 2015 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Aug 4 18:19:45 2015 -0400
----------------------------------------------------------------------
.../examples/consumers/SimpleAsyncConsumer.cpp | 57 +-
.../internal/util/concurrent/Threading.cpp | 15 +-
.../src/main/decaf/net/HttpURLConnection.cpp | 2 +-
activemq-cpp/src/main/decaf/util/StlSet.h | 2 +-
.../main/decaf/util/concurrent/BlockingQueue.h | 10 +-
.../decaf/util/concurrent/SynchronousQueue.h | 64 ++-
.../util/concurrent/ThreadPoolExecutor.cpp | 2 +-
.../decaf/io/BufferedInputStreamBenchmark.cpp | 6 +-
.../decaf/io/ByteArrayInputStreamBenchmark.cpp | 4 +-
.../activemq/core/ActiveMQConnectionTest.cpp | 4 +
.../failover/FailoverTransportTest.cpp | 550 +++++++++----------
activemq-cpp/src/test/decaf/net/URLTest.cpp | 2 +
.../decaf/util/AbstractSequentialListTest.cpp | 21 +-
13 files changed, 378 insertions(+), 361 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp b/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
index 0aab559..6212103 100644
--- a/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
+++ b/activemq-cpp/src/examples/consumers/SimpleAsyncConsumer.cpp
@@ -62,15 +62,15 @@ private:
private:
- SimpleAsyncConsumer( const SimpleAsyncConsumer& );
- SimpleAsyncConsumer& operator= ( const SimpleAsyncConsumer& );
+ SimpleAsyncConsumer(const SimpleAsyncConsumer&);
+ SimpleAsyncConsumer& operator=(const SimpleAsyncConsumer&);
public:
- SimpleAsyncConsumer( const std::string& brokerURI,
- const std::string& destURI,
- bool useTopic = false,
- bool clientAck = false ) :
+ SimpleAsyncConsumer(const std::string& brokerURI,
+ const std::string& destURI,
+ bool useTopic = false,
+ bool clientAck = false) :
connection(NULL),
session(NULL),
destination(NULL),
@@ -94,16 +94,15 @@ public:
try {
// Create a ConnectionFactory
- ActiveMQConnectionFactory* connectionFactory =
- new ActiveMQConnectionFactory( brokerURI );
+ ActiveMQConnectionFactory* connectionFactory = new ActiveMQConnectionFactory(brokerURI);
// Create a Connection
connection = connectionFactory->createConnection();
delete connectionFactory;
- ActiveMQConnection* amqConnection = dynamic_cast<ActiveMQConnection*>( connection );
- if( amqConnection != NULL ) {
- amqConnection->addTransportListener( this );
+ ActiveMQConnection* amqConnection = dynamic_cast<ActiveMQConnection*>(connection);
+ if (amqConnection != NULL) {
+ amqConnection->addTransportListener(this);
}
connection->start();
@@ -111,22 +110,22 @@ public:
connection->setExceptionListener(this);
// Create a Session
- if( clientAck ) {
- session = connection->createSession( Session::CLIENT_ACKNOWLEDGE );
+ if (clientAck) {
+ session = connection->createSession(Session::CLIENT_ACKNOWLEDGE);
} else {
- session = connection->createSession( Session::AUTO_ACKNOWLEDGE );
+ session = connection->createSession(Session::AUTO_ACKNOWLEDGE);
}
// Create the destination (Topic or Queue)
- if( useTopic ) {
- destination = session->createTopic( destURI );
+ if (useTopic) {
+ destination = session->createTopic(destURI);
} else {
- destination = session->createQueue( destURI );
+ destination = session->createQueue(destURI);
}
// Create a MessageConsumer from the Session to the Topic or Queue
- consumer = session->createConsumer( destination );
- consumer->setMessageListener( this );
+ consumer = session->createConsumer(destination);
+ consumer->setMessageListener(this);
} catch (CMSException& e) {
e.printStackTrace();
@@ -134,28 +133,26 @@ public:
}
// Called from the consumer since this class is a registered MessageListener.
- virtual void onMessage( const Message* message ) {
+ virtual void onMessage(const Message* message) {
static int count = 0;
- try
- {
+ try {
count++;
- const TextMessage* textMessage =
- dynamic_cast< const TextMessage* >( message );
+ const TextMessage* textMessage = dynamic_cast<const TextMessage*>(message);
string text = "";
- if( textMessage != NULL ) {
+ if (textMessage != NULL) {
text = textMessage->getText();
} else {
text = "NOT A TEXTMESSAGE!";
}
- if( clientAck ) {
+ if (clientAck) {
message->acknowledge();
}
- printf( "Message #%d Received: %s\n", count, text.c_str() );
+ printf("Message #%d Received: %s\n", count, text.c_str());
} catch (CMSException& e) {
e.printStackTrace();
}
@@ -163,11 +160,15 @@ public:
// If something bad happens you see it here as this class is also been
// registered as an ExceptionListener with the connection.
- virtual void onException( const CMSException& ex AMQCPP_UNUSED ) {
+ virtual void onException(const CMSException& ex AMQCPP_UNUSED) {
printf("CMS Exception occurred. Shutting down client.\n");
exit(1);
}
+ virtual void onException(const decaf::lang::Exception& ex) {
+ printf("Transport Exception occurred: %s \n", ex.getMessage().c_str());
+ }
+
virtual void transportInterrupted() {
std::cout << "The Connection's Transport has been Interrupted." << std::endl;
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp b/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp
index 53d6c81..ab48db2 100644
--- a/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp
+++ b/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp
@@ -63,9 +63,11 @@ namespace {
SuspendedCompletionCondition(ThreadHandle* thread) : thread(thread) {}
- bool operator()() {
+ virtual bool operator()() {
return !thread->suspended;
}
+
+ using CompletionCondition::operator();
};
class MonitorWaitCompletionCondition : public CompletionCondition {
@@ -1104,6 +1106,9 @@ namespace {
return false;
}
+
+ using CompletionCondition::operator();
+
};
}
@@ -1219,6 +1224,9 @@ namespace {
return false;
}
+
+ using CompletionCondition::operator();
+
};
}
@@ -1354,7 +1362,7 @@ namespace {
ParkCompletionCondition(ThreadHandle* handle) : handle(handle) {}
- bool operator()() {
+ virtual bool operator()() {
if (handle->unparked == true) {
handle->unparked = false;
return true;
@@ -1364,6 +1372,9 @@ namespace {
return false;
}
+
+ using CompletionCondition::operator();
+
};
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/main/decaf/net/HttpURLConnection.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/net/HttpURLConnection.cpp b/activemq-cpp/src/main/decaf/net/HttpURLConnection.cpp
index 6c31b57..cd1d9a0 100644
--- a/activemq-cpp/src/main/decaf/net/HttpURLConnection.cpp
+++ b/activemq-cpp/src/main/decaf/net/HttpURLConnection.cpp
@@ -117,7 +117,7 @@ std::string HttpURLConnection::getResponseMessage() {
}
////////////////////////////////////////////////////////////////////////////////
-void HttpURLConnection::setRequestMethod(const std::string& method) {
+void HttpURLConnection::setRequestMethod(const std::string& method DECAF_UNUSED) {
if (connected) {
throw ProtocolException(__FILE__, __LINE__, "Connection already established");
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/main/decaf/util/StlSet.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/StlSet.h b/activemq-cpp/src/main/decaf/util/StlSet.h
index 62f844b..612545b 100644
--- a/activemq-cpp/src/main/decaf/util/StlSet.h
+++ b/activemq-cpp/src/main/decaf/util/StlSet.h
@@ -139,7 +139,7 @@ namespace util {
* Copy constructor - copies the content of the given set into this one.
* @param source The source set.
*/
- StlSet(const StlSet& source) : AbstractSet<E>(), values() {
+ StlSet(const StlSet& source) : AbstractCollection<E>(), AbstractSet<E>(), values() {
copy(source);
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/main/decaf/util/concurrent/BlockingQueue.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/concurrent/BlockingQueue.h b/activemq-cpp/src/main/decaf/util/concurrent/BlockingQueue.h
index efcf07f..78c1fd7 100644
--- a/activemq-cpp/src/main/decaf/util/concurrent/BlockingQueue.h
+++ b/activemq-cpp/src/main/decaf/util/concurrent/BlockingQueue.h
@@ -180,7 +180,7 @@ namespace concurrent {
* @throws IllegalArgumentException if some property of the specified
* element prevents it from being added to this queue
*/
- virtual void put( const E& value ) = 0;
+ virtual void put(const E& value) = 0;
/**
* Inserts the specified element into this queue, waiting up to the specified wait
@@ -200,7 +200,7 @@ namespace concurrent {
* @throws IllegalArgumentException if some property of the specified
* element prevents it from being added to this queue
*/
- virtual bool offer( const E& e, long long timeout, const TimeUnit& unit ) = 0;
+ virtual bool offer(const E& e, long long timeout, const TimeUnit& unit) = 0;
/**
* Retrieves and removes the head of this queue, waiting if necessary until an
@@ -224,7 +224,7 @@ namespace concurrent {
* waiting time elapses before an element is available.
* @throws InterruptedException if interrupted while waiting
*/
- virtual bool poll( E& result, long long timeout, const TimeUnit& unit ) = 0;
+ virtual bool poll(E& result, long long timeout, const TimeUnit& unit) = 0;
/**
* Returns the number of additional elements that this queue can ideally
@@ -259,7 +259,7 @@ namespace concurrent {
* queue, or some property of an element of this queue prevents
* it from being added to the specified collection
*/
- virtual int drainTo( Collection<E>& c ) = 0;
+ virtual int drainTo(Collection<E>& c) = 0;
/**
* Removes at most the given number of available elements from
@@ -281,7 +281,7 @@ namespace concurrent {
* queue, or some property of an element of this queue prevents
* it from being added to the specified collection
*/
- virtual int drainTo( Collection<E>& c, int maxElements ) = 0;
+ virtual int drainTo(Collection<E>& c, int maxElements) = 0;
};
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/main/decaf/util/concurrent/SynchronousQueue.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/concurrent/SynchronousQueue.h b/activemq-cpp/src/main/decaf/util/concurrent/SynchronousQueue.h
index 20c2c92..1194103 100644
--- a/activemq-cpp/src/main/decaf/util/concurrent/SynchronousQueue.h
+++ b/activemq-cpp/src/main/decaf/util/concurrent/SynchronousQueue.h
@@ -68,10 +68,9 @@ namespace concurrent {
public:
virtual E next() {
-
throw NoSuchElementException(
__FILE__, __LINE__,
- "Cannot traverse a Synchronous Queue." );
+ "Cannot traverse a Synchronous Queue.");
}
virtual bool hasNext() const {
@@ -79,21 +78,20 @@ namespace concurrent {
}
virtual void remove() {
-
throw lang::exceptions::IllegalStateException(
__FILE__, __LINE__,
- "No Elements to remove from a Synchronous Queue." );
+ "No Elements to remove from a Synchronous Queue.");
}
};
private:
- SynchronousQueue( const SynchronousQueue& );
- SynchronousQueue& operator= ( const SynchronousQueue& );
+ SynchronousQueue(const SynchronousQueue&);
+ SynchronousQueue& operator=(const SynchronousQueue&);
public:
- SynchronousQueue() {}
+ SynchronousQueue() : BlockingQueue<E>() {}
virtual ~SynchronousQueue() {}
@@ -107,7 +105,7 @@ namespace concurrent {
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
*/
- virtual void put( const E& value ) {
+ virtual void put(const E& value) {
//if (o == null) throw new NullPointerException();
//if (transferer.transfer(o, false, 0) == null) {
@@ -127,7 +125,7 @@ namespace concurrent {
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
*/
- virtual bool offer( const E& e, long long timeout, const TimeUnit& unit ) {
+ virtual bool offer(const E& e, long long timeout, const TimeUnit& unit) {
//if (o == null) throw new NullPointerException();
//if (transferer.transfer(o, true, unit.toNanos(timeout)) != null)
@@ -153,7 +151,7 @@ namespace concurrent {
* @throws IllegalArgumentException if some property of the specified
* element prevents it from being added to this queue
*/
- virtual bool offer( const E& value ) {
+ virtual bool offer(const E& value) {
//if (e == null) throw new NullPointerException();
//return transferer.transfer(e, true, 0) != null;
@@ -192,7 +190,7 @@ namespace concurrent {
* @return true if the head of the Queue was copied to the result param
* or false if no value could be returned.
*/
- virtual bool poll( E& result, long long timeout, const TimeUnit& unit ) {
+ virtual bool poll(E& result, long long timeout, const TimeUnit& unit) {
//Object e = transferer.transfer(null, true, unit.toNanos(timeout));
//if (e != null || !Thread.interrupted())
@@ -212,11 +210,11 @@ namespace concurrent {
* @return true if the head of the Queue was copied to the result param
* or false if no value could be returned.
*/
- virtual bool poll( E& result ) {
+ virtual bool poll(E& result) {
return false; // (E)transferer.transfer(null, true, 0);
}
- virtual bool equals( const Collection<E>& value ) const {
+ virtual bool equals(const Collection<E>& value) const {
if( (void*)&value == this ) {
return true;
}
@@ -246,70 +244,76 @@ namespace concurrent {
virtual void clear() {}
- virtual bool contains( const E& value DECAF_UNUSED ) const {
+ virtual bool contains(const E& value DECAF_UNUSED) const {
return false;
}
- virtual bool containsAll( const Collection<E>& collection ) const {
+ virtual bool containsAll(const Collection<E>& collection) const {
return collection.isEmpty();
}
- virtual bool remove( const E& value DECAF_UNUSED ) {
+ virtual bool remove(const E& value DECAF_UNUSED) {
return false;
}
- virtual bool removeAll( const Collection<E>& collection DECAF_UNUSED ) {
+ virtual bool removeAll(const Collection<E>& collection DECAF_UNUSED) {
return false;
}
- virtual bool retainAll( const Collection<E>& collection DECAF_UNUSED ) {
+ virtual bool retainAll(const Collection<E>& collection DECAF_UNUSED) {
return false;
}
- virtual bool peek( E& result DECAF_UNUSED ) const {
+ virtual bool peek(E& result DECAF_UNUSED) const {
return false;
}
- virtual std::vector<E> toArray() const { return std::vector<E>(); }
+ virtual std::vector<E> toArray() const {
+ return std::vector<E>();
+ }
- virtual int drainTo( Collection<E>& c ) {
+ virtual int drainTo(Collection<E>& c) {
- if( (void*)&c == this ) {
+ if ((void*) &c == this) {
throw decaf::lang::exceptions::IllegalArgumentException(
__FILE__, __LINE__,
- "Cannot drain a Collection to Itself." );
+ "Cannot drain a Collection to Itself.");
}
int count = 0;
E element;
- while( ( poll( element ) ) != false ) {
- c.add( element );
+ while ((poll(element)) != false) {
+ c.add(element);
++count;
}
return count;
}
- virtual int drainTo( Collection<E>& c, int maxElements ) {
+ virtual int drainTo(Collection<E>& c, int maxElements) {
- if( (void*)&c == this ) {
+ if ((void*) &c == this) {
throw decaf::lang::exceptions::IllegalArgumentException(
__FILE__, __LINE__,
- "Cannot drain a Collection to Itself." );
+ "Cannot drain a Collection to Itself.");
}
int count = 0;
E element;
- while( count < maxElements && ( poll( element ) != false ) ) {
- c.add( element );
+ while (count < maxElements && (poll(element) != false)) {
+ c.add(element);
++count;
}
return count;
}
+ public:
+
+ using AbstractQueue<E>::remove;
+
};
}}}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp b/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
index 819bc6e..e5c4236 100644
--- a/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
+++ b/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
@@ -201,7 +201,7 @@ namespace concurrent{
protected:
- virtual bool isHeldExclusively() {
+ virtual bool isHeldExclusively() const {
return getState() == 1;
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp b/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp
index 674a7c3..e327f3f 100644
--- a/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp
+++ b/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp
@@ -50,11 +50,11 @@ void BufferedInputStreamBenchmark::run() {
std::vector<unsigned char> bucket(bufferSize);
BufferedInputStream bis(&source);
- for (std::size_t iy = 0; iy < numRuns; ++iy) {
+ for (int iy = 0; iy < numRuns; ++iy) {
BufferedInputStream local(&source);
}
- for (std::size_t iy = 0; iy < numRuns; ++iy) {
+ for (int iy = 0; iy < numRuns; ++iy) {
for (int iz = 0; iz < bufferSize; ++iz) {
bucket[iy] = (unsigned char) bis.read();
@@ -62,7 +62,7 @@ void BufferedInputStreamBenchmark::run() {
source.reset();
}
- for (std::size_t iy = 0; iy < numRuns; ++iy) {
+ for (int iy = 0; iy < numRuns; ++iy) {
bis.read(&bucket[0], bufferSize, 0, bufferSize);
source.reset();
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayInputStreamBenchmark.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayInputStreamBenchmark.cpp b/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayInputStreamBenchmark.cpp
index c0d824c..454db02 100755
--- a/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayInputStreamBenchmark.cpp
+++ b/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayInputStreamBenchmark.cpp
@@ -63,7 +63,7 @@ void ByteArrayInputStreamBenchmark::run() {
ByteArrayInputStream local(buffer, bufferSize);
}
- for (std::size_t iy = 0; iy < numRuns; ++iy) {
+ for (int iy = 0; iy < numRuns; ++iy) {
for (std::size_t iz = 0; iz < bufferSize; ++iz) {
bucket[iy] = (unsigned char) bis.read();
@@ -71,7 +71,7 @@ void ByteArrayInputStreamBenchmark::run() {
bis.reset();
}
- for (std::size_t iy = 0; iy < numRuns; ++iy) {
+ for (int iy = 0; iy < numRuns; ++iy) {
bis.read(&bucket[0], bufferSize, 0, bufferSize);
bis.reset();
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/test/activemq/core/ActiveMQConnectionTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/activemq/core/ActiveMQConnectionTest.cpp b/activemq-cpp/src/test/activemq/core/ActiveMQConnectionTest.cpp
index fb7964f..6807ec7 100644
--- a/activemq-cpp/src/test/activemq/core/ActiveMQConnectionTest.cpp
+++ b/activemq-cpp/src/test/activemq/core/ActiveMQConnectionTest.cpp
@@ -63,6 +63,10 @@ namespace core {
virtual ~MyCommandListener() {}
+ virtual void onCommand(const Pointer<Command> command) {
+ cmd = command.get();
+ }
+
virtual void onCommand(commands::Command* command) {
cmd = command;
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/test/activemq/transport/failover/FailoverTransportTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/activemq/transport/failover/FailoverTransportTest.cpp b/activemq-cpp/src/test/activemq/transport/failover/FailoverTransportTest.cpp
index 54802df..bc3f04f 100644
--- a/activemq-cpp/src/test/activemq/transport/failover/FailoverTransportTest.cpp
+++ b/activemq-cpp/src/test/activemq/transport/failover/FailoverTransportTest.cpp
@@ -55,20 +55,20 @@ void FailoverTransportTest::testTransportCreate() {
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
transport->start();
- Thread::sleep( 1000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
+ Thread::sleep(1000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
transport->close();
}
@@ -81,21 +81,21 @@ void FailoverTransportTest::testTransportCreateWithBackups() {
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
- CPPUNIT_ASSERT( failover->isBackup() == true );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
+ CPPUNIT_ASSERT(failover->isBackup() == true);
transport->start();
- Thread::sleep( 1000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
+ Thread::sleep(1000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
transport->close();
}
@@ -106,9 +106,9 @@ public:
bool caughtException;
- FailToConnectListener() : caughtException( false ) {}
+ FailToConnectListener() : caughtException(false) {}
- virtual void onException( const decaf::lang::Exception& ex AMQCPP_UNUSED ) {
+ virtual void onException(const decaf::lang::Exception& ex AMQCPP_UNUSED) {
caughtException = true;
}
};
@@ -117,27 +117,27 @@ public:
void FailoverTransportTest::testTransportCreateFailOnCreate() {
std::string uri =
- "failover://(mock://localhost:61616?failOnCreate=true)?useExponentialBackOff=false&maxReconnectAttempts=3&initialReconnectDelay=100";
+ "failover://(mock://localhost:61616?failOnCreate=true)?useExponentialBackOff=false&maxReconnectAttempts=3&initialReconnectDelay=100";
FailToConnectListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->getMaxReconnectAttempts() == 3 );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->getMaxReconnectAttempts() == 3);
transport->start();
- Thread::sleep( 1000 );
+ Thread::sleep(1000);
- CPPUNIT_ASSERT( listener.caughtException == true );
- CPPUNIT_ASSERT( failover->isConnected() == false );
+ CPPUNIT_ASSERT(listener.caughtException == true);
+ CPPUNIT_ASSERT(failover->isConnected() == false);
transport->close();
}
@@ -146,31 +146,28 @@ void FailoverTransportTest::testTransportCreateFailOnCreate() {
void FailoverTransportTest::testTransportCreateFailOnCreateSendMessage() {
std::string uri =
- "failover://(mock://localhost:61616?failOnCreate=true)?useExponentialBackOff=false&maxReconnectAttempts=3&initialReconnectDelay=100";
+ "failover://(mock://localhost:61616?failOnCreate=true)?useExponentialBackOff=false&maxReconnectAttempts=3&initialReconnectDelay=100";
- Pointer<ActiveMQMessage> message( new ActiveMQMessage() );
+ Pointer<ActiveMQMessage> message(new ActiveMQMessage());
FailToConnectListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->getMaxReconnectAttempts() == 3 );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->getMaxReconnectAttempts() == 3);
transport->start();
- CPPUNIT_ASSERT_THROW_MESSAGE(
- "Should Throw a IOException",
- transport->oneway( message ),
- IOException );
+ CPPUNIT_ASSERT_THROW_MESSAGE("Should Throw a IOException", transport->oneway(message), IOException);
- CPPUNIT_ASSERT( listener.caughtException == true );
+ CPPUNIT_ASSERT(listener.caughtException == true);
transport->close();
}
@@ -178,28 +175,27 @@ void FailoverTransportTest::testTransportCreateFailOnCreateSendMessage() {
////////////////////////////////////////////////////////////////////////////////
void FailoverTransportTest::testFailingBackupCreation() {
- std::string uri =
- "failover://(mock://localhost:61616,"
- "mock://localhost:61618?failOnCreate=true)?randomize=false&backup=true";
+ std::string uri = "failover://(mock://localhost:61616,"
+ "mock://localhost:61618?failOnCreate=true)?randomize=false&backup=true";
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
- CPPUNIT_ASSERT( failover->isBackup() == true );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
+ CPPUNIT_ASSERT(failover->isBackup() == true);
transport->start();
- Thread::sleep( 2000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
+ Thread::sleep(2000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
transport->close();
}
@@ -210,9 +206,9 @@ public:
int numMessages;
- MessageCountingListener() : numMessages( 0 ) {}
+ MessageCountingListener() : numMessages(0) {}
- virtual void onCommand( const Pointer<Command>& command AMQCPP_UNUSED ) {
+ virtual void onCommand(const Pointer<Command> command AMQCPP_UNUSED) {
numMessages++;
}
};
@@ -223,40 +219,40 @@ void FailoverTransportTest::testSendOnewayMessage() {
std::string uri = "failover://(mock://localhost:61616)?randomize=false";
const int numMessages = 1000;
- Pointer<ActiveMQMessage> message( new ActiveMQMessage() );
+ Pointer<ActiveMQMessage> message(new ActiveMQMessage());
MessageCountingListener messageCounter;
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
transport->start();
- Thread::sleep( 1000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
+ Thread::sleep(1000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
MockTransport* mock = NULL;
- while( mock == NULL ) {
- mock = dynamic_cast<MockTransport*>( transport->narrow( typeid( MockTransport ) ) );
+ while (mock == NULL) {
+ mock = dynamic_cast<MockTransport*>(transport->narrow(typeid(MockTransport)));
}
- mock->setOutgoingListener( &messageCounter );
+ mock->setOutgoingListener(&messageCounter);
- for( int i = 0; i < numMessages; ++i ) {
- transport->oneway( message );
+ for (int i = 0; i < numMessages; ++i) {
+ transport->oneway(message);
}
- Thread::sleep( 2000 );
+ Thread::sleep(2000);
- CPPUNIT_ASSERT( messageCounter.numMessages = numMessages );
+ CPPUNIT_ASSERT(messageCounter.numMessages = numMessages);
transport->close();
}
@@ -266,40 +262,40 @@ void FailoverTransportTest::testSendRequestMessage() {
std::string uri = "failover://(mock://localhost:61616)?randomize=false";
- Pointer<ActiveMQMessage> message( new ActiveMQMessage() );
+ Pointer<ActiveMQMessage> message(new ActiveMQMessage());
MessageCountingListener messageCounter;
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
transport->start();
- Thread::sleep( 1000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
+ Thread::sleep(1000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
MockTransport* mock = NULL;
- while( mock == NULL ) {
- mock = dynamic_cast<MockTransport*>( transport->narrow( typeid( MockTransport ) ) );
+ while (mock == NULL) {
+ mock = dynamic_cast<MockTransport*>(transport->narrow(typeid(MockTransport)));
}
- mock->setOutgoingListener( &messageCounter );
+ mock->setOutgoingListener(&messageCounter);
- transport->request( message );
- transport->request( message );
- transport->request( message );
- transport->request( message );
- Thread::sleep( 1000 );
+ transport->request(message);
+ transport->request(message);
+ transport->request(message);
+ transport->request(message);
+ Thread::sleep(1000);
- CPPUNIT_ASSERT( messageCounter.numMessages = 4 );
+ CPPUNIT_ASSERT(messageCounter.numMessages = 4);
transport->close();
}
@@ -307,44 +303,43 @@ void FailoverTransportTest::testSendRequestMessage() {
////////////////////////////////////////////////////////////////////////////////
void FailoverTransportTest::testSendOnewayMessageFail() {
- std::string uri =
- "failover://(mock://localhost:61616?failOnSendMessage=true,"
- "mock://localhost:61618)?randomize=false";
+ std::string uri = "failover://(mock://localhost:61616?failOnSendMessage=true,"
+ "mock://localhost:61618)?randomize=false";
- Pointer<ActiveMQMessage> message( new ActiveMQMessage() );
+ Pointer<ActiveMQMessage> message(new ActiveMQMessage());
MessageCountingListener messageCounter;
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
transport->start();
- Thread::sleep( 1000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
+ Thread::sleep(1000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
MockTransport* mock = NULL;
- while( mock == NULL ) {
- mock = dynamic_cast<MockTransport*>( transport->narrow( typeid( MockTransport ) ) );
+ while (mock == NULL) {
+ mock = dynamic_cast<MockTransport*>(transport->narrow(typeid(MockTransport)));
}
- mock->setOutgoingListener( &messageCounter );
+ mock->setOutgoingListener(&messageCounter);
- transport->oneway( message );
- transport->oneway( message );
- transport->oneway( message );
- transport->oneway( message );
- Thread::sleep( 1000 );
+ transport->oneway(message);
+ transport->oneway(message);
+ transport->oneway(message);
+ transport->oneway(message);
+ Thread::sleep(1000);
- CPPUNIT_ASSERT( messageCounter.numMessages = 4 );
+ CPPUNIT_ASSERT(messageCounter.numMessages = 4);
transport->close();
}
@@ -352,44 +347,43 @@ void FailoverTransportTest::testSendOnewayMessageFail() {
////////////////////////////////////////////////////////////////////////////////
void FailoverTransportTest::testSendRequestMessageFail() {
- std::string uri =
- "failover://(mock://localhost:61616?failOnSendMessage=true,"
- "mock://localhost:61618)?randomize=false";
+ std::string uri = "failover://(mock://localhost:61616?failOnSendMessage=true,"
+ "mock://localhost:61618)?randomize=false";
- Pointer<ActiveMQMessage> message( new ActiveMQMessage() );
+ Pointer<ActiveMQMessage> message(new ActiveMQMessage());
MessageCountingListener messageCounter;
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
transport->start();
- Thread::sleep( 1000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
+ Thread::sleep(1000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
MockTransport* mock = NULL;
- while( mock == NULL ) {
- mock = dynamic_cast<MockTransport*>( transport->narrow( typeid( MockTransport ) ) );
+ while (mock == NULL) {
+ mock = dynamic_cast<MockTransport*>(transport->narrow(typeid(MockTransport)));
}
- mock->setOutgoingListener( &messageCounter );
+ mock->setOutgoingListener(&messageCounter);
- transport->request( message );
- transport->request( message );
- transport->request( message );
- transport->request( message );
- Thread::sleep( 1000 );
+ transport->request(message);
+ transport->request(message);
+ transport->request(message);
+ transport->request(message);
+ Thread::sleep(1000);
- CPPUNIT_ASSERT( messageCounter.numMessages = 4 );
+ CPPUNIT_ASSERT(messageCounter.numMessages = 4);
transport->close();
}
@@ -402,52 +396,52 @@ void FailoverTransportTest::testWithOpewireCommands() {
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
transport->start();
- Thread::sleep( 1000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
+ Thread::sleep(1000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
Pointer<ConnectionInfo> connection = createConnection();
- transport->request( connection );
- Pointer<SessionInfo> session1 = createSession( connection );
- transport->request( session1 );
- Pointer<SessionInfo> session2 = createSession( connection );
- transport->request( session2 );
- Pointer<ConsumerInfo> consumer1 = createConsumer( session1 );
- transport->request( consumer1 );
- Pointer<ConsumerInfo> consumer2 = createConsumer( session1 );
- transport->request( consumer2 );
- Pointer<ConsumerInfo> consumer3 = createConsumer( session2 );
- transport->request( consumer3 );
-
- Pointer<ProducerInfo> producer1 = createProducer( session2 );
- transport->request( producer1 );
+ transport->request(connection);
+ Pointer<SessionInfo> session1 = createSession(connection);
+ transport->request(session1);
+ Pointer<SessionInfo> session2 = createSession(connection);
+ transport->request(session2);
+ Pointer<ConsumerInfo> consumer1 = createConsumer(session1);
+ transport->request(consumer1);
+ Pointer<ConsumerInfo> consumer2 = createConsumer(session1);
+ transport->request(consumer2);
+ Pointer<ConsumerInfo> consumer3 = createConsumer(session2);
+ transport->request(consumer3);
+
+ Pointer<ProducerInfo> producer1 = createProducer(session2);
+ transport->request(producer1);
// Remove the Producers
- this->disposeOf( producer1, transport );
+ this->disposeOf(producer1, transport);
// Remove the Consumers
- this->disposeOf( consumer1, transport );
- this->disposeOf( consumer2, transport );
- this->disposeOf( consumer3, transport );
+ this->disposeOf(consumer1, transport);
+ this->disposeOf(consumer2, transport);
+ this->disposeOf(consumer3, transport);
// Remove the Session instances.
- this->disposeOf( session1, transport );
- this->disposeOf( session2, transport );
+ this->disposeOf(session1, transport);
+ this->disposeOf(session2, transport);
// Indicate that we are done.
- Pointer<ShutdownInfo> shutdown( new ShutdownInfo() );
- transport->oneway( shutdown );
+ Pointer<ShutdownInfo> shutdown(new ShutdownInfo());
+ transport->oneway(shutdown);
transport->close();
}
@@ -455,141 +449,137 @@ void FailoverTransportTest::testWithOpewireCommands() {
////////////////////////////////////////////////////////////////////////////////
Pointer<ConnectionInfo> FailoverTransportTest::createConnection() {
- Pointer<ConnectionId> id( new ConnectionId() );
- id->setValue( UUID::randomUUID().toString() );
+ Pointer<ConnectionId> id(new ConnectionId());
+ id->setValue(UUID::randomUUID().toString());
- Pointer<ConnectionInfo> info( new ConnectionInfo() );
- info->setClientId( UUID::randomUUID().toString() );
- info->setConnectionId( id );
+ Pointer<ConnectionInfo> info(new ConnectionInfo());
+ info->setClientId(UUID::randomUUID().toString());
+ info->setConnectionId(id);
return info;
}
////////////////////////////////////////////////////////////////////////////////
-Pointer<SessionInfo> FailoverTransportTest::createSession( const Pointer<ConnectionInfo>& parent ) {
+Pointer<SessionInfo> FailoverTransportTest::createSession(const Pointer<ConnectionInfo>& parent) {
static int idx = 1;
- Pointer<SessionId> id( new SessionId() );
- id->setConnectionId( parent->getConnectionId()->getValue() );
- id->setValue( idx++ );
+ Pointer<SessionId> id(new SessionId());
+ id->setConnectionId(parent->getConnectionId()->getValue());
+ id->setValue(idx++);
- Pointer<SessionInfo> info( new SessionInfo() );
- info->setSessionId( id );
+ Pointer<SessionInfo> info(new SessionInfo());
+ info->setSessionId(id);
return info;
}
////////////////////////////////////////////////////////////////////////////////
-Pointer<ConsumerInfo> FailoverTransportTest::createConsumer( const Pointer<SessionInfo>& parent ) {
+Pointer<ConsumerInfo> FailoverTransportTest::createConsumer(const Pointer<SessionInfo>& parent) {
static int idx = 1;
- Pointer<ConsumerId> id( new ConsumerId() );
- id->setConnectionId( parent->getSessionId()->getConnectionId() );
- id->setSessionId( parent->getSessionId()->getValue() );
- id->setValue( idx++ );
+ Pointer<ConsumerId> id(new ConsumerId());
+ id->setConnectionId(parent->getSessionId()->getConnectionId());
+ id->setSessionId(parent->getSessionId()->getValue());
+ id->setValue(idx++);
- Pointer<ConsumerInfo> info( new ConsumerInfo() );
- info->setConsumerId( id );
+ Pointer<ConsumerInfo> info(new ConsumerInfo());
+ info->setConsumerId(id);
return info;
}
////////////////////////////////////////////////////////////////////////////////
-Pointer<ProducerInfo> FailoverTransportTest::createProducer( const Pointer<SessionInfo>& parent ) {
+Pointer<ProducerInfo> FailoverTransportTest::createProducer(const Pointer<SessionInfo>& parent) {
static int idx = 1;
- Pointer<ProducerId> id( new ProducerId() );
- id->setConnectionId( parent->getSessionId()->getConnectionId() );
- id->setSessionId( parent->getSessionId()->getValue() );
- id->setValue( idx++ );
+ Pointer<ProducerId> id(new ProducerId());
+ id->setConnectionId(parent->getSessionId()->getConnectionId());
+ id->setSessionId(parent->getSessionId()->getValue());
+ id->setValue(idx++);
- Pointer<ProducerInfo> info( new ProducerInfo() );
- info->setProducerId( id );
+ Pointer<ProducerInfo> info(new ProducerInfo());
+ info->setProducerId(id);
return info;
}
////////////////////////////////////////////////////////////////////////////////
-void FailoverTransportTest::disposeOf( const Pointer<SessionInfo>& session,
- Pointer<Transport>& transport ) {
+void FailoverTransportTest::disposeOf(const Pointer<SessionInfo>& session, Pointer<Transport>& transport) {
- Pointer<RemoveInfo> command( new RemoveInfo() );
- command->setObjectId( session->getSessionId() );
- transport->oneway( command );
+ Pointer<RemoveInfo> command(new RemoveInfo());
+ command->setObjectId(session->getSessionId());
+ transport->oneway(command);
}
////////////////////////////////////////////////////////////////////////////////
-void FailoverTransportTest::disposeOf( const Pointer<ConsumerInfo>& consumer,
- Pointer<Transport>& transport ) {
+void FailoverTransportTest::disposeOf(const Pointer<ConsumerInfo>& consumer, Pointer<Transport>& transport) {
- Pointer<RemoveInfo> command( new RemoveInfo() );
- command->setObjectId( consumer->getConsumerId() );
- transport->oneway( command );
+ Pointer<RemoveInfo> command(new RemoveInfo());
+ command->setObjectId(consumer->getConsumerId());
+ transport->oneway(command);
}
////////////////////////////////////////////////////////////////////////////////
-void FailoverTransportTest::disposeOf( const Pointer<ProducerInfo>& producer,
- Pointer<Transport>& transport ) {
+void FailoverTransportTest::disposeOf(const Pointer<ProducerInfo>& producer, Pointer<Transport>& transport) {
- Pointer<RemoveInfo> command( new RemoveInfo() );
- command->setObjectId( producer->getProducerId() );
- transport->oneway( command );
+ Pointer<RemoveInfo> command(new RemoveInfo());
+ command->setObjectId(producer->getProducerId());
+ transport->oneway(command);
}
////////////////////////////////////////////////////////////////////////////////
void FailoverTransportTest::testTransportHandlesConnectionControl() {
- std::string uri =
- "failover://(mock://localhost:61618?failOnCreate=true,mock://localhost:61616)?randomize=false";
+ std::string uri = "failover://(mock://localhost:61618?failOnCreate=true,mock://localhost:61616)?randomize=false";
std::string reconnectStr = "mock://localhost:61613?name=Reconnect";
- Pointer<ConnectionControl> control( new ConnectionControl() );
- control->setReconnectTo( reconnectStr );
- control->setRebalanceConnection( true );
+ Pointer<ConnectionControl> control(new ConnectionControl());
+ control->setReconnectTo(reconnectStr);
+ control->setRebalanceConnection(true);
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
failover->setUpdateURIsSupported(true);
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
transport->start();
- Thread::sleep( 3000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
+ Thread::sleep(3000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
MockTransport* mock = NULL;
- while( mock == NULL ) {
- Thread::sleep( 100 );
- mock = dynamic_cast<MockTransport*>( transport->narrow( typeid( MockTransport ) ) );
+ while (mock == NULL) {
+ Thread::sleep(100);
+ mock = dynamic_cast<MockTransport*>(transport->narrow(typeid(MockTransport)));
}
LinkedList<URI> removals;
- removals.add( URI("mock://localhost:61616") );
+ removals.add(URI("mock://localhost:61616"));
- mock->fireCommand( control );
- Thread::sleep( 2000 );
- failover->removeURI( true, removals );
+ mock->fireCommand(control);
+ Thread::sleep(2000);
+ failover->removeURI(true, removals);
- Thread::sleep( 20000 );
+ Thread::sleep(20000);
mock = NULL;
- while( mock == NULL ) {
- Thread::sleep( 100 );
- mock = dynamic_cast<MockTransport*>( transport->narrow( typeid( MockTransport ) ) );
+ while (mock == NULL) {
+ Thread::sleep(100);
+ mock = dynamic_cast<MockTransport*>(transport->narrow(typeid(MockTransport)));
}
CPPUNIT_ASSERT_EQUAL(std::string("Reconnect"), mock->getName());
@@ -599,27 +589,27 @@ void FailoverTransportTest::testTransportHandlesConnectionControl() {
void FailoverTransportTest::testPriorityBackupConfig() {
std::string uri = "failover://(mock://localhost:61616,"
- "mock://localhost:61618)?randomize=false&priorityBackup=true";
+ "mock://localhost:61618)?randomize=false&priorityBackup=true";
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
- CPPUNIT_ASSERT( failover->isPriorityBackup() == true );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
+ CPPUNIT_ASSERT(failover->isPriorityBackup() == true);
transport->start();
- Thread::sleep( 1000 );
- CPPUNIT_ASSERT( failover->isConnected() == true );
- CPPUNIT_ASSERT( failover->isConnectedToPriority() == true );
+ Thread::sleep(1000);
+ CPPUNIT_ASSERT(failover->isConnected() == true);
+ CPPUNIT_ASSERT(failover->isConnectedToPriority() == true);
transport->close();
}
@@ -645,28 +635,28 @@ void FailoverTransportTest::testUriOptionsApplied() {
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
-
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
-
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == true );
- CPPUNIT_ASSERT( failover->isPriorityBackup() == true );
- CPPUNIT_ASSERT( failover->isUseExponentialBackOff() == false );
- CPPUNIT_ASSERT( failover->getInitialReconnectDelay() == 222 );
- CPPUNIT_ASSERT( failover->getMaxReconnectAttempts() == 27 );
- CPPUNIT_ASSERT( failover->getStartupMaxReconnectAttempts() == 44 );
- CPPUNIT_ASSERT( failover->isBackup() == true );
- CPPUNIT_ASSERT( failover->isTrackMessages() == false );
- CPPUNIT_ASSERT( failover->getMaxCacheSize() == 16543217 );
- CPPUNIT_ASSERT( failover->isUpdateURIsSupported() == false );
- CPPUNIT_ASSERT( failover->getMaxReconnectDelay() == 55555 );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
+
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
+
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == true);
+ CPPUNIT_ASSERT(failover->isPriorityBackup() == true);
+ CPPUNIT_ASSERT(failover->isUseExponentialBackOff() == false);
+ CPPUNIT_ASSERT(failover->getInitialReconnectDelay() == 222);
+ CPPUNIT_ASSERT(failover->getMaxReconnectAttempts() == 27);
+ CPPUNIT_ASSERT(failover->getStartupMaxReconnectAttempts() == 44);
+ CPPUNIT_ASSERT(failover->isBackup() == true);
+ CPPUNIT_ASSERT(failover->isTrackMessages() == false);
+ CPPUNIT_ASSERT(failover->getMaxCacheSize() == 16543217);
+ CPPUNIT_ASSERT(failover->isUpdateURIsSupported() == false);
+ CPPUNIT_ASSERT(failover->getMaxReconnectDelay() == 55555);
const List<URI>& priorityUris = failover->getPriorityURIs();
- CPPUNIT_ASSERT( priorityUris.size() == 2 );
+ CPPUNIT_ASSERT(priorityUris.size() == 2);
transport->close();
}
@@ -681,29 +671,29 @@ void FailoverTransportTest::testConnectedToMockBroker() {
broker1.waitUntilStarted();
std::string uri = "failover://(tcp://localhost:61626,"
- "tcp://localhost:61628)?randomize=false";
+ "tcp://localhost:61628)?randomize=false";
DefaultTransportListener listener;
FailoverTransportFactory factory;
- Pointer<Transport> transport( factory.create( uri ) );
- CPPUNIT_ASSERT( transport != NULL );
- transport->setTransportListener( &listener );
+ Pointer<Transport> transport(factory.create(uri));
+ CPPUNIT_ASSERT(transport != NULL);
+ transport->setTransportListener(&listener);
- FailoverTransport* failover = dynamic_cast<FailoverTransport*>(
- transport->narrow( typeid( FailoverTransport ) ) );
+ FailoverTransport* failover =
+ dynamic_cast<FailoverTransport*>(transport->narrow(typeid(FailoverTransport)));
- CPPUNIT_ASSERT( failover != NULL );
- CPPUNIT_ASSERT( failover->isRandomize() == false );
+ CPPUNIT_ASSERT(failover != NULL);
+ CPPUNIT_ASSERT(failover->isRandomize() == false);
transport->start();
int count = 0;
while (!failover->isConnected() && count++ < 20) {
- Thread::sleep( 200 );
+ Thread::sleep(200);
}
- CPPUNIT_ASSERT( failover->isConnected() == true );
- CPPUNIT_ASSERT( failover->isConnectedToPriority() == false );
+ CPPUNIT_ASSERT(failover->isConnected() == true);
+ CPPUNIT_ASSERT(failover->isConnectedToPriority() == false);
transport->close();
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/test/decaf/net/URLTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/decaf/net/URLTest.cpp b/activemq-cpp/src/test/decaf/net/URLTest.cpp
index 1e06067..998ca50 100644
--- a/activemq-cpp/src/test/decaf/net/URLTest.cpp
+++ b/activemq-cpp/src/test/decaf/net/URLTest.cpp
@@ -42,6 +42,8 @@ namespace {
return NULL;
}
+ using URLStreamHandler::openConnection;
+
public:
void parse(URL& url, const String& spec, int start, int end) {
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/22408e32/activemq-cpp/src/test/decaf/util/AbstractSequentialListTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/decaf/util/AbstractSequentialListTest.cpp b/activemq-cpp/src/test/decaf/util/AbstractSequentialListTest.cpp
index fbf0737..c1a0594 100644
--- a/activemq-cpp/src/test/decaf/util/AbstractSequentialListTest.cpp
+++ b/activemq-cpp/src/test/decaf/util/AbstractSequentialListTest.cpp
@@ -39,13 +39,16 @@ namespace {
public:
SimpleList() : AbstractSequentialList<E>(), list() {}
+
virtual ~SimpleList() {}
- virtual ListIterator<E>* listIterator( int index ) {
- return list.listIterator( index );
+ using AbstractSequentialList<E>::listIterator;
+
+ virtual ListIterator<E>* listIterator(int index) {
+ return list.listIterator(index);
}
- virtual ListIterator<E>* listIterator( int index ) const {
- return list.listIterator( index );
+ virtual ListIterator<E>* listIterator(int index) const {
+ return list.listIterator(index);
}
virtual int size() const {
@@ -72,11 +75,11 @@ namespace {
throw UnsupportedOperationException();
}
- virtual void add( const E& e ) {
+ virtual void add(const E& e) {
throw UnsupportedOperationException();
}
- virtual void set( const E& e ) {
+ virtual void set(const E& e) {
throw UnsupportedOperationException();
}
@@ -104,10 +107,12 @@ namespace {
virtual ~MockAbstractSequentialList() {}
- virtual ListIterator<E>* listIterator( int index ) {
+ using AbstractSequentialList<E>::listIterator;
+
+ virtual ListIterator<E>* listIterator(int index) {
return new MockListIterator<E>();
}
- virtual ListIterator<E>* listIterator( int index ) const {
+ virtual ListIterator<E>* listIterator(int index) const {
return new MockListIterator<E>();
}