diff --git a/fastdds_python/test/api/DEFAULT_FASTRTPS_PROFILES.xml b/fastdds_python/test/api/DEFAULT_FASTRTPS_PROFILES.xml deleted file mode 100644 index ad16f819..00000000 --- a/fastdds_python/test/api/DEFAULT_FASTRTPS_PROFILES.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - 3 - - test_name - - - - - - - - partition_name_c - - - - - - - - - - partition_name_b - - - - - - - - - VOLATILE - - - - - - - - RELIABLE - - - - - diff --git a/fastdds_python/test/api/test_domainparticipant.py b/fastdds_python/test/api/test_domainparticipant.py index ef4056a2..a6e40f6e 100644 --- a/fastdds_python/test/api/test_domainparticipant.py +++ b/fastdds_python/test/api/test_domainparticipant.py @@ -796,3 +796,248 @@ def second_participant(): factory.delete_participant(participant)) assert(fastdds.RETCODE_OK == factory.delete_participant(participant2)) + +def test_get_publisher_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + qos = fastdds.PublisherQos() + ret = participant.get_publisher_qos_from_xml( + xml_content, qos, 'test_publisher_profile') + assert(fastdds.RETCODE_OK == ret) + + qos_no_name = fastdds.PublisherQos() + ret = participant.get_publisher_qos_from_xml( + xml_content, qos_no_name) + assert(fastdds.RETCODE_OK == ret) + + # Non matching name takes the first publisher found (the only one) + assert(qos == qos_no_name) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_default_publisher_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + default_qos = fastdds.PublisherQos() + ret = participant.get_default_publisher_qos_from_xml( + xml_content, default_qos) + assert(fastdds.RETCODE_OK == ret) + + qos = fastdds.PublisherQos() + ret = participant.get_publisher_qos_from_xml( + xml_content, qos, 'test_publisher_profile') + assert(fastdds.RETCODE_OK == ret) + + assert(default_qos == qos) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_subscriber_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + qos = fastdds.SubscriberQos() + ret = participant.get_subscriber_qos_from_xml( + xml_content, qos, 'test_subscriber_profile') + assert(fastdds.RETCODE_OK == ret) + + qos_no_name = fastdds.SubscriberQos() + ret = participant.get_subscriber_qos_from_xml( + xml_content, qos_no_name) + assert(fastdds.RETCODE_OK == ret) + + # Non matching name takes the first subscriber found (the only one) + assert(qos == qos_no_name) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_default_subscriber_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + default_qos = fastdds.SubscriberQos() + ret = participant.get_default_subscriber_qos_from_xml( + xml_content, default_qos) + assert(fastdds.RETCODE_OK == ret) + + qos = fastdds.SubscriberQos() + ret = participant.get_subscriber_qos_from_xml( + xml_content, qos, 'test_subscriber_profile') + assert(fastdds.RETCODE_OK == ret) + + assert(default_qos == qos) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_topic_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + qos = fastdds.TopicQos() + ret = participant.get_topic_qos_from_xml( + xml_content, qos, 'test_topic_profile') + assert(fastdds.RETCODE_OK == ret) + + qos_no_name = fastdds.TopicQos() + ret = participant.get_topic_qos_from_xml( + xml_content, qos_no_name) + assert(fastdds.RETCODE_OK == ret) + + # Non matching name takes the first topic found (the only one) + assert(qos == qos_no_name) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_default_topic_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + default_qos = fastdds.TopicQos() + ret = participant.get_default_topic_qos_from_xml( + xml_content, default_qos) + assert(fastdds.RETCODE_OK == ret) + + qos = fastdds.TopicQos() + ret = participant.get_topic_qos_from_xml( + xml_content, qos, 'test_topic_profile') + assert(fastdds.RETCODE_OK == ret) + + assert(default_qos == qos) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_requester_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + qos = fastdds.RequesterQos() + ret = participant.get_requester_qos_from_xml( + xml_content, qos, 'test_requester_profile') + assert(fastdds.RETCODE_OK == ret) + + qos_no_name = fastdds.RequesterQos() + ret = participant.get_requester_qos_from_xml( + xml_content, qos_no_name) + assert(fastdds.RETCODE_OK == ret) + + # Non matching name takes the first requester found (the only one) + assert(qos == qos_no_name) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_default_requester_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + default_qos = fastdds.RequesterQos() + ret = participant.get_default_requester_qos_from_xml( + xml_content, default_qos) + assert(fastdds.RETCODE_OK == ret) + + qos = fastdds.RequesterQos() + ret = participant.get_requester_qos_from_xml( + xml_content, qos, 'test_requester_profile') + assert(fastdds.RETCODE_OK == ret) + + assert(default_qos == qos) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_replier_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + qos = fastdds.ReplierQos() + ret = participant.get_replier_qos_from_xml( + xml_content, qos, 'test_replier_profile') + assert(fastdds.RETCODE_OK == ret) + + qos_no_name = fastdds.ReplierQos() + ret = participant.get_replier_qos_from_xml( + xml_content, qos_no_name) + assert(fastdds.RETCODE_OK == ret) + + # Non matching name takes the first replier found (the only one) + assert(qos == qos_no_name) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_default_replier_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + default_qos = fastdds.ReplierQos() + ret = participant.get_default_replier_qos_from_xml( + xml_content, default_qos) + assert(fastdds.RETCODE_OK == ret) + + qos = fastdds.ReplierQos() + ret = participant.get_replier_qos_from_xml( + xml_content, qos, 'test_replier_profile') + assert(fastdds.RETCODE_OK == ret) + + assert(default_qos == qos) + + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) diff --git a/fastdds_python/test/api/test_domainparticipantfactory.py b/fastdds_python/test/api/test_domainparticipantfactory.py index ad67b9b0..e123cace 100644 --- a/fastdds_python/test/api/test_domainparticipantfactory.py +++ b/fastdds_python/test/api/test_domainparticipantfactory.py @@ -208,3 +208,81 @@ def test(status_mask, listnr=None): fastdds.StatusMask.sample_rejected() << fastdds.StatusMask.subscription_matched(), listener) + +def test_get_participant_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + + qos = fastdds.DomainParticipantQos() + ret = factory.get_participant_qos_from_xml( + xml_content, qos, 'test_participant_profile') + assert(fastdds.RETCODE_OK == ret) + + qos_no_name = fastdds.DomainParticipantQos() + ret = factory.get_participant_qos_from_xml( + xml_content, qos_no_name) + assert(fastdds.RETCODE_OK == ret) + + # Non matching name takes the first participant found (the only one) + assert(qos == qos_no_name) + +def test_get_default_participant_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + + default_qos = fastdds.DomainParticipantQos() + ret = factory.get_default_participant_qos_from_xml( + xml_content, default_qos) + assert(fastdds.RETCODE_OK == ret) + + qos = fastdds.DomainParticipantQos() + ret = factory.get_participant_qos_from_xml( + xml_content, qos, 'test_participant_profile') + assert(fastdds.RETCODE_OK == ret) + + assert(default_qos == qos) + +def test_get_participant_extended_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + + qos = fastdds.DomainParticipantExtendedQos() + ret = factory.get_participant_extended_qos_from_xml( + xml_content, qos, 'test_participant_profile') + assert(fastdds.RETCODE_OK == ret) + + qos_no_name = fastdds.DomainParticipantExtendedQos() + ret = factory.get_participant_extended_qos_from_xml( + xml_content, qos_no_name) + assert(fastdds.RETCODE_OK == ret) + + # Non matching name takes the first participant found (the only one) + assert(qos == qos_no_name) + +def test_get_default_participant_extended_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + + default_qos = fastdds.DomainParticipantExtendedQos() + ret = factory.get_default_participant_extended_qos_from_xml( + xml_content, default_qos) + assert(fastdds.RETCODE_OK == ret) + + qos = fastdds.DomainParticipantExtendedQos() + ret = factory.get_participant_extended_qos_from_xml( + xml_content, qos, 'test_participant_profile') + assert(fastdds.RETCODE_OK == ret) + + assert(default_qos == qos) diff --git a/fastdds_python/test/api/test_publisher.py b/fastdds_python/test/api/test_publisher.py index 6f83237a..b2b4e7de 100644 --- a/fastdds_python/test/api/test_publisher.py +++ b/fastdds_python/test/api/test_publisher.py @@ -491,3 +491,58 @@ def create_publisher(): participant.delete_publisher(publisher)) assert(fastdds.RETCODE_OK == factory.delete_participant(participant)) + +def test_get_datawriter_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) + + qos = fastdds.DataWriterQos() + ret = publisher.get_datawriter_qos_from_xml( + xml_content, qos, 'test_publisher_profile') + assert(fastdds.RETCODE_OK == ret) + + qos_no_name = fastdds.DataWriterQos() + ret = publisher.get_datawriter_qos_from_xml( + xml_content, qos_no_name) + assert(fastdds.RETCODE_OK == ret) + + # Non matching name takes the first publisher found (the only one) + assert(qos == qos_no_name) + + assert(fastdds.RETCODE_OK == + participant.delete_publisher(publisher)) + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_default_datawriter_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) + + default_qos = fastdds.DataWriterQos() + ret = publisher.get_default_datawriter_qos_from_xml( + xml_content, default_qos) + assert(fastdds.RETCODE_OK == ret) + + qos = fastdds.DataWriterQos() + ret = publisher.get_datawriter_qos_from_xml( + xml_content, qos, 'test_publisher_profile') + assert(fastdds.RETCODE_OK == ret) + + assert(default_qos == qos) + + assert(fastdds.RETCODE_OK == + participant.delete_publisher(publisher)) + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) diff --git a/fastdds_python/test/api/test_subscriber.py b/fastdds_python/test/api/test_subscriber.py index ca096e7c..35029c7e 100644 --- a/fastdds_python/test/api/test_subscriber.py +++ b/fastdds_python/test/api/test_subscriber.py @@ -468,3 +468,58 @@ def create_subcriber(): participant.delete_subscriber(subscriber)) assert(fastdds.RETCODE_OK == factory.delete_participant(participant)) + +def test_get_datareader_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) + + qos = fastdds.DataReaderQos() + ret = subscriber.get_datareader_qos_from_xml( + xml_content, qos, 'test_subscriber_profile') + assert(fastdds.RETCODE_OK == ret) + + qos_no_name = fastdds.DataReaderQos() + ret = subscriber.get_datareader_qos_from_xml( + xml_content, qos_no_name) + assert(fastdds.RETCODE_OK == ret) + + # Non matching name takes the first subscriber found (the only one) + assert(qos == qos_no_name) + + assert(fastdds.RETCODE_OK == + participant.delete_subscriber(subscriber)) + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) + +def test_get_default_datareader_qos_from_xml(): + + with open("test_xml_profile.xml", "r", encoding="utf-8") as file: + xml_content = file.read() + + factory = fastdds.DomainParticipantFactory.get_instance() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) + + default_qos = fastdds.DataReaderQos() + ret = subscriber.get_default_datareader_qos_from_xml( + xml_content, default_qos) + assert(fastdds.RETCODE_OK == ret) + + qos = fastdds.DataReaderQos() + ret = subscriber.get_datareader_qos_from_xml( + xml_content, qos, 'test_subscriber_profile') + assert(fastdds.RETCODE_OK == ret) + + assert(default_qos == qos) + + assert(fastdds.RETCODE_OK == + participant.delete_subscriber(subscriber)) + assert(fastdds.RETCODE_OK == + factory.delete_participant(participant)) diff --git a/fastdds_python/test/api/test_xml_profile.xml b/fastdds_python/test/api/test_xml_profile.xml new file mode 100644 index 00000000..89965e96 --- /dev/null +++ b/fastdds_python/test/api/test_xml_profile.xml @@ -0,0 +1,96 @@ + + + + + 3 + + test_name + + + + + + + + partition_name_c + + + + VOLATILE + + + + + + + + + partition_name_b + + + + RELIABLE + + + + + + + KEEP_LAST + 20 + + + 200 + 20 + 100 + 50 + + + + + request_topic_name + reply_topic_name + + + + MANUAL_BY_TOPIC + + + + + + + MANUAL_BY_TOPIC + + + + + + + request_topic_name + reply_topic_name + + + + MANUAL_BY_TOPIC + + + + + + + MANUAL_BY_TOPIC + + + + + +