RMQ - RabbitMQ C++ Library
rmqtestmocks_mockconnection.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_MOCKCONNECTION
17#define INCLUDED_RMQTESTMOCKS_MOCKCONNECTION
18
19#include <rmqp_connection.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
40 ~MockConnection() BSLS_KEYWORD_OVERRIDE;
41
42 bsl::shared_ptr<rmqp::Connection> connection();
43
45 static rmqt::Future<rmqp::Connection> timeout();
46 static rmqt::Future<rmqp::Connection> error();
47
48 MOCK_METHOD0(close, void());
49
50 MOCK_METHOD3(createProducerAsync,
52 rmqt::ExchangeHandle exchange,
53 uint16_t maxOutstandingConfirms));
54 MOCK_METHOD3(createProducer,
56 rmqt::ExchangeHandle exchange,
57 uint16_t maxOutstandingConfirms));
58 MOCK_METHOD4(createConsumer,
60 const rmqt::Topology& topology,
61 rmqt::QueueHandle queue,
62 const rmqp::Consumer::ConsumerFunc& messageConsumer,
63 const rmqt::ConsumerConfig& config));
64
65 MOCK_METHOD4(createConsumerAsync,
67 const rmqt::Topology& topology,
68 rmqt::QueueHandle queue,
69 const rmqp::Consumer::ConsumerFunc& messageConsumer,
70 const rmqt::ConsumerConfig& config));
71
72 // DEPRECATED
73
74 MOCK_METHOD5(createConsumer,
76 const rmqt::Topology& topology,
77 rmqt::QueueHandle queue,
78 const rmqp::Consumer::ConsumerFunc& messageConsumer,
79 const bsl::string& consumerTag,
80 uint16_t prefetchCount));
81
82 MOCK_METHOD5(createConsumerAsync,
84 const rmqt::Topology& topology,
85 rmqt::QueueHandle queue,
86 const rmqp::Consumer::ConsumerFunc& messageConsumer,
87 const bsl::string& consumerTag,
88 uint16_t prefetchCount));
89
90 private:
91 MockConnection(const MockConnection&) BSLS_KEYWORD_DELETED;
92 MockConnection& operator=(const MockConnection&) BSLS_KEYWORD_DELETED;
93
94}; // class MockConnection
95
96} // namespace rmqtestmocks
97} // namespace BloombergLP
98
99#endif // ! INCLUDED_RMQTESTMOCKS_MOCKCONNECTION
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 rmqp::Connection and/or rmqa::Connection.
Definition: rmqtestmocks_mockconnection.h:36