in sdk/core/azure_core_amqp/src/messaging.rs [1902:1972]
fn test_message_with_header_serialization() {
let message = AmqpMessage::builder()
.with_header(AmqpMessageHeader {
priority: 5,
..Default::default()
})
.with_body(AmqpValue::from("String Value Body."))
.with_properties(AmqpMessageProperties {
message_id: Some("12345".into()),
..Default::default()
})
.build();
let serialized = AmqpMessage::serialize(&message).unwrap();
assert_eq!(
serialized,
vec![
0x00, 0x53, 0x70, 0xc0, 0x04, 0x02, 0x40, 0x50, 0x05, 0x00, 0x53, 0x73, 0xc0, 0x08,
0x01, 0xa1, 0x05, 0x31, 0x32, 0x33, 0x34, 0x35, 0x00, 0x53, 0x77, 0xa1, 0x12, 0x53,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x42, 0x6f,
0x64, 0x79, 0x2e
]
);
#[cfg(all(feature = "fe2o3_amqp", not(target_arch = "wasm32")))]
{
let amqp_message = fe2o3_amqp_types::messaging::message::Builder::new()
.header(
fe2o3_amqp_types::messaging::Header::builder()
.priority(5)
.build(),
)
.properties(
fe2o3_amqp_types::messaging::Properties::builder()
.message_id("12345".to_string())
.build(),
)
.body(fe2o3_amqp_types::messaging::Body::Value::<
fe2o3_amqp_types::primitives::Value,
>(fe2o3_amqp_types::messaging::AmqpValue(
fe2o3_amqp_types::primitives::Value::String("String Value Body.".to_string()),
)))
.build();
let serialized_fe2o3 = serde_amqp::ser::to_vec(
&fe2o3_amqp_types::messaging::message::__private::Serializable(
amqp_message.clone(),
),
)
.unwrap();
assert_eq!(serialized, serialized_fe2o3);
// Now deserialize the message and verify that it matches the original.
let value = serde_amqp::de::from_slice::<
fe2o3_amqp_types::messaging::message::__private::Deserializable<
fe2o3_amqp_types::messaging::Message<
fe2o3_amqp_types::messaging::Body<fe2o3_amqp_types::primitives::Value>,
>,
>,
>(serialized_fe2o3.as_slice())
.unwrap();
assert_eq!(amqp_message, value.0);
}
#[cfg(feature = "cplusplus")]
{
let deserialized = AmqpMessage::decode(&serialized).unwrap();
assert_eq!(deserialized, message);
}
}