Line data Source code
1 : /**
2 : * @file ZmqSubscriber_test.cxx ZmqSubscriber class Unit Tests
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "ipm/Subscriber.hpp"
10 : #include "ipm/ZmqContext.hpp"
11 :
12 : #define BOOST_TEST_MODULE ZmqSubscriber_test // NOLINT
13 :
14 : #include "boost/test/unit_test.hpp"
15 :
16 : #include <string>
17 : #include <vector>
18 :
19 : using namespace dunedaq::ipm;
20 :
21 : BOOST_AUTO_TEST_SUITE(ZmqSubscriber_test)
22 :
23 2 : BOOST_AUTO_TEST_CASE(BasicTests)
24 : {
25 1 : auto the_subscriber = make_ipm_subscriber("ZmqSubscriber");
26 1 : BOOST_REQUIRE(the_subscriber != nullptr);
27 1 : BOOST_REQUIRE(!the_subscriber->can_receive());
28 :
29 1 : auto the_receiver = make_ipm_receiver("ZmqSubscriber");
30 1 : BOOST_REQUIRE(the_receiver != nullptr);
31 1 : }
32 :
33 2 : BOOST_AUTO_TEST_CASE(Errors)
34 : {
35 1 : auto the_subscriber = make_ipm_subscriber("ZmqSubscriber");
36 1 : BOOST_REQUIRE(the_subscriber != nullptr);
37 1 : BOOST_REQUIRE(!the_subscriber->can_receive());
38 :
39 1 : nlohmann::json config_json;
40 :
41 1 : config_json["connection_string"] = "not a uri";
42 1 : the_subscriber->connect_for_receives(config_json);
43 1 : BOOST_REQUIRE(the_subscriber->can_receive());
44 :
45 1 : config_json["connection_string"] = "tcp://thishostddoesnotexist";
46 1 : the_subscriber->connect_for_receives(config_json);
47 1 : BOOST_REQUIRE(the_subscriber->can_receive());
48 :
49 1 : config_json["connection_string"] = "badproto://default";
50 1 : the_subscriber->connect_for_receives(config_json);
51 1 : BOOST_REQUIRE(the_subscriber->can_receive());
52 1 : }
53 :
54 : BOOST_AUTO_TEST_SUITE_END()
|