libbmq  a5f8a06ba1d16cb5a65643e1fa7f1a1d6aadef40
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 
542 
543 // BMQ
544 #include <bmqa_abstractsession.h>
545 #include <bmqa_closequeuestatus.h>
548 #include <bmqa_openqueuestatus.h>
549 #include <bmqa_queueid.h>
550 #include <bmqa_session.h> // for 'bmqa::SessionEventHandler'
551 #include <bmqt_queueoptions.h>
552 #include <bmqt_sessionoptions.h>
553 
554 // BDE
555 #include <ball_log.h>
556 #include <bdlb_variant.h>
557 #include <bdlbb_blob.h>
558 #include <bdlbb_pooledblobbufferfactory.h>
559 #include <bsl_cstddef.h>
560 #include <bsl_deque.h>
561 #include <bsl_functional.h>
562 #include <bsl_memory.h>
563 #include <bsl_string.h>
564 #include <bsl_unordered_map.h>
565 #include <bsl_unordered_set.h>
566 #include <bslma_allocator.h>
567 #include <bslma_managedptr.h>
568 #include <bslma_usesbslmaallocator.h>
569 #include <bslmf_nestedtraitdeclaration.h>
570 #include <bslmt_mutex.h>
571 #include <bsls_alignedbuffer.h>
572 #include <bsls_assert.h>
573 #include <bsls_timeinterval.h>
574 #include <bsls_types.h>
575 
576 namespace BloombergLP {
577 
578 // FORWARD DECLARATION
579 namespace bmqimp {
580 class Event;
581 }
582 namespace bmqimp {
583 class MessageCorrelationIdContainer;
584 }
585 namespace bmqimp {
586 struct Stat;
587 }
588 namespace bmqst {
589 class StatContext;
590 }
591 
592 namespace bmqa {
593 
594 // FORWARD DECLARATION
595 class ConfirmEventBuilder;
596 
597 // Record an expected method 'CALL' into the specified mock session 'OBJ'.
598 #define BMQA_EXPECT_CALL(OBJ, CALL) \
599  (((OBJ).expect_##CALL).fromLocation(__FILE__, __LINE__))
600 
601 // ======================
602 // struct MockSessionUtil
603 // ======================
604 
607  private:
608  // PRIVATE TYPES
609 
612  typedef bsl::shared_ptr<bmqimp::Event> EventImplSp;
613 
616  typedef bsl::shared_ptr<bmqimp::Queue> QueueImplSp;
617 
618  public:
619  // PUBLIC TYPES
620 
622  struct AckParams {
623  // PUBLIC DATA
624 
627 
630 
633 
636 
637  // CREATORS
638 
642  const bmqt::CorrelationId& correlationId,
643  const bmqt::MessageGUID& guid,
644  const bmqa::QueueId& queueId);
645  };
646 
647  // PUBLIC TYPES
648 
651  // PUBLIC DATA
652 
654  bdlbb::Blob d_payload;
655 
658 
661 
664 
665  // CREATORS
666 
669  PushMessageParams(const bdlbb::Blob& payload,
670  const bmqa::QueueId& queueId,
671  const bmqt::MessageGUID& guid,
672  const MessageProperties& properties);
673  };
674 
675  // CLASS METHODS
676 
680  static Event createAckEvent(const bsl::vector<AckParams>& acks,
681  bdlbb::BlobBufferFactory* bufferFactory,
682  bslma::Allocator* allocator);
683 
688  static Event
689  createPushEvent(const bsl::vector<PushMessageParams>& pushEventParams,
690  bdlbb::BlobBufferFactory* bufferFactory,
691  bslma::Allocator* allocator);
692 
698  static Event
700  QueueId* queueId,
701  const bmqt::CorrelationId& correlationId,
702  int errorCode,
703  const bslstl::StringRef& errorDescription,
704  bslma::Allocator* allocator);
705 
710  static Event
712  const bmqt::CorrelationId& correlationId,
713  const int errorCode,
714  const bslstl::StringRef& errorDescription,
715  bslma::Allocator* allocator);
716 
720  static OpenQueueStatus
722  bmqt::OpenQueueResult::Enum statusCode,
723  const bsl::string& errorDescription,
724  bslma::Allocator* allocator = 0);
725 
729  static ConfigureQueueStatus
732  const bsl::string& errorDescription,
733  bslma::Allocator* allocator = 0);
734 
738  static CloseQueueStatus
740  bmqt::CloseQueueResult::Enum statusCode,
741  const bsl::string& errorDescription,
742  bslma::Allocator* allocator = 0);
743 };
744 
745 // =================
746 // class MockSession
747 // =================
748 
750 class MockSession : public AbstractSession {
751  public:
752  // CLASS METHODS
753 
766  static void initialize(bslma::Allocator* allocator = 0);
767 
774  static void shutdown();
775 
776  // PUBLIC TYPES
777 
782  typedef bsl::function<
783  void(const char* description, const char* file, int line)>
785 
786  private:
787  // CLASS-SCOPE CATEGORY
788  BALL_LOG_SET_CLASS_CATEGORY("BMQA.MOCKSESSION");
789 
790  private:
791  // CONSTANTS
792 
797  static const int k_MAX_SIZEOF_BMQC_TWOKEYHASHMAP = 256;
798 
799  // PRIVATE TYPES
800 
802  typedef bsls::AlignedBuffer<k_MAX_SIZEOF_BMQC_TWOKEYHASHMAP>
803  TwoKeyHashMapBuffer;
804 
806  typedef bsl::shared_ptr<bmqimp::Queue> QueueImplSp;
807 
809  typedef bsl::shared_ptr<bmqimp::Event> EventImplSp;
810 
812  typedef bsl::shared_ptr<bmqimp::Stat> StatImplSp;
813 
815  typedef bsl::shared_ptr<bmqimp::MessageCorrelationIdContainer>
816  CorrelationIdContainerSp;
817 
818  typedef bsl::function<void()> CallbackFn;
819 
822  struct Job {
823  // PUBLIC DATA
824 
826  CallbackFn d_callback;
827 
829  QueueImplSp d_queue;
830 
834 
836  int d_status;
837  };
838 
839  typedef bdlb::Variant<Event, Job> EventOrJob;
840 
843  enum Method {
844  e_START,
845  e_START_ASYNC,
846  e_STOP,
847  e_STOP_ASYNC,
848  e_FINALIZE_STOP,
849  e_OPEN_QUEUE,
850  e_OPEN_QUEUE_SYNC,
851  e_OPEN_QUEUE_ASYNC,
852  e_OPEN_QUEUE_ASYNC_CALLBACK,
853  e_CLOSE_QUEUE,
854  e_CLOSE_QUEUE_SYNC,
855  e_CLOSE_QUEUE_ASYNC,
856  e_CLOSE_QUEUE_ASYNC_CALLBACK,
857  e_CONFIGURE_QUEUE,
858  e_CONFIGURE_QUEUE_SYNC,
859  e_CONFIGURE_QUEUE_ASYNC,
860  e_CONFIGURE_QUEUE_ASYNC_CALLBACK,
861  e_NEXT_EVENT,
862  e_POST,
863  e_CONFIRM_MESSAGE,
864  e_CONFIRM_MESSAGES
865  };
866 
867  struct Call {
868  // PUBLIC TYPES
869 
871  typedef bsl::vector<EventOrJob> EventsAndJobs;
872 
873  // PUBLIC DATA
874 
876  int d_rc;
877 
879  Method d_method;
880 
882  int d_line;
883 
885  bsl::string d_file;
886 
888  bmqt::Uri d_uri;
889 
891  bsls::Types::Uint64 d_flags;
892 
894  bmqt::QueueOptions d_queueOptions;
895 
897  bsls::TimeInterval d_timeout;
898 
901  OpenQueueCallback d_openQueueCallback;
902 
905  ConfigureQueueCallback d_configureQueueCallback;
906 
909  CloseQueueCallback d_closeQueueCallback;
910 
912  bmqa::OpenQueueStatus d_openQueueResult;
913 
915  bmqa::ConfigureQueueStatus d_configureQueueResult;
916 
918  bmqa::CloseQueueStatus d_closeQueueResult;
919 
921  EventsAndJobs d_emittedEvents;
922 
924  Event d_returnEvent;
925 
927  MessageEvent d_messageEvent;
928 
930  MessageConfirmationCookie d_cookie;
931 
933  bslma::Allocator* d_allocator_p;
934 
935  // TRAITS
936  BSLMF_NESTED_TRAIT_DECLARATION(Call, bslma::UsesBslmaAllocator)
937 
938  // CREATORS
939 
940 
942  Call(Method method, bslma::Allocator* allocator);
943 
944  Call(const Call& other, bslma::Allocator* allocator);
945 
946  // MANIPULATORS
947 
952  Call& fromLocation(const char* file, int line);
953 
956  Call& returning(int rc);
957 
961  Call& returning(const bmqa::OpenQueueStatus& result);
962 
966  Call& returning(const bmqa::ConfigureQueueStatus& result);
967 
971  Call& returning(const bmqa::CloseQueueStatus& result);
972 
975  Call& returning(const Event& event);
976 
979  Call& emitting(const Event& event);
980 
984  Call& emitting(const OpenQueueStatus& openQueueResult);
985 
989  Call& emitting(const ConfigureQueueStatus& configureQueueResutl);
990 
994  Call& emitting(const CloseQueueStatus& closeQueueResult);
995 
996  // ACCESSORS
997 
999  const char* methodName() const;
1000  };
1001 
1003  typedef bsl::deque<Call> CallQueue;
1004 
1006  typedef bsl::deque<bmqa::MessageEvent> PostedEvents;
1007 
1008  // DATA
1009 
1011  bdlbb::PooledBlobBufferFactory d_blobBufferFactory;
1012 
1014  bslma::ManagedPtr<SessionEventHandler> d_eventHandler_mp;
1015 
1017  mutable CallQueue d_calls;
1018 
1020  mutable bsl::deque<EventOrJob> d_eventsAndJobs;
1021 
1023  bsl::unordered_set<bmqt::MessageGUID> d_unconfirmedGUIDs;
1024 
1026  TwoKeyHashMapBuffer d_twoKeyHashMapBuffer;
1027 
1030  FailureCb d_failureCb;
1031 
1033  int d_lastQueueId;
1034 
1036  CorrelationIdContainerSp d_corrIdContainer_sp;
1037 
1039  PostedEvents d_postedEvents;
1040 
1042  mutable bslmt::Mutex d_mutex;
1043 
1045  bslma::ManagedPtr<bmqst::StatContext> d_rootStatContext_mp;
1046 
1048  StatImplSp d_queuesStats_sp;
1049 
1051  bmqt::SessionOptions d_sessionOptions;
1052 
1054  bslma::Allocator* d_allocator_p;
1055 
1056  private:
1057  // PRIVATE CLASS METHODS
1058 
1060  static const char* toAscii(const Method method);
1061 
1062  // PRIVATE MANIPULATORS
1063 
1065  void initializeStats();
1066 
1074  void openQueueImp(QueueId* queueId,
1075  const bmqt::QueueOptions& options,
1076  const bmqt::Uri& uri,
1077  bsls::Types::Uint64 flags,
1078  bool async);
1079 
1083  void processIfQueueEvent(Event* event);
1084 
1088  void processIfQueueJob(Job* job);
1089 
1092  void processIfPushEvent(const Event& event);
1093 
1094  // PRIVATE ACCESSORS
1095 
1098  void assertWrongCall(const Method method) const;
1099 
1102  void assertWrongCall(const Method method, const Call& expectedCall) const;
1103 
1108  template <class T, class U>
1109  void assertWrongArg(const T& expected,
1110  const U& actual,
1111  const Method method,
1112  const char* arg,
1113  const Call& call) const;
1114 
1115  public:
1116  // TRAITS
1117  BSLMF_NESTED_TRAIT_DECLARATION(MockSession, bslma::UsesBslmaAllocator)
1118 
1119  // CREATORS
1120 
1121 
1126  explicit MockSession(
1127  const bmqt::SessionOptions& options = bmqt::SessionOptions(),
1128  bslma::Allocator* allocator = 0);
1129 
1135  explicit MockSession(
1136  bslma::ManagedPtr<SessionEventHandler> eventHandler,
1137  const bmqt::SessionOptions& options = bmqt::SessionOptions(),
1138  bslma::Allocator* allocator = 0);
1139 
1141  ~MockSession() BSLS_KEYWORD_OVERRIDE;
1142 
1143  // MANIPULATORS
1144  // (specific to 'bmqa::MockSession')
1145 
1149  void enqueueEvent(const bmqa::Event& event);
1150 
1156  bool emitEvent(int numEvents = 1);
1157 
1158  Call&
1159  expect_start(const bsls::TimeInterval& timeout = bsls::TimeInterval());
1161  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1162  Call& expect_stop();
1165  Call&
1167  const bmqt::Uri& uri,
1168  bsls::Types::Uint64 flags,
1169  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1170  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1172  QueueId* queueId,
1173  const bmqt::Uri& uri,
1174  bsls::Types::Uint64 flags,
1175  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1176  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1177 
1179  QueueId* queueId,
1180  const bmqt::Uri& uri,
1181  bsls::Types::Uint64 flags,
1182  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1183  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1185  QueueId* queueId,
1186  const bmqt::Uri& uri,
1187  bsls::Types::Uint64 flags,
1188  const OpenQueueCallback& callback,
1189  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1190  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1191 
1193  QueueId* queueId,
1194  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1196  QueueId* queueId,
1197  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1198 
1200  QueueId* queueId,
1201  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1203  QueueId* queueId,
1204  const CloseQueueCallback& callback,
1205  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1207  QueueId* queueId,
1208  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1209  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1211  QueueId* queueId,
1212  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1213  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1215  QueueId* queueId,
1216  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1217  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1218 
1220  QueueId* queueId,
1221  const bmqt::QueueOptions& options,
1222  const ConfigureQueueCallback& callback,
1223  const bsls::TimeInterval& timeout = bsls::TimeInterval());
1224 
1225  Call&
1226  expect_nextEvent(const bsls::TimeInterval& timeout = bsls::TimeInterval());
1227  Call& expect_post(const MessageEvent& messageEvent);
1228  Call& expect_confirmMessage(const Message& message);
1230 
1237 
1238  // MANIPULATORS
1239  // (virtual bmqa::AbstractSession)
1240  int start(const bsls::TimeInterval& timeout = bsls::TimeInterval())
1241  BSLS_KEYWORD_OVERRIDE;
1242 
1247  int startAsync(const bsls::TimeInterval& timeout = bsls::TimeInterval())
1248  BSLS_KEYWORD_OVERRIDE;
1249 
1250  void stop() BSLS_KEYWORD_OVERRIDE;
1251 
1255  void stopAsync() BSLS_KEYWORD_OVERRIDE;
1256 
1260  void finalizeStop() BSLS_KEYWORD_OVERRIDE;
1261 
1265  BSLS_KEYWORD_OVERRIDE;
1266 
1270  BSLS_KEYWORD_OVERRIDE;
1271 
1274  void
1275  loadMessageProperties(MessageProperties* buffer) BSLS_KEYWORD_OVERRIDE;
1276 
1279 
1282  int getQueueId(QueueId* queueId,
1283  const bmqt::Uri& uri) BSLS_KEYWORD_OVERRIDE;
1284 
1287  int getQueueId(QueueId* queueId, const bmqt::CorrelationId& correlationId)
1288  BSLS_KEYWORD_OVERRIDE;
1289 
1294  int openQueue(QueueId* queueId,
1295  const bmqt::Uri& uri,
1296  bsls::Types::Uint64 flags,
1297  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1298  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1299  BSLS_KEYWORD_OVERRIDE;
1300 
1311  const bmqt::Uri& uri,
1312  bsls::Types::Uint64 flags,
1313  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1314  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1315  BSLS_KEYWORD_OVERRIDE;
1316 
1321  int
1323  const bmqt::Uri& uri,
1324  bsls::Types::Uint64 flags,
1325  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1326  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1327  BSLS_KEYWORD_OVERRIDE;
1328 
1345  void
1347  const bmqt::Uri& uri,
1348  bsls::Types::Uint64 flags,
1349  const OpenQueueCallback& callback,
1350  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1351  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1352  BSLS_KEYWORD_OVERRIDE;
1353 
1358  int
1360  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1361  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1362  BSLS_KEYWORD_OVERRIDE;
1363 
1369  const bmqt::QueueOptions& options,
1370  const bsls::TimeInterval& timeout)
1371  BSLS_KEYWORD_OVERRIDE;
1372 
1378  QueueId* queueId,
1379  const bmqt::QueueOptions& options = bmqt::QueueOptions(),
1380  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1381  BSLS_KEYWORD_OVERRIDE;
1382 
1392  const bmqt::QueueOptions& options,
1393  const ConfigureQueueCallback& callback,
1394  const bsls::TimeInterval& timeout =
1395  bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE;
1396 
1401  int closeQueue(QueueId* queueId,
1402  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1403  BSLS_KEYWORD_OVERRIDE;
1404 
1412  const bsls::TimeInterval& timeout = bsls::TimeInterval())
1413  BSLS_KEYWORD_OVERRIDE;
1414 
1419  int closeQueueAsync(QueueId* queueId,
1420  const bsls::TimeInterval& timeout =
1421  bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE;
1422 
1430  void closeQueueAsync(QueueId* queueId,
1431  const CloseQueueCallback& callback,
1432  const bsls::TimeInterval& timeout =
1433  bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE;
1434 
1441  Event nextEvent(const bsls::TimeInterval& timeout = bsls::TimeInterval())
1442  BSLS_KEYWORD_OVERRIDE;
1443 
1448  int post(const MessageEvent& messageEvent) BSLS_KEYWORD_OVERRIDE;
1449 
1450  int confirmMessage(const Message& message) BSLS_KEYWORD_OVERRIDE;
1452  BSLS_KEYWORD_OVERRIDE;
1453 
1457  int confirmMessages(ConfirmEventBuilder* builder) BSLS_KEYWORD_OVERRIDE;
1458 
1459  int configureMessageDumping(const bslstl::StringRef& command)
1460  BSLS_KEYWORD_OVERRIDE;
1461  // NOT IMPLEMENTED
1462 
1466  void setFailureCallback(const FailureCb& failureCb);
1467 
1471  bool popPostedEvent(bmqa::MessageEvent* event);
1472 
1473  // ACCESSORS
1474 
1478  size_t unconfirmedMessages() const;
1479 };
1480 
1481 // ============================================================================
1482 // INLINE DEFINITIONS
1483 // ============================================================================
1484 
1485 // -----------------
1486 // class MockSession
1487 // -----------------
1488 
1489 inline void MockSession::setFailureCallback(const FailureCb& failureCb)
1490 {
1491  d_failureCb = failureCb;
1492 }
1493 
1495 {
1496  return d_unconfirmedGUIDs.size();
1497 }
1498 
1500 {
1501  // PRECONDITIONS
1502  BSLS_ASSERT(event);
1503 
1504  bslmt::LockGuard<bslmt::Mutex> guard(&d_mutex); // LOCKED
1505 
1506  if (d_postedEvents.empty()) {
1507  return false; // RETURN
1508  }
1509 
1510  *event = d_postedEvents.front();
1511  d_postedEvents.pop_front();
1512 
1513  return true;
1514 }
1515 
1516 } // close package namespace
1517 } // close enterprise namespace
1518 
1519 #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:750
void loadMessageProperties(MessageProperties *buffer) BSLS_KEYWORD_OVERRIDE
int confirmMessages(ConfirmEventBuilder *builder) BSLS_KEYWORD_OVERRIDE
size_t unconfirmedMessages() const
Definition: bmqa_mocksession.h:1494
void finalizeStop() BSLS_KEYWORD_OVERRIDE
void setFailureCallback(const FailureCb &failureCb)
Definition: bmqa_mocksession.h:1489
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:1499
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:784
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:622
QueueId d_queueId
QueueId for message being referred to.
Definition: bmqa_mocksession.h:635
bmqt::MessageGUID d_guid
Message GUID of confirmed message.
Definition: bmqa_mocksession.h:632
bmqt::CorrelationId d_correlationId
CorrelationId.
Definition: bmqa_mocksession.h:629
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:626
Struct representing parameters for a push message.
Definition: bmqa_mocksession.h:650
MessageProperties d_properties
Optionally specified properties for message.
Definition: bmqa_mocksession.h:663
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:657
bdlbb::Blob d_payload
Payload of message.
Definition: bmqa_mocksession.h:654
bmqt::MessageGUID d_guid
GUID for message.
Definition: bmqa_mocksession.h:660
Utility methods to create bmqa events.
Definition: bmqa_mocksession.h:606
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