LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
LogCabin::RPC::ServiceMock Class Reference

This class is used to mock out a Service for testing a client that sends RPCs. More...

#include <ServiceMock.h>

Inheritance diagram for LogCabin::RPC::ServiceMock:
LogCabin::RPC::Service

List of all members.

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< ExpectedresponseQueue
 A FIFO queue of requests to expect from clients and their associated handlers.

Detailed Description

This class is used to mock out a Service for testing a client that sends RPCs.

Definition at line 35 of file ServiceMock.h.


Member Typedef Documentation

typedef google::protobuf::Message LogCabin::RPC::ServiceMock::Message

Definition at line 37 of file ServiceMock.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 90 of file ServiceMock.h.

Destructor.

Makes sure no more requests are expected.

Definition at line 98 of file ServiceMock.h.


Member Function Documentation

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.

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.


Member Data Documentation

A FIFO queue of requests to expect from clients and their associated handlers.

Definition at line 187 of file ServiceMock.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines