@@ -406,6 +406,71 @@ BOOST_AUTO_TEST_CASE(socket__pub_sub__grasslands_asynchronous_connect_first__rec
406
406
SEND_MESSAGES_UNTIL (publisher, received);
407
407
}
408
408
409
+ // Default receive-all filter is removed. No message received.
410
+ BOOST_AUTO_TEST_CASE (socket__pub_sub__grasslands_asynchronous__no_subscription)
411
+ {
412
+ zmq::context context;
413
+ BOOST_REQUIRE (context);
414
+
415
+ std::promise<bool > received;
416
+
417
+ simple_thread publisher_thread ([&]()
418
+ {
419
+ zmq::socket publisher (context, role::publisher);
420
+ BOOST_REQUIRE (publisher);
421
+ BC_REQUIRE_SUCCESS (publisher.bind ({ TEST_PUBLIC_ENDPOINT }));
422
+ SEND_MESSAGES_UNTIL (publisher, received); // begin sending now, needs own thread.
423
+ });
424
+
425
+ simple_thread subscriber_thread ([&]()
426
+ {
427
+ zmq::socket subscriber (context, role::subscriber);
428
+ BOOST_REQUIRE (subscriber);
429
+
430
+ data_chunk subscribe_all;
431
+ BOOST_REQUIRE (subscriber.set_unsubscription (subscribe_all));
432
+
433
+ BC_REQUIRE_SUCCESS (subscriber.connect ({ TEST_PUBLIC_ENDPOINT }));
434
+
435
+ RECEIVE_FAILURE (subscriber);
436
+ received.set_value (true );
437
+ });
438
+ }
439
+
440
+ // Default receive-all filter is removed. "hello" filter is added.
441
+ BOOST_AUTO_TEST_CASE (socket__pub_sub__grasslands_asynchronous__hello_subscription_only)
442
+ {
443
+ zmq::context context;
444
+ BOOST_REQUIRE (context);
445
+
446
+ std::promise<bool > received;
447
+
448
+ simple_thread publisher_thread ([&]()
449
+ {
450
+ zmq::socket publisher (context, role::publisher);
451
+ BOOST_REQUIRE (publisher);
452
+ BC_REQUIRE_SUCCESS (publisher.bind ({ TEST_PUBLIC_ENDPOINT }));
453
+ SEND_MESSAGES_UNTIL (publisher, received);
454
+ });
455
+
456
+ simple_thread subscriber_thread ([&]()
457
+ {
458
+ zmq::socket subscriber (context, role::subscriber);
459
+ BOOST_REQUIRE (subscriber);
460
+
461
+ data_chunk subscribe_all;
462
+ BOOST_REQUIRE (subscriber.set_unsubscription (subscribe_all));
463
+
464
+ std::string topic = TEST_TOPIC;
465
+ BOOST_REQUIRE (subscriber.set_subscription (to_chunk (topic)));
466
+
467
+ BC_REQUIRE_SUCCESS (subscriber.connect ({ TEST_PUBLIC_ENDPOINT }));
468
+
469
+ RECEIVE_MESSAGE (subscriber);
470
+ received.set_value (true );
471
+ });
472
+ }
473
+
409
474
BOOST_AUTO_TEST_CASE (socket__xpub_xsub__grasslands_two_threads__subscribed)
410
475
{
411
476
zmq::context context;
0 commit comments