2

I have a unit test in which I am able to test sending DDS messages currently. However, I also want to implement the ability to test the message readers as well.

The problem is, due to the programs setup for creation of DDS readers and writers. If I try to make the readers I need, they already have the same topic as the writer and due to this an exception is thrown.

Has anyone thus figured out a way to simulate sending DDS messages to a reader as if they came from a DDS writer? Within one computer and no using separate computers on a network to do so.

jgr208
  • 2,896
  • 9
  • 36
  • 64

1 Answers1

1

You can use lookup_topicdescription() on the DomainParticipant to get a reference to the previously created Topic, if it exists. In pseudo-code, you could do something like

use lookup_topicdescription() to see if topic exists
if topic does not exist
  use create_topic() to create the topic

If your application does this in multiple threads, then you will have to grab and release a lock around this code.

Reinier Torenbeek
  • 16,669
  • 7
  • 46
  • 69