|
LogCabin
|
This class is used to mock out a Service for testing a client that sends RPCs. More...
#include <ServiceMock.h>
Classes | |
| class | CloseSession |
| See closeSession(). More... | |
| struct | Expected |
| See responseQueue. More... | |
| class | Handler |
| The base class for RPC handlers. More... | |
| class | RejectInvalidRequest |
| See rejectInvalidRequest(). More... | |
| class | Reply |
| See reply(). More... | |
| class | ServiceSpecificError |
| See serviceSpecificError(). More... | |
Public Types | |
| typedef google::protobuf::Message | Message |
Public Member Functions | |
| ServiceMock () | |
| Constructor. | |
| ~ServiceMock () | |
| Destructor. | |
| void | clear () |
| Remove previously expected requests. | |
| void | closeSession (uint16_t opCode, const Message &request) |
| Close the client's session when the specified request arrives (in FIFO order). | |
| void | reply (uint16_t opCode, const Message &request, const Message &response) |
| Reply normally to the client when the specified request arrives (in FIFO order). | |
| void | serviceSpecificError (uint16_t opCode, const Message &request, const Message &response) |
| Reply with a service-specific error to the client when the specified request arrives (in FIFO order). | |
| void | rejectInvalidRequest (uint16_t opCode, const Message &request) |
| Reject the client's RPC as an invalid request when the specified request arrives (in FIFO order). | |
| void | runArbitraryCode (uint16_t opCode, const Message &request, std::shared_ptr< Handler > response) |
| Call a custom handler when the request arrives. | |
| void | handleRPC (RPC::ServerRPC serverRPC) |
| This is called by the Server. | |
| std::string | getName () const |
| Return a short name for this service which can be used in things like log messages. | |
Private Member Functions | |
| void | expect (uint16_t opCode, const Message &request, std::shared_ptr< Handler > response) |
| Call the Handler when the specified request arrives (in FIFO order). | |
Private Attributes | |
| std::queue< Expected > | responseQueue |
| A FIFO queue of requests to expect from clients and their associated handlers. | |
This class is used to mock out a Service for testing a client that sends RPCs.
Definition at line 35 of file ServiceMock.h.
| typedef google::protobuf::Message LogCabin::RPC::ServiceMock::Message |
Definition at line 37 of file ServiceMock.h.
| LogCabin::RPC::ServiceMock::ServiceMock | ( | ) | [inline] |
Constructor.
Definition at line 90 of file ServiceMock.h.
| LogCabin::RPC::ServiceMock::~ServiceMock | ( | ) | [inline] |
| void LogCabin::RPC::ServiceMock::clear | ( | ) | [inline] |
Remove previously expected requests.
Definition at line 105 of file ServiceMock.h.
| void LogCabin::RPC::ServiceMock::closeSession | ( | uint16_t | opCode, |
| const Message & | request | ||
| ) | [inline] |
Close the client's session when the specified request arrives (in FIFO order).
Definition at line 113 of file ServiceMock.h.
| void LogCabin::RPC::ServiceMock::reply | ( | uint16_t | opCode, |
| const Message & | request, | ||
| const Message & | response | ||
| ) | [inline] |
Reply normally to the client when the specified request arrives (in FIFO order).
Definition at line 121 of file ServiceMock.h.
| void LogCabin::RPC::ServiceMock::serviceSpecificError | ( | uint16_t | opCode, |
| const Message & | request, | ||
| const Message & | response | ||
| ) | [inline] |
Reply with a service-specific error to the client when the specified request arrives (in FIFO order).
Definition at line 130 of file ServiceMock.h.
| void LogCabin::RPC::ServiceMock::rejectInvalidRequest | ( | uint16_t | opCode, |
| const Message & | request | ||
| ) | [inline] |
Reject the client's RPC as an invalid request when the specified request arrives (in FIFO order).
Definition at line 140 of file ServiceMock.h.
| void LogCabin::RPC::ServiceMock::runArbitraryCode | ( | uint16_t | opCode, |
| const Message & | request, | ||
| std::shared_ptr< Handler > | response | ||
| ) | [inline] |
Call a custom handler when the request arrives.
Definition at line 147 of file ServiceMock.h.
| void LogCabin::RPC::ServiceMock::handleRPC | ( | RPC::ServerRPC | serverRPC | ) | [virtual] |
This is called by the Server.
Implements LogCabin::RPC::Service.
Definition at line 50 of file ServiceMock.cc.
| std::string LogCabin::RPC::ServiceMock::getName | ( | ) | const [virtual] |
Return a short name for this service which can be used in things like log messages.
Implements LogCabin::RPC::Service.
Definition at line 77 of file ServiceMock.cc.
| void LogCabin::RPC::ServiceMock::expect | ( | uint16_t | opCode, |
| const Message & | request, | ||
| std::shared_ptr< Handler > | response | ||
| ) | [private] |
Call the Handler when the specified request arrives (in FIFO order).
Definition at line 83 of file ServiceMock.cc.
std::queue<Expected> LogCabin::RPC::ServiceMock::responseQueue [private] |
A FIFO queue of requests to expect from clients and their associated handlers.
Definition at line 187 of file ServiceMock.h.
1.7.6.1