@@ -1243,6 +1243,48 @@ static void test10_empty()
12431243 BMQTST_ASSERT (!p.hasProperty (" z" ));
12441244}
12451245
1246+ static void test11_reservedPropertyNames ()
1247+ // ------------------------------------------------------------------------
1248+ // RESERVED PROPERTY NAMES
1249+ //
1250+ // Concerns:
1251+ // Verify that property names starting with the reserved prefix
1252+ // "bmq." cannot be set by users.
1253+ //
1254+ // Testing:
1255+ // - Setting properties with reserved prefix should fail
1256+ // - Setting properties without reserved prefix should succeed
1257+ // - Specifically test "bmq.traceparent" as it's reserved for
1258+ // distributed tracing
1259+ // ------------------------------------------------------------------------
1260+ {
1261+ bmqtst::TestHelper::printTestName (" RESERVED PROPERTY NAMES" );
1262+
1263+ bmqp::MessageProperties obj (bmqtst::TestHelperUtil::allocator ());
1264+
1265+ // Test setting property with reserved prefix should fail
1266+ BMQTST_ASSERT_NE (0 , obj.setPropertyAsString (" bmq.traceparent" , " test" ));
1267+ BMQTST_ASSERT_NE (0 , obj.setPropertyAsString (" bmq.test" , " value" ));
1268+ BMQTST_ASSERT_NE (0 , obj.setPropertyAsInt32 (" bmq.count" , 42 ));
1269+
1270+ // Verify that no properties were added
1271+ BMQTST_ASSERT_EQ (0 , obj.numProperties ());
1272+ BMQTST_ASSERT (!obj.hasProperty (" bmq.traceparent" ));
1273+ BMQTST_ASSERT (!obj.hasProperty (" bmq.test" ));
1274+ BMQTST_ASSERT (!obj.hasProperty (" bmq.count" ));
1275+
1276+ // Test that properties without reserved prefix work normally
1277+ BMQTST_ASSERT_EQ (0 , obj.setPropertyAsString (" traceparent" , " test" ));
1278+ BMQTST_ASSERT_EQ (0 , obj.setPropertyAsString (" myProperty" , " value" ));
1279+ BMQTST_ASSERT_EQ (0 , obj.setPropertyAsInt32 (" count" , 42 ));
1280+
1281+ // Verify properties were added successfully
1282+ BMQTST_ASSERT_EQ (3 , obj.numProperties ());
1283+ BMQTST_ASSERT (obj.hasProperty (" traceparent" ));
1284+ BMQTST_ASSERT (obj.hasProperty (" myProperty" ));
1285+ BMQTST_ASSERT (obj.hasProperty (" count" ));
1286+ }
1287+
12461288// ============================================================================
12471289// MAIN PROGRAM
12481290// ----------------------------------------------------------------------------
@@ -1255,6 +1297,7 @@ int main(int argc, char* argv[])
12551297
12561298 switch (_testCase) {
12571299 case 0 :
1300+ case 11 : test11_reservedPropertyNames (); break ;
12581301 case 10 : test10_empty (); break ;
12591302 case 9 : test9_copyAssignTest (); break ;
12601303 case 8 : test8_printTest (); break ;
0 commit comments