@@ -877,7 +877,7 @@ TEST_P(DDSContentFilter, CorrectGAPSendingTwoReader)
877877 {
878878 total_count_2 = status.total_count ;
879879 }).init ();
880- ASSERT_TRUE (reader .isInitialized ());
880+ ASSERT_TRUE (reader_2 .isInitialized ());
881881
882882 // Set up the writer
883883 PubSubWriter<HelloWorldPubSubType> writer (TEST_TOPIC_NAME);
@@ -946,6 +946,97 @@ TEST(DDSContentFilter, filter_other_type_name)
946946 ASSERT_EQ (dds::DomainParticipantFactory::get_instance ()->delete_participant (participant), RETCODE_OK);
947947}
948948
949+
950+ /*
951+ * Regression test for https://eprosima.easyredmine.com/issues/24038
952+ *
953+ * This test checks that a DDSSQL content filter can be created with a type name that is different from the one
954+ * in the generated type support.
955+ */
956+ TEST (DDSContentFilter, reusing_reader_proxy)
957+ {
958+ int32_t total_count {0 };
959+ int32_t total_count_2 {0 };
960+
961+ PubSubReader<HelloWorldPubSubType> reader (TEST_TOPIC_NAME, " index = 1 OR index = 2 OR index = 6" , {}, true , false ,
962+ false );
963+ reader
964+ .reliability (RELIABLE_RELIABILITY_QOS)
965+ .durability_kind (TRANSIENT_LOCAL_DURABILITY_QOS)
966+ .sample_lost_status_functor ([&total_count](const SampleLostStatus& status)
967+ {
968+ total_count = status.total_count ;
969+ }).init ();
970+ ASSERT_TRUE (reader.isInitialized ());
971+
972+ auto udp_transport = std::make_shared<UDPv4TransportDescriptor>();
973+
974+ // Set up the writer
975+ PubSubWriter<HelloWorldPubSubType> writer (TEST_TOPIC_NAME);
976+ writer
977+ .add_user_transport_to_pparams (udp_transport)
978+ .disable_builtin_transport ()
979+ .durability_kind (TRANSIENT_LOCAL_DURABILITY_QOS)
980+ .history_depth (10 )
981+ // .heartbeat_period_seconds(100)
982+ .init ();
983+ ASSERT_TRUE (writer.isInitialized ());
984+
985+ // Wait for discovery
986+ reader.wait_discovery ();
987+ writer.wait_discovery ();
988+
989+ // Send 10 samples
990+ auto data = default_helloworld_data_generator ();
991+
992+ decltype (data) expected_data;
993+ expected_data.push_back (*data.begin ()); // index 1
994+ expected_data.push_back (*std::next (data.begin ())); // index 2
995+ expected_data.push_back (*std::next (data.begin (), 5 )); // index 6
996+ decltype (data) expected_data_2;
997+ expected_data_2.push_back (*std::next (data.begin (), 8 )); // index 9
998+ expected_data_2.push_back (*std::next (data.begin (), 2 )); // index 3
999+ expected_data_2.push_back (*std::next (data.begin (), 3 )); // index 4
1000+
1001+ reader.startReception (expected_data);
1002+
1003+ writer.send (data, 50 );
1004+
1005+ // Wait for reception and check
1006+ reader.block_for_all ();
1007+ ASSERT_EQ (0 , total_count);
1008+
1009+ reader.destroy ();
1010+
1011+ data = default_helloworld_data_generator (4 );
1012+
1013+ writer.send (data, 50 );
1014+
1015+ PubSubReader<HelloWorldPubSubType> reader_2 (TEST_TOPIC_NAME, " index = 3 OR index = 4 OR index = 9" , {}, true , false ,
1016+ false );
1017+ reader_2
1018+ .reliability (RELIABLE_RELIABILITY_QOS)
1019+ .durability_kind (TRANSIENT_LOCAL_DURABILITY_QOS)
1020+ .sample_lost_status_functor ([&total_count_2](const SampleLostStatus& status)
1021+ {
1022+ total_count_2 += status.total_count ;
1023+ }).init ();
1024+ ASSERT_TRUE (reader_2.isInitialized ());
1025+
1026+
1027+ reader_2.wait_discovery ();
1028+ writer.wait_discovery ();
1029+
1030+ data = default_helloworld_data_generator (1 );
1031+
1032+ writer.send (data, 50 );
1033+
1034+ reader_2.startReception (expected_data_2);
1035+
1036+ // Wait for reception and check
1037+ reader_2.block_for_all ();
1038+ }
1039+
9491040#ifdef INSTANTIATE_TEST_SUITE_P
9501041#define GTEST_INSTANTIATE_TEST_MACRO (x, y, z, w ) INSTANTIATE_TEST_SUITE_P(x, y, z, w)
9511042#else
0 commit comments