18#ifndef _ACTIVEMQ_TANSPORT_MOCK_MOCKTRANSPORT_H_
19#define _ACTIVEMQ_TANSPORT_MOCK_MOCKTRANSPORT_H_
45 using decaf::lang::Pointer;
46 using activemq::commands::Command;
47 using activemq::commands::Response;
70 static MockTransport* instance;
74 bool failOnSendMessage;
75 int numSentMessageBeforeFail;
77 bool failOnReceiveMessage;
78 int numReceivedMessageBeforeFail;
79 int numReceivedMessages;
80 bool failOnKeepAliveSends;
81 int numSentKeepAlivesBeforeFail;
82 int numSentKeepAlives;
90 MockTransport(
const MockTransport&);
91 MockTransport operator=(
const MockTransport&);
109 if (listener !=
NULL) {
110 listener->onCommand(command);
122 if (listener !=
NULL) {
123 listener->onException(ex);
134 this->responseBuilder = responseBuilder;
144 outgoingListener = listener;
153 return this->wireFormat;
170 this->listener = listener;
174 return this->listener;
184 if (
typeid( *
this ) == typeId) {
220 return this->failOnSendMessage;
224 this->failOnSendMessage = value;
228 return this->numSentMessageBeforeFail;
232 this->numSentMessageBeforeFail = value;
236 return this->numSentMessages;
240 this->numSentMessages = value;
244 return this->failOnReceiveMessage;
248 this->failOnReceiveMessage = value;
252 return this->numReceivedMessageBeforeFail;
256 this->numReceivedMessageBeforeFail = value;
260 return this->numReceivedMessages;
264 this->numReceivedMessages = value;
268 return this->failOnKeepAliveSends;
272 this->failOnKeepAliveSends = value;
276 return this->numSentKeepAlivesBeforeFail;
280 this->numSentKeepAlivesBeforeFail = value;
284 return this->numSentKeepAlives;
288 this->numSentKeepAlives = value;
292 return this->failOnReceiveMessage;
296 this->failOnReceiveMessage = value;
300 return this->failOnStop;
304 this->failOnStop = value;
308 return this->failOnClose;
312 this->failOnClose = value;
#define AMQCPP_API
Definition Config.h:30
Definition ActiveMQException.h:35
Interface for a transport layer for command objects.
Definition Transport.h:60
A listener of asynchronous exceptions from a command transport object.
Definition TransportListener.h:38
Listens for Commands sent from the MockTransport.
Definition InternalCommandListener.h:46
void setFailOnReceiveMessage(bool value)
Definition MockTransport.h:247
int getNumReceivedMessageBeforeFail() const
Definition MockTransport.h:251
void setFailOnClose(bool value)
Definition MockTransport.h:311
MockTransport(const Pointer< wireformat::WireFormat > wireFormat, const Pointer< ResponseBuilder > responseBuilder)
void setFailOnSendMessage(bool value)
Definition MockTransport.h:223
bool isFailOnStart() const
Definition MockTransport.h:291
virtual Pointer< Response > request(const Pointer< Command > command)
Sends the given command to the broker and then waits for the response.
virtual void fireCommand(const Pointer< Command > command)
Fires a Command back through this transport to its registered CommandListener if there is one.
Definition MockTransport.h:108
virtual std::string getRemoteAddress() const
Definition MockTransport.h:203
virtual bool isFaultTolerant() const
Is this Transport fault tolerant, meaning that it will reconnect to a broker on disconnect.
Definition MockTransport.h:191
void setNumSentKeepAlivesBeforeFail(int value)
Definition MockTransport.h:279
virtual void setOutgoingListener(TransportListener *listener)
Sets a Listener that gets notified for every command that would have been sent by this transport to t...
Definition MockTransport.h:143
virtual bool isReconnectSupported() const
Definition MockTransport.h:315
void setFailOnKeepAliveSends(bool value)
Definition MockTransport.h:271
virtual ~MockTransport()
Definition MockTransport.h:97
virtual void setWireFormat(const Pointer< wireformat::WireFormat > wireFormat AMQCPP_UNUSED)
Sets the WireFormat instance to use.
Definition MockTransport.h:167
int getNumSentKeepAlives() const
Definition MockTransport.h:283
void setName(const std::string &name)
Definition MockTransport.h:215
void setNumReceivedMessages(int value)
Definition MockTransport.h:263
int getNumReceivedMessages() const
Definition MockTransport.h:259
bool isFailOnReceiveMessage() const
Definition MockTransport.h:243
int getNumSentMessageBeforeFail() const
Definition MockTransport.h:227
void setNumSentMessages(int value)
Definition MockTransport.h:239
int getNumSentMessages() const
Definition MockTransport.h:235
std::string getName() const
Definition MockTransport.h:211
void setNumSentKeepAlives(int value)
Definition MockTransport.h:287
void setFailOnStart(bool value)
Definition MockTransport.h:295
virtual TransportListener * getTransportListener() const
Gets the observer of asynchronous events from this transport.
Definition MockTransport.h:173
virtual bool isClosed() const
Has the Transport been shutdown and no longer usable.
Definition MockTransport.h:199
int getNumSentKeepAlivesBeforeFail() const
Definition MockTransport.h:275
virtual bool isUpdateURIsSupported() const
Definition MockTransport.h:319
void setNumReceivedMessageBeforeFail(int value)
Definition MockTransport.h:255
void setResponseBuilder(const Pointer< ResponseBuilder > responseBuilder)
Sets the ResponseBuilder that this class uses to create Responses to Commands sent.
Definition MockTransport.h:133
virtual void setTransportListener(TransportListener *listener)
Sets the observer of asynchronous events from this transport.
Definition MockTransport.h:169
virtual Transport * narrow(const std::type_info &typeId)
Narrows down a Chain of Transports to a specific Transport to allow a higher level transport to skip ...
Definition MockTransport.h:183
virtual Pointer< Response > request(const Pointer< Command > command, unsigned int timeout)
Sends the given command to the broker and then waits for the response.
static MockTransport * getInstance()
Definition MockTransport.h:99
virtual void oneway(const Pointer< Command > command)
Sends a one-way command.
bool isFailOnSendMessage() const
Definition MockTransport.h:219
Pointer< wireformat::WireFormat > getWireFormat() const
Gets the currently set WireFormat.
Definition MockTransport.h:152
virtual void start()
Starts the Transport, the send methods of a Transport will throw an exception if used before the Tran...
virtual void fireException(const exceptions::ActiveMQException &ex)
Fires a Exception back through this transport to its registered ExceptionListener if there is one.
Definition MockTransport.h:121
virtual bool isConnected() const
Is the Transport Connected to its Broker.
Definition MockTransport.h:195
void setFailOnStop(bool value)
Definition MockTransport.h:303
virtual void close()
Closes this object and deallocates the appropriate resources.
bool isFailOnStop() const
Definition MockTransport.h:299
bool isFailOnClose() const
Definition MockTransport.h:307
virtual void stop()
Stops the Transport.
bool isFailOnKeepAliveSends() const
Definition MockTransport.h:267
virtual Pointer< FutureResponse > asyncRequest(const Pointer< Command > command, const Pointer< ResponseCallback > responseCallback)
Sends a commands asynchronously, returning a FutureResponse object that the caller can use to check t...
virtual void updateURIs(bool rebalance AMQCPP_UNUSED, const decaf::util::List< decaf::net::URI > &uris AMQCPP_UNUSED)
Definition MockTransport.h:323
virtual void reconnect(const decaf::net::URI &uri AMQCPP_UNUSED)
Definition MockTransport.h:207
void setNumSentMessageBeforeFail(int value)
Definition MockTransport.h:231
Definition IOException.h:28
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition Pointer.h:53
This class represents an instance of a URI as defined by RFC 2396.
Definition URI.h:37
An ordered collection (also known as a sequence).
Definition List.h:47
An int value that may be updated atomically.
Definition AtomicInteger.h:37
#define NULL
Definition Config.h:33
Definition InternalCommandListener.h:34
Definition AbstractTransportFactory.h:30
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24