| 131 | } |
| 132 | |
| 133 | void test_message_maps() { |
| 134 | message m; |
| 135 | |
| 136 | ASSERT(m.properties().empty()); |
| 137 | ASSERT(m.message_annotations().empty()); |
| 138 | ASSERT(m.delivery_annotations().empty()); |
| 139 | |
| 140 | m.properties().put("foo", 12); |
| 141 | m.delivery_annotations().put("bar", "xyz"); |
| 142 | m.message_annotations().put(23, int8_t(42)); |
| 143 | |
| 144 | ASSERT_EQUAL(m.properties().get("foo"), scalar(12)); |
| 145 | ASSERT_EQUAL(m.delivery_annotations().get("bar"), scalar("xyz")); |
| 146 | |
| 147 | ASSERT_EQUAL(m.message_annotations().get(23), scalar(int8_t(42))); |
| 148 | ASSERT_EQUAL(proton::get<int8_t>(m.message_annotations().get(23)), 42); |
| 149 | ASSERT_EQUAL(m.message_annotations().get(23).get<int8_t>(), 42); |
| 150 | |
| 151 | message m2(m); |
| 152 | |
| 153 | ASSERT_EQUAL(m.properties().get("foo"), scalar(12)); // Decoding shouldn't change it |
| 154 | |
| 155 | ASSERT_EQUAL(m2.properties().get("foo"), scalar(12)); |
| 156 | ASSERT_EQUAL(m2.delivery_annotations().get("bar"), scalar("xyz")); |
| 157 | ASSERT_EQUAL(m2.message_annotations().get(23), scalar(int8_t(42))); |
| 158 | |
| 159 | m.properties().put("foo","newfoo"); |
| 160 | m.delivery_annotations().put(24, 1000); |
| 161 | m.message_annotations().erase(23); |
| 162 | |
| 163 | message m3 = m; |
| 164 | size_t size = m3.properties().size(); |
| 165 | ASSERT_EQUAL(1u, size); |
| 166 | ASSERT_EQUAL(m3.properties().get("foo"), scalar("newfoo")); |
| 167 | ASSERT_EQUAL(2u, m3.delivery_annotations().size()); |
| 168 | ASSERT_EQUAL(m3.delivery_annotations().get("bar"), scalar("xyz")); |
| 169 | ASSERT_EQUAL(m3.delivery_annotations().get(24), scalar(1000)); |
| 170 | ASSERT(m3.message_annotations().empty()); |
| 171 | |
| 172 | // PROTON-1498 |
| 173 | message msg; |
| 174 | msg.message_annotations().put("x-opt-jms-msg-type", int8_t(1)); |
| 175 | |
| 176 | proton::message::annotation_map& am_ref = msg.message_annotations(); |
| 177 | uint8_t t = am_ref.get(proton::symbol("x-opt-jms-msg-type")).get<int8_t>(); |
| 178 | ASSERT_EQUAL(1, t); |
| 179 | |
| 180 | proton::message::annotation_map am_val = msg.message_annotations(); |
| 181 | t = am_val.get(proton::symbol("x-opt-jms-msg-type")).get<int8_t>(); |
| 182 | ASSERT_EQUAL(1, t); |
| 183 | } |
| 184 | |
| 185 | void test_message_reuse() { |
| 186 | message m1("one"); |