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

This class is used in unit testing to interpose when clients send RPCs to the leader of the LogCabin cluster. More...

#include <LeaderRPCMock.h>

Inheritance diagram for LogCabin::Client::LeaderRPCMock:
LogCabin::Client::LeaderRPCBase

List of all members.

Classes

class  Call
 See LeaderRPCBase::Call. More...

Public Types

typedef std::unique_ptr
< google::protobuf::Message > 
MessagePtr

Public Member Functions

 LeaderRPCMock ()
 Constructor.
 ~LeaderRPCMock ()
 Destructor.
void expect (OpCode opCode, const google::protobuf::Message &response)
 Expect the next request operation to have type opCode, and return it the given response.
MessagePtr popRequest ()
 Pop the first request from the queue.
Status call (OpCode opCode, const google::protobuf::Message &request, google::protobuf::Message &response, TimePoint timeout)
 Mocks out an RPC call.
std::unique_ptr
< LeaderRPCBase::Call
makeCall ()
 See LeaderRPCBase::makeCall.

Private Attributes

std::deque< std::pair< OpCode,
MessagePtr > > 
requestLog
 A queue of requests that have come in from call().
std::queue< std::pair< OpCode,
MessagePtr > > 
responseQueue
 A queue of responses that have been primed from expect().

Detailed Description

This class is used in unit testing to interpose when clients send RPCs to the leader of the LogCabin cluster.

Definition at line 35 of file LeaderRPCMock.h.


Member Typedef Documentation

typedef std::unique_ptr<google::protobuf::Message> LogCabin::Client::LeaderRPCMock::MessagePtr

Definition at line 37 of file LeaderRPCMock.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 26 of file LeaderRPCMock.cc.

Destructor.

Definition at line 32 of file LeaderRPCMock.cc.


Member Function Documentation

void LogCabin::Client::LeaderRPCMock::expect ( OpCode  opCode,
const google::protobuf::Message &  response 
)

Expect the next request operation to have type opCode, and return it the given response.

Definition at line 37 of file LeaderRPCMock.cc.

Pop the first request from the queue.

Definition at line 46 of file LeaderRPCMock.cc.

LeaderRPCMock::Status LogCabin::Client::LeaderRPCMock::call ( OpCode  opCode,
const google::protobuf::Message &  request,
google::protobuf::Message &  response,
TimePoint  timeout 
) [virtual]

Mocks out an RPC call.

You should have called expect prior to this to prime a response. The request will be logged so you can pop it.

Implements LogCabin::Client::LeaderRPCBase.

Definition at line 54 of file LeaderRPCMock.cc.

See LeaderRPCBase::makeCall.

Implements LogCabin::Client::LeaderRPCBase.

Definition at line 112 of file LeaderRPCMock.cc.


Member Data Documentation

A queue of requests that have come in from call().

Definition at line 84 of file LeaderRPCMock.h.

A queue of responses that have been primed from expect().

Definition at line 88 of file LeaderRPCMock.h.


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