libbmq  e19ff338c707b114e9f84d83ea866a97518afb37
bmqa_mocksession.h
Go to the documentation of this file.
1 // Copyright 2016-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 // bmqa_mocksession.h -*-C++-*-
17 #ifndef INCLUDED_BMQA_MOCKSESSION
18 #define INCLUDED_BMQA_MOCKSESSION
19 
550 
551 // BMQ
552 #include <bmqa_abstractsession.h>
553 #include <bmqa_closequeuestatus.h>
556 #include <bmqa_openqueuestatus.h>
557 #include <bmqa_queueid.h>
558 #include <bmqa_session.h> // for 'bmqa::SessionEventHandler'
559 #include <bmqt_queueoptions.h>
560 #include <bmqt_sessionoptions.h>
561 
562 // BDE
563 #include <ball_log.h>
564 #include <bdlb_variant.h>
565 #include <bdlbb_blob.h>
566 #include <bdlbb_pooledblobbufferfactory.h>
567 #include <bdlcc_sharedobjectpool.h>
568 #include <bsl_cstddef.h>
569 #include <bsl_deque.h>
570 #include <bsl_functional.h>
571 #include <bsl_memory.h>
572 #include <bsl_string.h>
573 #include <bsl_unordered_map.h>
574 #include <bsl_unordered_set.h>
575 #include <bslma_allocator.h>
576 #include <bslma_managedptr.h>
577 #include <bslma_usesbslmaallocator.h>
578 #include <bslmf_nestedtraitdeclaration.h>
579 #include <bslmt_mutex.h>
580 #include <bsls_alignedbuffer.h>
581 #include <bsls_assert.h>
582 #include <bsls_timeinterval.h>
583 #include <bsls_types.h>
584 
585 namespace BloombergLP {
586 
587 // FORWARD DECLARATION
588 namespace bmqimp {
589 class Event;
590 }
591 namespace bmqimp {
592 class MessageCorrelationIdContainer;
593 }
594 namespace bmqimp {
595 struct Stat;
596 }
597 namespace bmqst {
598 class StatContext;
599 }
600 
601 namespace bmqa {
602 
603 // FORWARD DECLARATION
604 class ConfirmEventBuilder;
605 
606 // Record an expected method 'CALL' into the specified mock session 'OBJ'.
607 #define BMQA_EXPECT_CALL(OBJ, CALL) \
608  (((OBJ).expect_##CALL).fromLocation(__FILE__, __LINE__))
609 
610 // ======================
611 // struct MockSessionUtil
612 // ======================
613 
616  private:
617  // PRIVATE TYPES
618 
620  typedef bdlcc::SharedObjectPool<
621  bdlbb::Blob,
622  bdlcc::ObjectPoolFunctors::DefaultCreator,
623  bdlcc::ObjectPoolFunctors::RemoveAll<bdlbb::Blob> >
624  BlobSpPool;
625 
628  typedef bsl::shared_ptr<bmqimp::Event> EventImplSp;
629 
632  typedef bsl::shared_ptr<bmqimp::Queue> QueueImplSp;
633 
634  public:
635  // PUBLIC TYPES
636 
638  struct AckParams {
639  // PUBLIC DATA
640 
643 
646 
649 
652 
653  // CREATORS
654 
658  const bmqt::CorrelationId& correlationId,
659  const bmqt::MessageGUID& guid,
660  const bmqa::QueueId& queueId);
661  };
662 
663  // PUBLIC TYPES
664 
667  // PUBLIC DATA
668 
670  bdlbb::Blob d_payload;
671 
674 
677 
680 
681  // CREATORS
682 
685  PushMessageParams(const bdlbb::Blob& payload,
686  const bmqa::QueueId& queueId,
687  const bmqt::MessageGUID& guid,
688  const MessageProperties& properties);
689  };
690 
691  // CLASS METHODS
692 
696  static Event createAckEvent(const bsl::vector<AckParams>& acks,
697  bdlbb::BlobBufferFactory* bufferFactory,
698  bslma::Allocator* allocator);
699 
704  static Event
705  createPushEvent(const bsl::vector<PushMessageParams>& pushEventParams,
706  bdlbb::BlobBufferFactory* bufferFactory,
707  bslma::Allocator* allocator);
708 
714  static Event
716  QueueId* queueId,
717  const bmqt::CorrelationId& correlationId,
718  int errorCode,
719  const bslstl::StringRef& errorDescription,
720  bslma::Allocator* allocator);
721 
726  static Event
728  const bmqt::CorrelationId& correlationId,
729  const int errorCode,
730  const bslstl::StringRef& errorDescription,
731  bslma::Allocator* allocator);
732 
736  static OpenQueueStatus
738  bmqt::OpenQueueResult::Enum statusCode,
739  const bsl::string& errorDescription,
740  bslma::Allocator* allocator = 0);
741 
745  static ConfigureQueueStatus
748  const bsl::string& errorDescription,
749  bslma::Allocator* allocator = 0);
750 
754  static CloseQueueStatus
756  bmqt::CloseQueueResult::Enum statusCode,
757  const bsl::string& errorDescription,
758  bslma::Allocator* allocator = 0);
759 };
760 
761 // =================
762 // class MockSession
763 // =================
764 
766 class MockSession : public AbstractSession {
767  public:
768  // TYPES
769 
770  // CLASS METHODS
771 
784  static void initialize(bslma::Allocator* allocator = 0);
785 
792  static void shutdown();
793 
794  // PUBLIC TYPES
795 
800  typedef bsl::function<
801  void(const char* description, const char* file, int line)>
803 
804  private:
805  // CLASS-SCOPE CATEGORY
806  BALL_LOG_SET_CLASS_CATEGORY("BMQA.MOCKSESSION");
807 
808  private:
809  // CONSTANTS
810 
815  static const int k_MAX_SIZEOF_BMQC_TWOKEYHASHMAP = 256;
816 
817  // PRIVATE TYPES
818 
820  typedef bdlcc::SharedObjectPool<
821  bdlbb::Blob,
822  bdlcc::ObjectPoolFunctors::DefaultCreator,
823  bdlcc::ObjectPoolFunctors::RemoveAll<bdlbb::Blob> >
824  BlobSpPool;
825 
827  typedef bsl::shared_ptr<BlobSpPool> BlobSpPoolSp;
828 
830  typedef bsls::AlignedBuffer<k_MAX_SIZEOF_BMQC_TWOKEYHASHMAP>
831  TwoKeyHashMapBuffer;
832 
834  typedef bsl::shared_ptr<bmqimp::Queue> QueueImplSp;
835 
837  typedef bsl::shared_ptr<bmqimp::Event> EventImplSp;
838 
840  typedef bsl::shared_ptr<bmqimp::Stat> StatImplSp;
841 
843  typedef bsl::shared_ptr<bmqimp::MessageCorrelationIdContainer>
844  CorrelationIdContainerSp;
845 
846  typedef bsl::function<void()> CallbackFn;
847 
850  struct Job {
851  // PUBLIC DATA
852 
854  CallbackFn d_callback;
855 
857  QueueImplSp d_queue;
858 
862 
864  int d_status;
865  };
866 
867  typedef bdlb::Variant<Event, Job> EventOrJob;
868 
871  enum Method {
872  e_START,
873  e_START_ASYNC,
874  e_STOP,
875  e_STOP_ASYNC,
876  e_FINALIZE_STOP,
877  e_OPEN_QUEUE,
878  e_OPEN_QUEUE_SYNC,
879  e_OPEN_QUEUE_ASYNC,
880  e_OPEN_QUEUE_ASYNC_CALLBACK,
881  e_CLOSE_QUEUE,
882  e_CLOSE_QUEUE_SYNC,
883  e_CLOSE_QUEUE_ASYNC,
884  e_CLOSE_QUEUE_ASYNC_CALLBACK,
885  e_CONFIGURE_QUEUE,
886  e_CONFIGURE_QUEUE_SYNC,
887  e_CONFIGURE_QUEUE_ASYNC,
888  e_CONFIGURE_QUEUE_ASYNC_CALLBACK,
889  e_NEXT_EVENT,
890  e_POST,
891  e_CONFIRM_MESSAGE,
892  e_CONFIRM_MESSAGES
893  };
894 
895  struct Call {
896  // PUBLIC TYPES
897 
899  typedef bsl::vector<EventOrJob> EventsAndJobs;
900 
901  // PUBLIC DATA
902 
904  int d_rc;
905 
907  Method d_method;
908 
910  int d_line;
911 
913  bsl::string d_file;
914 
916  bmqt::Uri d_uri;
917 
919  bsls::Types::Uint64 d_flags;
920 
922  bmqt::QueueOptions d_queueOptions;
923 
925  bsls::TimeInterval d_timeout;
926 
929  OpenQueueCallback d_openQueueCallback;
930 
933  ConfigureQueueCallback d_configureQueueCallback;
934 
937  CloseQueueCallback d_closeQueueCallback;
938 
940  bmqa::OpenQueueStatus d_openQueueResult;
941 
943  bmqa::ConfigureQueueStatus d_configureQueueResult;
944 
946  bmqa::CloseQueueStatus d_closeQueueResult;
947 
949  EventsAndJobs d_emittedEvents;
950 
952  Event d_returnEvent;
953 
955  MessageEvent d_messageEvent;
956 
958  MessageConfirmationCookie d_cookie;
959 
961  bslma::Allocator* d_allocator_p;
962 
963  // TRAITS
964  BSLMF_NESTED_TRAIT_DECLARATION(Call, bslma::UsesBslmaAllocator)
965 
966  // CREATORS
967 
968 
970  Call(Method method, bslma::Allocator* allocator);
971 
972  Call(const Call& other, bslma::Allocator* allocator);
973 
974  // MANIPULATORS
975 
980  Call& fromLocation(const char* file, int line);
981 
984  Call& returning(int rc);
985 
989  Call& returning(const bmqa::OpenQueueStatus& result);
990 
994  Call& returning(const bmqa::ConfigureQueueStatus& result);
995 
999  Call& returning(const bmqa::CloseQueueStatus& result);
1000 
1003  Call& returning(const Event& event);
1004 
1007  Call& emitting(const Event& event);
1008 
1012  Call& emitting(const OpenQueueStatus& openQueueResult);
1013 
1017  Call& emitting(const ConfigureQueueStatus& configureQueueResutl);
1018 
1022  Call& emitting(const CloseQueueStatus& closeQueueResult);
1023 
1024  // ACCESSORS
1025 
1027  const char* methodName() const;
1028  };
1029 
1031  typedef bsl::deque<Call> CallQueue;
1032 
1034  typedef bsl::deque<bmqa::MessageEvent> PostedEvents;
1035 
1036  // DATA
1037 
1039  bdlbb::PooledBlobBufferFactory d_blobBufferFactory;
1040 
1042  BlobSpPoolSp d_blobSpPool_sp;
1043 
1045  bslma::ManagedPtr<SessionEventHandler> d_eventHandler_mp;
1046 
1048  mutable CallQueue d_calls;
1049 
1051  mutable bsl::deque<EventOrJob> d_eventsAndJobs;
1052 
1054  bsl::unordered_set<bmqt::MessageGUID> d_unconfirmedGUIDs;
1055 
1057  TwoKeyHashMapBuffer d_twoKeyHashMapBuffer;
1058 
1061  FailureCb d_failureCb;
1062 
1064  int d_lastQueueId;
1065 
1067  CorrelationIdContainerSp d_corrIdContainer_sp;
1068 
1070  PostedEvents d_postedEvents;
1071 
1073  mutable bslmt::Mutex d_mutex;
1074 
1076  bslma::ManagedPtr<bmqst::StatContext> d_rootStatContext_mp;
1077 
1079  StatImplSp d_queuesStats_sp;
1080 
1082  bmqt::SessionOptions d_sessionOptions;
1083 
1085  bslma::Allocator* d_allocator_p;
1086 
1087  private:
1088  // PRIVATE CLASS METHODS
1089 
1091  static const char* toAscii(const Method method);
1092 
1093  // PRIVATE MANIPULATORS
1094 
1096  void initializeStats();
1097 
1105  void openQueueImp(QueueId* queueId,
1106  const bmqt::QueueOptions& options,
1107  const bmqt::Uri& uri,
1108  bsls::Types::Uint64 flags,
1109  bool async);
1110 
1114  void processIfQueueEvent(Event* event);
1115 
1119  void processIfQueueJob(Job* job);
1120 
1123  void processIfPushEvent(const Event& event);
1124 
1125  // PRIVATE ACCESSORS
1126 
1129  void assertWrongCall(const Method method) const;
1130 
1133  void assertWrongCall(const Method method, const Call& expectedCall) const;
1134 
1139  template <class T, class U>
1140  void assertWrongArg(const T& expected,
1141  const U& actual,
1142  const Method method,
1143  const char* arg,
1144  const Call& call) const;
1145 
1146  public:
1147  // TRAITS
1148  BSLMF_NESTED_TRAIT_DECLARATION(MockSession, bslma::UsesBslmaAllocator)
1149 
1150  // CREATORS
1151 
1152 
1157  explicit MockSession(
1158  const bmqt::SessionOptions& options = bmqt::SessionOptions(),
1159  bslma::Allocator* allocator = 0);
1160 
1166  explicit MockSession(
1167  bslma::ManagedPtr<SessionEventHandler> eventHandler,
1168  const bmqt::SessionOptions& options = bmqt::SessionOptions(),
1169  bslma::Allocator* allocator = 0);
1170 
1172  ~MockSession() BSLS_KEYWORD_OVERRIDE;
1173 
1174  // MANIPULATORS
1175  // (specific to 'bmqa::MockSession')
1176 
1180  void enqueueEvent(const bmqa::Event& event);
1181 
1187  bool emitEvent(int numEvents = 1);
1188 
1189  Call&
1190  expect_start(const bsls::TimeInterval& timeout = bsls::TimeInterval());
1192  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1193  Call& expect_stop();
1196  Call&
1198  const bmqt::Uri& uri,
1199  bsls::Types::Uint64 flags,
1200  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1201  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1203  QueueId* queueId,
1204  const bmqt::Uri& uri,
1205  bsls::Types::Uint64 flags,
1206  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1207  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1208 
1210  QueueId* queueId,
1211  const bmqt::Uri& uri,
1212  bsls::Types::Uint64 flags,
1213  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1214  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1216  QueueId* queueId,
1217  const bmqt::Uri& uri,
1218  bsls::Types::Uint64 flags,
1219  const OpenQueueCallback& callback,
1220  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1221  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1222 
1224  QueueId* queueId,
1225  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1227  QueueId* queueId,
1228  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1229 
1231  QueueId* queueId,
1232  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1234  QueueId* queueId,
1235  const CloseQueueCallback& callback,
1236  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1238  QueueId* queueId,
1239  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1240  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1242  QueueId* queueId,
1243  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1244  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1246  QueueId* queueId,
1247  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1248  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1249 
1251  QueueId* queueId,
1252  const bmqt::QueueOptions& options,
1253  const ConfigureQueueCallback& callback,
1254  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1255 
1256  Call&
1257  expect_nextEvent(const bsls::TimeInterval& timeout = bsls::TimeInterval());
1258  Call& expect_post(const MessageEvent& messageEvent);
1259  Call& expect_confirmMessage(const Message& message);
1261 
1268 
1269  // MANIPULATORS
1270  // (virtual bmqa::AbstractSession)
1271  int start(const bsls::TimeInterval& timeout = bsls::TimeInterval())
1272  BSLS_KEYWORD_OVERRIDE;
1273 
1278  int startAsync(const bsls::TimeInterval& timeout = bsls::TimeInterval())
1279  BSLS_KEYWORD_OVERRIDE;
1280 
1281  void stop() BSLS_KEYWORD_OVERRIDE;
1282 
1286  void stopAsync() BSLS_KEYWORD_OVERRIDE;
1287 
1291  void finalizeStop() BSLS_KEYWORD_OVERRIDE;
1292 
1296  BSLS_KEYWORD_OVERRIDE;
1297 
1301  BSLS_KEYWORD_OVERRIDE;
1302 
1305  void
1306  loadMessageProperties(MessageProperties* buffer) BSLS_KEYWORD_OVERRIDE;
1307 
1310 
1313  int getQueueId(QueueId* queueId,
1314  const bmqt::Uri& uri) BSLS_KEYWORD_OVERRIDE;
1315 
1318  int getQueueId(QueueId* queueId, const bmqt::CorrelationId& correlationId)
1319  BSLS_KEYWORD_OVERRIDE;
1320 
1325  int openQueue(QueueId* queueId,
1326  const bmqt::Uri& uri,
1327  bsls::Types::Uint64 flags,
1328  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1329  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1330  BSLS_KEYWORD_OVERRIDE;
1331 
1342  const bmqt::Uri& uri,
1343  bsls::Types::Uint64 flags,
1344  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1345  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1346  BSLS_KEYWORD_OVERRIDE;
1347 
1352  int
1354  const bmqt::Uri& uri,
1355  bsls::Types::Uint64 flags,
1356  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1357  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1358  BSLS_KEYWORD_OVERRIDE;
1359 
1376  void
1378  const bmqt::Uri& uri,
1379  bsls::Types::Uint64 flags,
1380  const OpenQueueCallback& callback,
1381  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1382  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1383  BSLS_KEYWORD_OVERRIDE;
1384 
1389  int
1391  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1392  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1393  BSLS_KEYWORD_OVERRIDE;
1394 
1400  const bmqt::QueueOptions& options,
1401  const bsls::TimeInterval& timeout)
1402  BSLS_KEYWORD_OVERRIDE;
1403 
1409  QueueId* queueId,
1410  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1411  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1412  BSLS_KEYWORD_OVERRIDE;
1413 
1423  const bmqt::QueueOptions& options,
1424  const ConfigureQueueCallback& callback,
1425  const bsls::TimeInterval& timeout =
1426  bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE;
1427 
1432  int closeQueue(QueueId* queueId,
1433  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1434  BSLS_KEYWORD_OVERRIDE;
1435 
1443  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1444  BSLS_KEYWORD_OVERRIDE;
1445 
1450  int closeQueueAsync(QueueId* queueId,
1451  const bsls::TimeInterval& timeout =
1452  bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE;
1453 
1461  void closeQueueAsync(QueueId* queueId,
1462  const CloseQueueCallback& callback,
1463  const bsls::TimeInterval& timeout =
1464  bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE;
1465 
1472  Event nextEvent(const bsls::TimeInterval& timeout = bsls::TimeInterval())
1473  BSLS_KEYWORD_OVERRIDE;
1474 
1479  int post(const MessageEvent& messageEvent) BSLS_KEYWORD_OVERRIDE;
1480 
1481  int confirmMessage(const Message& message) BSLS_KEYWORD_OVERRIDE;
1483  BSLS_KEYWORD_OVERRIDE;
1484 
1488  int confirmMessages(ConfirmEventBuilder* builder) BSLS_KEYWORD_OVERRIDE;
1489 
1490  int configureMessageDumping(const bslstl::StringRef& command)
1491  BSLS_KEYWORD_OVERRIDE;
1492  // NOT IMPLEMENTED
1493 
1497  void setFailureCallback(const FailureCb& failureCb);
1498 
1502  bool popPostedEvent(bmqa::MessageEvent* event);
1503 
1504  // ACCESSORS
1505 
1509  size_t unconfirmedMessages() const;
1510 };
1511 
1512 // ============================================================================
1513 // INLINE DEFINITIONS
1514 // ============================================================================
1515 
1516 // -----------------
1517 // class MockSession
1518 // -----------------
1519 
1520 inline void MockSession::setFailureCallback(const FailureCb& failureCb)
1521 {
1522  d_failureCb = failureCb;
1523 }
1524 
1526 {
1527  return d_unconfirmedGUIDs.size();
1528 }
1529 
1531 {
1532  // PRECONDITIONS
1533  BSLS_ASSERT(event);
1534 
1535  bslmt::LockGuard<bslmt::Mutex> guard(&d_mutex); // LOCKED
1536 
1537  if (d_postedEvents.empty()) {
1538  return false; // RETURN
1539  }
1540 
1541  *event = d_postedEvents.front();
1542  d_postedEvents.pop_front();
1543 
1544  return true;
1545 }
1546 
1547 } // close package namespace
1548 } // close enterprise namespace
1549 
1550 #endif
Provide a pure protocol for a BlazingMQ session.
Provide Value-Semantic Type for a close queue operation status.
Provide Value-Semantic Type for a configure queue operation status.
Provide a builder for bmqa::MessageEvent objects.
Provide Value-Semantic Type for an open queue operation status.
Provide a value-semantic efficient identifier for a queue.
Provide access to the BlazingMQ broker.
Provide a value-semantic type for options related to a queue.
Provide a value-semantic type to configure session with the broker.
A pure protocol for a session.
Definition: bmqa_abstractsession.h:50
bsl::function< void(const bmqa::CloseQueueStatus &result)> CloseQueueCallback
Definition: bmqa_abstractsession.h:73
bsl::function< void(const bmqa::ConfigureQueueStatus &result)> ConfigureQueueCallback
Definition: bmqa_abstractsession.h:66
bsl::function< void(const bmqa::OpenQueueStatus &result)> OpenQueueCallback
Definition: bmqa_abstractsession.h:59
Definition: bmqa_closequeuestatus.h:62
Definition: bmqa_configurequeuestatus.h:61
Mechanism to build a batch of CONFIRM messages.
Definition: bmqa_confirmeventbuilder.h:157
A variant type encompassing all types of events.
Definition: bmqa_event.h:69
Cookie for async message confirmation.
Definition: bmqa_message.h:131
A builder for MessageEvent objects.
Definition: bmqa_messageeventbuilder.h:319
Definition: bmqa_messageevent.h:64
Provide a VST representing message properties.
Definition: bmqa_messageproperties.h:92
A message sent/received to/from the BlazingMQ broker.
Definition: bmqa_message.h:170
Mechanism to mock a bmqa::Session
Definition: bmqa_mocksession.h:766
void loadMessageProperties(MessageProperties *buffer) BSLS_KEYWORD_OVERRIDE
int confirmMessages(ConfirmEventBuilder *builder) BSLS_KEYWORD_OVERRIDE
size_t unconfirmedMessages() const
Definition: bmqa_mocksession.h:1525
void finalizeStop() BSLS_KEYWORD_OVERRIDE
void setFailureCallback(const FailureCb &failureCb)
Definition: bmqa_mocksession.h:1520
int closeQueueAsync(QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
int configureQueue(QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
static void initialize(bslma::Allocator *allocator=0)
void stopAsync() BSLS_KEYWORD_OVERRIDE
int getQueueId(QueueId *queueId, const bmqt::Uri &uri) BSLS_KEYWORD_OVERRIDE
int openQueueAsync(QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
Call & expect_start(const bsls::TimeInterval &timeout=bsls::TimeInterval())
int startAsync(const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
Call & expect_openQueue(QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
bool popPostedEvent(bmqa::MessageEvent *event)
Definition: bmqa_mocksession.h:1530
MockSession(const bmqt::SessionOptions &options=bmqt::SessionOptions(), bslma::Allocator *allocator=0)
CloseQueueStatus closeQueueSync(QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
int confirmMessage(const Message &message) BSLS_KEYWORD_OVERRIDE
Call & expect_confirmMessage(const Message &message)
Call & expect_openQueueAsync(QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
Call & expect_configureQueueAsync(QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
void stop() BSLS_KEYWORD_OVERRIDE
OpenQueueStatus openQueueSync(QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
void loadConfirmEventBuilder(ConfirmEventBuilder *builder) BSLS_KEYWORD_OVERRIDE
int configureQueueAsync(QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
Call & expect_closeQueue(QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval())
void loadMessageEventBuilder(MessageEventBuilder *builder) BSLS_KEYWORD_OVERRIDE
Call & expect_confirmMessages(ConfirmEventBuilder *builder)
Call & expect_post(const MessageEvent &messageEvent)
int start(const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
Call & expect_nextEvent(const bsls::TimeInterval &timeout=bsls::TimeInterval())
Call & expect_configureQueueSync(QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
int closeQueue(QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
Call & expect_closeQueueSync(QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval())
ConfigureQueueStatus configureQueueSync(QueueId *queueId, const bmqt::QueueOptions &options, const bsls::TimeInterval &timeout) BSLS_KEYWORD_OVERRIDE
Call & expect_configureQueue(QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
Event nextEvent(const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
void enqueueEvent(const bmqa::Event &event)
bool emitEvent(int numEvents=1)
bsl::function< void(const char *description, const char *file, int line)> FailureCb
Definition: bmqa_mocksession.h:802
int openQueue(QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
int configureMessageDumping(const bslstl::StringRef &command) BSLS_KEYWORD_OVERRIDE
Call & expect_closeQueueAsync(QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval())
int post(const MessageEvent &messageEvent) BSLS_KEYWORD_OVERRIDE
Call & expect_startAsync(const bsls::TimeInterval &timeout=bsls::TimeInterval())
Call & expect_openQueueSync(QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
Definition: bmqa_openqueuestatus.h:62
Value-semantic efficient identifier for a queue.
Definition: bmqa_queueid.h:59
Definition: bmqa_session.h:611
Definition: bmqt_correlationid.h:193
Definition: bmqt_messageguid.h:95
Value-semantic type for options related to a queue.
Definition: bmqt_queueoptions.h:66
Value semantic type representing a URI.
Definition: bmqt_uri.h:157
Definition: bmqa_abstractsession.h:42
Struct representing parameters for an ack message.
Definition: bmqa_mocksession.h:638
QueueId d_queueId
QueueId for message being referred to.
Definition: bmqa_mocksession.h:651
bmqt::MessageGUID d_guid
Message GUID of confirmed message.
Definition: bmqa_mocksession.h:648
bmqt::CorrelationId d_correlationId
CorrelationId.
Definition: bmqa_mocksession.h:645
AckParams(const bmqt::AckResult::Enum status, const bmqt::CorrelationId &correlationId, const bmqt::MessageGUID &guid, const bmqa::QueueId &queueId)
bmqt::AckResult::Enum d_status
Status code.
Definition: bmqa_mocksession.h:642
Struct representing parameters for a push message.
Definition: bmqa_mocksession.h:666
MessageProperties d_properties
Optionally specified properties for message.
Definition: bmqa_mocksession.h:679
PushMessageParams(const bdlbb::Blob &payload, const bmqa::QueueId &queueId, const bmqt::MessageGUID &guid, const MessageProperties &properties)
QueueId d_queueId
QueueId for this message.
Definition: bmqa_mocksession.h:673
bdlbb::Blob d_payload
Payload of message.
Definition: bmqa_mocksession.h:670
bmqt::MessageGUID d_guid
GUID for message.
Definition: bmqa_mocksession.h:676
Utility methods to create bmqa events.
Definition: bmqa_mocksession.h:615
static Event createSessionEvent(bmqt::SessionEventType::Enum sessionEventType, const bmqt::CorrelationId &correlationId, const int errorCode, const bslstl::StringRef &errorDescription, bslma::Allocator *allocator)
static CloseQueueStatus createCloseQueueStatus(const QueueId &queueId, bmqt::CloseQueueResult::Enum statusCode, const bsl::string &errorDescription, bslma::Allocator *allocator=0)
static OpenQueueStatus createOpenQueueStatus(const QueueId &queueId, bmqt::OpenQueueResult::Enum statusCode, const bsl::string &errorDescription, bslma::Allocator *allocator=0)
static Event createAckEvent(const bsl::vector< AckParams > &acks, bdlbb::BlobBufferFactory *bufferFactory, bslma::Allocator *allocator)
static ConfigureQueueStatus createConfigureQueueStatus(const QueueId &queueId, bmqt::ConfigureQueueResult::Enum statusCode, const bsl::string &errorDescription, bslma::Allocator *allocator=0)
static Event createQueueSessionEvent(bmqt::SessionEventType::Enum sessionEventType, QueueId *queueId, const bmqt::CorrelationId &correlationId, int errorCode, const bslstl::StringRef &errorDescription, bslma::Allocator *allocator)
static Event createPushEvent(const bsl::vector< PushMessageParams > &pushEventParams, bdlbb::BlobBufferFactory *bufferFactory, bslma::Allocator *allocator)
Enum
Definition: bmqt_resultcode.h:437
Enum
Definition: bmqt_resultcode.h:287
Enum
Definition: bmqt_resultcode.h:215
Enum
Definition: bmqt_resultcode.h:137
Enum
Definition: bmqt_sessioneventtype.h:116