RMQ - RabbitMQ C++ Library
rmqtestmocks_mockvhost.h
1// Copyright 2020-2023 Bloomberg Finance L.P.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#ifndef INCLUDED_RMQTESTMOCKS_MOCKVHOST
17#define INCLUDED_RMQTESTMOCKS_MOCKVHOST
18
19#include <rmqa_vhost.h>
20#include <rmqp_consumer.h>
21#include <rmqp_producer.h>
22#include <rmqt_future.h>
23#include <rmqt_message.h>
24
25#include <gmock/gmock.h>
26
27#include <bsl_memory.h>
28#include <bsl_string.h>
29
30namespace BloombergLP {
31namespace rmqtestmocks {
32
35
37 public:
38 // CREATORS
39 MockVHost();
40 ~MockVHost() BSLS_KEYWORD_OVERRIDE;
41
42 bsl::shared_ptr<rmqp::Connection> vhost();
43
44 MOCK_METHOD0(close, void());
45
46 MOCK_METHOD4(createConsumer,
48 const rmqt::Topology& topology,
49 rmqt::QueueHandle queue,
50 const rmqp::Consumer::ConsumerFunc& messageConsumer,
51 const rmqt::ConsumerConfig& config));
52
53 MOCK_METHOD4(createConsumerAsync,
55 const rmqt::Topology& topology,
56 rmqt::QueueHandle queue,
57 const rmqp::Consumer::ConsumerFunc& messageConsumer,
58 const rmqt::ConsumerConfig& config));
59
60 MOCK_METHOD3(createProducer,
62 rmqt::ExchangeHandle exchange,
63 uint16_t maxOutstandingConfirms));
64
65 MOCK_METHOD3(createProducerAsync,
67 rmqt::ExchangeHandle exchange,
68 uint16_t maxOutstandingConfirms));
69 // DEPRECATED:
70
71 MOCK_METHOD5(createConsumer,
73 const rmqt::Topology& topology,
74 rmqt::QueueHandle queue,
75 const rmqp::Consumer::ConsumerFunc& messageConsumer,
76 const bsl::string& consumerTag,
77 uint16_t prefetchCount));
78
79 MOCK_METHOD5(createConsumerAsync,
81 const rmqt::Topology& topology,
82 rmqt::QueueHandle queue,
83 const rmqp::Consumer::ConsumerFunc& messageConsumer,
84 const bsl::string& consumerTag,
85 uint16_t prefetchCount));
86
87 private:
88 MockVHost(const MockVHost&) BSLS_KEYWORD_DELETED;
89 MockVHost& operator=(const MockVHost&) BSLS_KEYWORD_DELETED;
90
91}; // class MockVhost
92
93} // namespace rmqtestmocks
94} // namespace BloombergLP
95
96#endif // ! INCLUDED_RMQTESTMOCKS_MOCKVHOST
Provide a RabbitMQ Connection API.
Definition: rmqp_connection.h:42
virtual void close()=0
Flush all data pending and then close the connection. Close the connection and invalidates all consum...
virtual rmqt::Result< Producer > createProducer(const rmqt::Topology &topology, rmqt::ExchangeHandle exchange, uint16_t maxOutstandingConfirms)=0
virtual rmqt::Result< rmqp::Consumer > createConsumer(const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &onMessage, const rmqt::ConsumerConfig &consumerConfig)=0
Create an asynchronous consumer using the provided Topology.
bsl::function< void(rmqp::MessageGuard &)> ConsumerFunc
Callback function used to receive messages.
Definition: rmqp_consumer.h:48
Class for passing arguments to Consumer.
Definition: rmqt_consumerconfig.h:42
An async-style Future/Promise object.
Definition: rmqt_future.h:108
A result of an operation.
Definition: rmqt_result.h:37
Definition: rmqt_topology.h:32
Mocks an rmqa::VHost object.
Definition: rmqtestmocks_mockvhost.h:36