From 09c31677d11ec6476818f737bf26812e2e527896 Mon Sep 17 00:00:00 2001 From: hongli750210 Date: Thu, 27 May 2021 13:45:06 +0800 Subject: [PATCH] Fix Azure Core Amqp Sample issue #18806 by lihong 202105271344 --- .../models/AmqpAnnotatedMessageJavaDocCodeSamples.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk/core/azure-core-amqp/src/samples/java/com/azure/core/amqp/models/AmqpAnnotatedMessageJavaDocCodeSamples.java b/sdk/core/azure-core-amqp/src/samples/java/com/azure/core/amqp/models/AmqpAnnotatedMessageJavaDocCodeSamples.java index a37e5b9a10c6d..31c426234899a 100644 --- a/sdk/core/azure-core-amqp/src/samples/java/com/azure/core/amqp/models/AmqpAnnotatedMessageJavaDocCodeSamples.java +++ b/sdk/core/azure-core-amqp/src/samples/java/com/azure/core/amqp/models/AmqpAnnotatedMessageJavaDocCodeSamples.java @@ -3,6 +3,9 @@ package com.azure.core.amqp.models; +import org.junit.jupiter.api.Test; +import java.nio.charset.StandardCharsets; + /** * Class contains sample code snippets that will be used in javadocs. */ @@ -10,8 +13,10 @@ public class AmqpAnnotatedMessageJavaDocCodeSamples { /** * Get message body from {@link AmqpAnnotatedMessage}. */ + @Test public void checkBodyType() { - AmqpAnnotatedMessage amqpAnnotatedMessage = null; + AmqpAnnotatedMessage amqpAnnotatedMessage = + new AmqpAnnotatedMessage(AmqpMessageBody.fromData("my-amqp-message".getBytes(StandardCharsets.UTF_8))); // BEGIN: com.azure.core.amqp.models.AmqpBodyType.checkBodyType // If client do not check `AmqpMessageBody.getBodyType()` and payload is not of type `AmqpMessageBodyType.DATA`, // calling `getFirstData()` or `getData()` on `AmqpMessageBody` will throw Runtime exception.