Author: tabish
Date: Mon Nov 16 19:18:11 2009
New Revision: 880915
URL: http://svn.apache.org/viewvc?rev=880915&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-250
Add another set of configurable failures to the MockTransport, now it can fail
after sending a configurable number of KeepAliveInfo commands. Used to test
the Write check in the InactivityMonitor class.
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp?rev=880915&r1=880914&r2=880915&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.cpp
Mon Nov 16 19:18:11 2009
@@ -48,6 +48,9 @@
this->failOnReceiveMessage = false;
this->numReceivedMessageBeforeFail = 0;
this->numReceivedMessages = 0;
+ this->failOnKeepAliveSends = false;
+ this->numSentKeepAlivesBeforeFail = 0;
+ this->numSentKeepAlives = 0;
this->failOnStart = false;
this->failOnStop = false;
this->failOnClose = false;
@@ -73,6 +76,15 @@
}
}
+ if( command->isKeepAliveInfo() && this->failOnKeepAliveSends ) {
+ this->numSentKeepAlives++;
+
+ if( this->numSentKeepAlives > this->numSentKeepAlivesBeforeFail ) {
+ throw IOException(
+ __FILE__, __LINE__, "Failed to Send Message.");
+ }
+ }
+
// Process and send any new Commands back.
internalListener.onCommand( command );
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.h?rev=880915&r1=880914&r2=880915&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.h
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransport.h
Mon Nov 16 19:18:11 2009
@@ -76,6 +76,9 @@
bool failOnReceiveMessage;
int numReceivedMessageBeforeFail;
int numReceivedMessages;
+ bool failOnKeepAliveSends;
+ int numSentKeepAlivesBeforeFail;
+ int numSentKeepAlives;
bool failOnStart;
bool failOnStop;
@@ -297,6 +300,30 @@
this->numReceivedMessages = value;
}
+ bool isFailOnKeepAliveSends() const {
+ return this->failOnKeepAliveSends;
+ }
+
+ void setFailOnKeepAliveSends( bool value ) {
+ this->failOnKeepAliveSends = value;
+ }
+
+ int getNumSentKeepAlivesBeforeFail() const {
+ return this->numSentKeepAlivesBeforeFail;
+ }
+
+ void setNumSentKeepAlivesBeforeFail( int value ) {
+ this->numSentKeepAlivesBeforeFail = value;
+ }
+
+ int getNumSentKeepAlives() const {
+ return this->numSentKeepAlives;
+ }
+
+ void setNumSentKeepAlives( int value ) {
+ this->numSentKeepAlives = value;
+ }
+
bool isFailOnStart() const {
return this->failOnReceiveMessage;
}
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp?rev=880915&r1=880914&r2=880915&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp
Mon Nov 16 19:18:11 2009
@@ -127,6 +127,10 @@
Boolean::parseBoolean( properties.getProperty(
"failOnReceiveMessage", "false" ) ) );
transport->setNumReceivedMessageBeforeFail(
Integer::parseInt( properties.getProperty(
"numReceivedMessageBeforeFail", "0" ) ) );
+ transport->setFailOnKeepAliveSends(
+ Boolean::parseBoolean( properties.getProperty(
"failOnKeepAliveSends", "false" ) ) );
+ transport->setNumSentKeepAlivesBeforeFail(
+ Integer::parseInt( properties.getProperty(
"numSentKeepAlivesBeforeFail", "0" ) ) );
return transport;
}