DreamPearl commented on a change in pull request #346:
URL: https://github.com/apache/qpid-proton/pull/346#discussion_r774051417



##########
File path: cpp/src/link_test.cpp
##########
@@ -23,9 +23,121 @@
 #include <proton/sender_options.hpp>
 #include <proton/receiver_options.hpp>
 #include <proton/container.hpp>
+#include <proton/connection.hpp>
+#include <proton/connection_options.hpp>
+#include <proton/listen_handler.hpp>
+#include <proton/listener.hpp>
+#include <proton/messaging_handler.hpp>
+#include <proton/types.hpp>
+#include <proton/message.hpp>
+#include <proton/target_options.hpp>
+#include <proton/source_options.hpp>
+#include <proton/delivery.hpp>
 
 #include <iostream>
 
+#include <map>
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+
+namespace {
+std::mutex m;
+std::condition_variable cv;
+bool listener_ready = false;
+int listener_port;
+const std::string DYNAMIC_ADDRESS = "test_dynamic_address";
+} // namespace
+
+class test_recv : public proton::messaging_handler {
+  private:
+    class listener_ready_handler : public proton::listen_handler {
+        void on_open(proton::listener &l) override {
+            {
+                std::lock_guard<std::mutex> lk(m);
+                listener_port = l.port();
+                listener_ready = true;
+            }
+            cv.notify_one();
+        }
+    };
+
+    std::string url;
+    proton::listener listener;
+    listener_ready_handler listen_handler;
+
+  public:
+    test_recv(const std::string &s) : url(s) {}
+
+    void on_container_start(proton::container &c) override {
+        listener = c.listen(url, listen_handler);
+    }
+
+    void on_receiver_open(proton::receiver& r) override {
+        std::map<proton::symbol,proton::value> 
m_sender({{proton::symbol("supported-dist-modes"), proton::symbol("move")}});
+        std::map<proton::symbol,proton::value> props = 
r.target().dynamic_properties();
+
+        ASSERT(r.target().dynamic());
+        ASSERT(r.target().address().empty());

Review comment:
       ```
   void on_receiver_open(proton::receiver& r) override {
          ...
           ASSERT(r.target().address().empty());
           const char *address = pn_terminus_get_address(unwrap(r.target()));
           ASSERT(NULL == address);
           ASSERT_EQUAL(m_sender, props);
          ...
       }
   };
   ```
   If we don't use the address method, then I guess we have to do something 
like the above. That means we will be using the C function in the C++ binding 
test, is that something we can/should do? As I don't see it being done in any 
other C++ test.
   
   Also, I am getting an error in the above snippet.
   ```
   ...
   [100%] Linking CXX executable link_test
   /usr/bin/ld: CMakeFiles/link_test.dir/src/link_test.cpp.o: undefined 
reference to symbol 'pn_terminus_get_address'
   ...
   ```
   Alternatively, we may test this behavior under C tests (Maybe this is what 
you meant above).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to