Amqp Value should be encoded properly when value was not initialized (#364)
* Amqp Value should be encoded properly when value was not initialized * Copy the valueBuffer into the encoding buffer instead of decoding it eagerly * do not use pattern matching for casting
This commit is contained in:
Родитель
abf0504cc9
Коммит
f0ca0ddd69
|
@ -83,10 +83,14 @@ namespace Amqp.Framing
|
|||
internal override void EncodeValue(ByteBuffer buffer)
|
||||
{
|
||||
var byteBuffer = this.value as ByteBuffer;
|
||||
if (byteBuffer != null)
|
||||
if (this.value is ByteBuffer)
|
||||
{
|
||||
Encoder.WriteBinaryBuffer(buffer, byteBuffer);
|
||||
}
|
||||
else if (this.valueBuffer != null && !this.valueDecoded)
|
||||
{
|
||||
AmqpBitConverter.WriteBytes(buffer, this.valueBuffer.Buffer, this.valueBuffer.Offset, this.valueBuffer.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WriteValue(buffer, this.value);
|
||||
|
|
|
@ -1091,6 +1091,26 @@ namespace Test.Amqp
|
|||
}
|
||||
#endif
|
||||
|
||||
[TestMethod]
|
||||
public void EncodeDecodeMessageWithAmqpValueTest()
|
||||
{
|
||||
string name = "EncodeDecodeMessageWithAmqpValueTest";
|
||||
Queue<Message> messages = new Queue<Message>();
|
||||
messages.Enqueue(new Message("test") { Properties = new Properties() { MessageId = name } });
|
||||
|
||||
var source = new TestMessageSource(messages);
|
||||
this.host.RegisterMessageSource(name, source);
|
||||
|
||||
var connection = new Connection(Address);
|
||||
var session = new Session(connection);
|
||||
var receiver = new ReceiverLink(session, "receiver0", name);
|
||||
|
||||
Message message = receiver.Receive();
|
||||
Message copy = Message.Decode(message.Encode());
|
||||
|
||||
Assert.AreEqual((message.BodySection as AmqpValue).Value, (copy.BodySection as AmqpValue).Value);
|
||||
}
|
||||
|
||||
public static X509Certificate2 GetCertificate(StoreLocation storeLocation, StoreName storeName, string certFindValue)
|
||||
{
|
||||
X509Store store = new X509Store(storeName, storeLocation);
|
||||
|
|
Загрузка…
Ссылка в новой задаче