]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H | |
5 | #define LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H | |
6 | ||
7 | #include "test/librados_test_stub/TestMemRadosClient.h" | |
8 | #include "test/librados_test_stub/MockTestMemIoCtxImpl.h" | |
9 | #include "gmock/gmock.h" | |
10 | ||
11 | namespace librados { | |
12 | ||
13 | class TestMemCluster; | |
14 | ||
15 | class MockTestMemRadosClient : public TestMemRadosClient { | |
16 | public: | |
17 | MockTestMemRadosClient(CephContext *cct, TestMemCluster *test_mem_cluster) | |
18 | : TestMemRadosClient(cct, test_mem_cluster) { | |
19 | default_to_dispatch(); | |
20 | } | |
21 | ||
22 | MOCK_METHOD2(create_ioctx, TestIoCtxImpl *(int64_t pool_id, | |
23 | const std::string &pool_name)); | |
24 | TestIoCtxImpl *do_create_ioctx(int64_t pool_id, | |
25 | const std::string &pool_name) { | |
26 | return new ::testing::NiceMock<MockTestMemIoCtxImpl>( | |
27 | this, this, pool_id, pool_name, | |
28 | get_mem_cluster()->get_pool(pool_name)); | |
29 | } | |
30 | ||
31 | MOCK_METHOD2(blacklist_add, int(const std::string& client_address, | |
32 | uint32_t expire_seconds)); | |
33 | int do_blacklist_add(const std::string& client_address, | |
34 | uint32_t expire_seconds) { | |
35 | return TestMemRadosClient::blacklist_add(client_address, expire_seconds); | |
36 | } | |
37 | ||
c07f9fc5 FG |
38 | MOCK_METHOD3(service_daemon_register, |
39 | int(const std::string&, | |
40 | const std::string&, | |
41 | const std::map<std::string,std::string>&)); | |
42 | int do_service_daemon_register(const std::string& service, | |
43 | const std::string& name, | |
44 | const std::map<std::string,std::string>& metadata) { | |
45 | return TestMemRadosClient::service_daemon_register(service, name, metadata); | |
46 | } | |
47 | ||
48 | MOCK_METHOD1(service_daemon_update_status, | |
49 | int(const std::map<std::string,std::string>&)); | |
50 | int do_service_daemon_update_status(const std::map<std::string,std::string>& status) { | |
51 | return TestMemRadosClient::service_daemon_update_status(status); | |
52 | } | |
53 | ||
7c673cae FG |
54 | void default_to_dispatch() { |
55 | using namespace ::testing; | |
56 | ||
57 | ON_CALL(*this, create_ioctx(_, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_create_ioctx)); | |
58 | ON_CALL(*this, blacklist_add(_, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_blacklist_add)); | |
c07f9fc5 FG |
59 | ON_CALL(*this, service_daemon_register(_, _, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_service_daemon_register)); |
60 | ON_CALL(*this, service_daemon_update_status(_)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_service_daemon_update_status)); | |
7c673cae FG |
61 | } |
62 | }; | |
63 | ||
64 | } // namespace librados | |
65 | ||
66 | #endif // LIBRADOS_TEST_STUB_MOCK_TEST_MEM_RADOS_CLIENT_H |