This is an automated email from the ASF dual-hosted git repository.
astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/main by this push:
new 355362535 PROTON-2911: [C++] Correctly handle terminus capabilities
355362535 is described below
commit 35536253534af8984d74cbc52ca07827788832f9
Author: Andrew Stitcher <[email protected]>
AuthorDate: Mon Nov 24 22:06:23 2025 -0500
PROTON-2911: [C++] Correctly handle terminus capabilities
Terminus capabilities can be a single AMQP symbol as well as an AMQP array
of
symbols.
---
cpp/src/connection_driver_test.cpp | 26 +++++++++++++++++++++++++-
cpp/src/terminus.cpp | 2 +-
cpp/tests.cmake | 1 +
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/cpp/src/connection_driver_test.cpp
b/cpp/src/connection_driver_test.cpp
index 608e48e8e..ff3b7523f 100644
--- a/cpp/src/connection_driver_test.cpp
+++ b/cpp/src/connection_driver_test.cpp
@@ -39,8 +39,12 @@
#include "proton/types_fwd.hpp"
#include "proton/uuid.hpp"
-#include <deque>
+#include <proton/codec.h>
+#include <proton/terminus.h>
+
#include <algorithm>
+#include <cstring>
+#include <deque>
namespace {
@@ -466,6 +470,25 @@ void test_link_capability_filter() {
ASSERT_EQUAL(value("22"), f.get("2"));
}
+void test_terminus_capabilities_single_symbol() {
+ // Test that capabilities() correctly handles a single symbol (not an
array)
+ // Capabilities can be encoded as either a single AMQP symbol or an array
of symbols.
+ record_handler ha, hb;
+ driver_pair d(ha, hb);
+
+ // Annoyingly, we have to use the C API to set capabilities as a single
symbol
+ // because the C++ API only supports setting arrays of symbols.
+ auto s = d.a.connection().open_sender("test-address");
+ auto caps_data = pn_terminus_capabilities(unwrap(s.target()));
+ auto cap_str = "single-capability";
+ pn_data_put_symbol(caps_data, pn_bytes(strlen(cap_str), cap_str));
+
+ // Verify that capabilities() returns a vector with the single symbol
+ auto caps = s.target().capabilities();
+ ASSERT_EQUAL(1U, caps.size());
+ ASSERT_EQUAL(proton::symbol("single-capability"), caps[0]);
+}
+
void test_message() {
// Verify a message arrives intact
record_handler ha, hb;
@@ -544,6 +567,7 @@ int main(int argc, char** argv) {
RUN_ARGV_TEST(failed, test_link_address());
RUN_ARGV_TEST(failed, test_link_anonymous_dynamic());
RUN_ARGV_TEST(failed, test_link_capability_filter());
+ RUN_ARGV_TEST(failed, test_terminus_capabilities_single_symbol());
RUN_ARGV_TEST(failed, test_message());
RUN_ARGV_TEST(failed, test_message_timeout_succeed());
RUN_ARGV_TEST(failed, test_message_timeout_fail());
diff --git a/cpp/src/terminus.cpp b/cpp/src/terminus.cpp
index 0cdc25c93..141341342 100644
--- a/cpp/src/terminus.cpp
+++ b/cpp/src/terminus.cpp
@@ -58,7 +58,7 @@ value terminus::node_properties() const {
std::vector<symbol> terminus::capabilities() const {
value caps(pn_terminus_capabilities(object_));
- return caps.empty() ? std::vector<symbol>() : caps.get<std::vector<symbol>
>();
+ return get_multiple<std::vector<symbol>>(caps);
}
terminus::dynamic_property_map terminus::dynamic_properties() const {
diff --git a/cpp/tests.cmake b/cpp/tests.cmake
index b00d50129..c13faee42 100644
--- a/cpp/tests.cmake
+++ b/cpp/tests.cmake
@@ -52,6 +52,7 @@ endmacro(add_cpp_test)
add_cpp_test(codec_test)
add_cpp_test(connection_driver_test)
+target_link_libraries(connection_driver_test qpid-proton-core)
add_cpp_test(interop_test ${PROJECT_SOURCE_DIR}/tests)
add_cpp_test(message_test)
add_cpp_test(map_test)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]