diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 23a8ba155af07..0e05e2466436c 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -354,8 +354,8 @@ unreleased_com.azure:azure-aot-graalvm-support;1.0.0-beta.1 unreleased_com.azure:azure-aot-graalvm-support-netty;1.0.0-beta.1 unreleased_com.azure:azure-aot-graalvm-perf;1.0.0-beta.1 - unreleased_com.azure:azure-core-amqp;2.5.0-beta.1 +unreleased_com.azure:azure-core-experimental;1.0.0-beta.26 # Released Beta dependencies: Copy the entry from above, prepend "beta_", remove the current # version and set the version to the released beta. Released beta dependencies are only valid diff --git a/sdk/core/azure-core-experimental/CHANGELOG.md b/sdk/core/azure-core-experimental/CHANGELOG.md index 0dfb1b6448cae..55f6d064c75c0 100644 --- a/sdk/core/azure-core-experimental/CHANGELOG.md +++ b/sdk/core/azure-core-experimental/CHANGELOG.md @@ -6,6 +6,8 @@ ### Breaking Changes +- Changed `com.azure.core.experimental.models.MessageWithMetadata` to `BinaryContent`. + ### Bugs Fixed ### Other Changes diff --git a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java b/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/BinaryContent.java similarity index 77% rename from sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java rename to sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/BinaryContent.java index 7b0a9ccdbd4d5..5805f030eb49b 100644 --- a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java +++ b/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/BinaryContent.java @@ -10,7 +10,7 @@ * An abstraction for a message containing a content type along with its data. */ @Fluent -public class MessageWithMetadata { +public class BinaryContent { private BinaryData binaryData; private String contentType; @@ -28,9 +28,9 @@ public BinaryData getBodyAsBinaryData() { * * @param binaryData The message body. * - * @return The updated {@link MessageWithMetadata} object. + * @return The updated {@link BinaryContent} object. */ - public MessageWithMetadata setBodyAsBinaryData(BinaryData binaryData) { + public BinaryContent setBodyAsBinaryData(BinaryData binaryData) { this.binaryData = binaryData; return this; } @@ -49,9 +49,9 @@ public String getContentType() { * * @param contentType The content type. * - * @return The updated {@link MessageWithMetadata} object. + * @return The updated {@link BinaryContent} object. */ - public MessageWithMetadata setContentType(String contentType) { + public BinaryContent setContentType(String contentType) { this.contentType = contentType; return this; } diff --git a/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java b/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/BinaryContentTest.java similarity index 78% rename from sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java rename to sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/BinaryContentTest.java index ebe19fa1a9fc6..5419a1d5cb1c6 100644 --- a/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java +++ b/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/BinaryContentTest.java @@ -9,16 +9,16 @@ import static org.junit.jupiter.api.Assertions.assertNull; /** - * Tests for {@link MessageWithMetadata} + * Tests for {@link BinaryContent} */ -public class MessageWithMetadataTest { +public class BinaryContentTest { /** * Verify default parameters. */ @Test public void initialize() { // Act - final MessageWithMetadata message = new MessageWithMetadata(); + final BinaryContent message = new BinaryContent(); // Assert assertNull(message.getBodyAsBinaryData(), "'body' should initially be null."); @@ -33,10 +33,10 @@ public void settingProperties() { // Arrange final BinaryData binaryData = BinaryData.fromString("foo.bar.baz"); final String contentType = "some-content"; - final MessageWithMetadata message = new MessageWithMetadata(); + final BinaryContent message = new BinaryContent(); // Act - final MessageWithMetadata actual = message.setContentType(contentType) + final BinaryContent actual = message.setContentType(contentType) .setBodyAsBinaryData(binaryData); // Assert diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md index 583d2f24d077f..a5a0e8df2f8a1 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md @@ -6,6 +6,11 @@ ### Breaking Changes +- Changed `SchemaRegistryApacheAvroEncoder` to deserialize `BinaryContent`. +- Changed `SchemaRegistryApacheAvroEncoder` to `SchemaRegistryApacheAvroSerializer`. +- Changed `decodeMessageData` and `decodeMessageDataAsync` to `deserializeMessageData` and `deserializeMessageDataAsync`. +- Changed `encodeMessageData` and `encodeMessageDataAsync` to `serializeMessageData` and `serializeMessageDataAsync`. + ### Bugs Fixed ### Other Changes @@ -14,7 +19,7 @@ ### Features Added -- Changed `SchemaRegistryApacheAvroEncoder` to deserialize `MessageWithMetadata` rather than tied to a binary format +- Changed `SchemaRegistryApacheAvroEncoder` to deserialize `MessageWithMetadata` rather than tied to a binary format with preamble. Backwards compatibility with preamble format supported for this release. See issue #26449. ### Breaking Changes diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md index 15e55cb3f7804..e5a685b1678b8 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md @@ -72,11 +72,11 @@ SchemaRegistryAsyncClient schemaRegistryAsyncClient = new SchemaRegistryClientBu #### Create `SchemaRegistryAvroSerializer` through the builder -```java readme-sample-createSchemaRegistryAvroEncoder -SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() +```java readme-sample-createSchemaRegistryAvroSerializer +SchemaRegistryApacheAvroSerializer serializer = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") - .buildEncoder(); + .buildSerializer(); ``` ## Key concepts @@ -105,14 +105,14 @@ The serializer in this library creates messages in a wire format. The format is ### Serialize Serialize a strongly-typed object into Schema Registry-compatible avro payload. -```java readme-sample-encodeSample +```java readme-sample-serializeSample PlayingCard playingCard = new PlayingCard(); playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); playingCard.setIsFaceCard(false); playingCard.setCardValue(5); -MessageWithMetadata message = encoder.encodeMessageData(playingCard, - TypeReference.createInstance(MessageWithMetadata.class)); +BinaryContent message = serializer.serializeMessageData(playingCard, + TypeReference.createInstance(BinaryContent.class)); ``` The avro type `PlayingCard` is available in samples package @@ -121,10 +121,10 @@ The avro type `PlayingCard` is available in samples package ### Deserialize Deserialize a Schema Registry-compatible avro payload into a strongly-type object. -```java readme-sample-decodeSample -SchemaRegistryApacheAvroEncoder encoder = createAvroSchemaRegistryEncoder(); -MessageWithMetadata message = getSchemaRegistryAvroMessage(); -PlayingCard playingCard = encoder.decodeMessageData(message, TypeReference.createInstance(PlayingCard.class)); +```java readme-sample-deserializeSample +SchemaRegistryApacheAvroSerializer serializer = createAvroSchemaRegistrySerializer(); +BinaryContent message = getSchemaRegistryAvroMessage(); +PlayingCard playingCard = serializer.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); ``` ## Troubleshooting diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml index 4a8d72e34bc09..278cd1a50f191 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml @@ -44,10 +44,15 @@ + + com.azure + azure-core + 1.26.0 + com.azure azure-core-experimental - 1.0.0-beta.25 + 1.0.0-beta.26 com.azure diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java similarity index 88% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java index d5bb9f1f4049e..2a8d3f2c3f071 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java @@ -3,7 +3,7 @@ package com.azure.data.schemaregistry.apacheavro; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.experimental.models.BinaryContent; import com.azure.core.util.BinaryData; import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; @@ -28,13 +28,13 @@ /** * Schema Registry-based serializer implementation for Avro data format using Apache Avro. */ -public final class SchemaRegistryApacheAvroEncoder { +public final class SchemaRegistryApacheAvroSerializer { static final String AVRO_MIME_TYPE = "avro/binary"; static final byte[] RECORD_FORMAT_INDICATOR = new byte[]{0x00, 0x00, 0x00, 0x00}; static final int RECORD_FORMAT_INDICATOR_SIZE = RECORD_FORMAT_INDICATOR.length; static final int SCHEMA_ID_SIZE = 32; - private final ClientLogger logger = new ClientLogger(SchemaRegistryApacheAvroEncoder.class); + private final ClientLogger logger = new ClientLogger(SchemaRegistryApacheAvroSerializer.class); private final SchemaRegistryAsyncClient schemaRegistryClient; private final AvroSerializer avroSerializer; private final SerializerOptions serializerOptions; @@ -46,7 +46,7 @@ public final class SchemaRegistryApacheAvroEncoder { * @param avroSerializer Serializer implemented using Apache Avro. * @param serializerOptions Options to configure the serializer with. */ - SchemaRegistryApacheAvroEncoder(SchemaRegistryAsyncClient schemaRegistryClient, + SchemaRegistryApacheAvroSerializer(SchemaRegistryAsyncClient schemaRegistryClient, AvroSerializer avroSerializer, SerializerOptions serializerOptions) { this.schemaRegistryClient = Objects.requireNonNull(schemaRegistryClient, "'schemaRegistryClient' cannot be null."); @@ -60,7 +60,7 @@ public final class SchemaRegistryApacheAvroEncoder { * * @param object Object to encode. * @param typeReference Type of message to create. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return The message encoded or {@code null} if the message could not be encoded. * @@ -70,8 +70,8 @@ public final class SchemaRegistryApacheAvroEncoder { * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public T encodeMessageData(Object object, TypeReference typeReference) { - return encodeMessageDataAsync(object, typeReference).block(); + public T serializeMessageData(Object object, TypeReference typeReference) { + return serializeMessageDataAsync(object, typeReference).block(); } /** @@ -80,7 +80,7 @@ public T encodeMessageData(Object object, TypeRe * @param object Object to encode. * @param typeReference Type of message to create. * @param messageFactory Factory to create an instance given the serialized Avro. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return The message encoded or {@code null} if the message could not be encoded. * @@ -90,9 +90,9 @@ public T encodeMessageData(Object object, TypeRe * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public T encodeMessageData(Object object, TypeReference typeReference, + public T serializeMessageData(Object object, TypeReference typeReference, Function messageFactory) { - return encodeMessageDataAsync(object, typeReference, messageFactory).block(); + return serializeMessageDataAsync(object, typeReference, messageFactory).block(); } /** @@ -100,7 +100,7 @@ public T encodeMessageData(Object object, TypeRe * * @param object Object to encode. * @param typeReference Type of message to create. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return A Mono that completes with the encoded message. * @@ -110,10 +110,10 @@ public T encodeMessageData(Object object, TypeRe * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public Mono encodeMessageDataAsync(Object object, + public Mono serializeMessageDataAsync(Object object, TypeReference typeReference) { - return encodeMessageDataAsync(object, typeReference, null); + return serializeMessageDataAsync(object, typeReference, null); } /** @@ -123,7 +123,7 @@ public Mono encodeMessageDataAsync(Object obj * @param typeReference Type of message to create. * @param messageFactory Factory to create an instance given the serialized Avro. If null is passed in, then the * no argument constructor will be used. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return A Mono that completes with the encoded message. * @@ -133,7 +133,7 @@ public Mono encodeMessageDataAsync(Object obj * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public Mono encodeMessageDataAsync(Object object, + public Mono serializeMessageDataAsync(Object object, TypeReference typeReference, Function messageFactory) { if (object == null) { @@ -193,14 +193,14 @@ public Mono encodeMessageDataAsync(Object obj * * @param message Object to encode. * @param typeReference Message to encode to. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return The message encoded. * * @throws NullPointerException if {@code message} or {@code typeReference} is null. */ - public T decodeMessageData(MessageWithMetadata message, TypeReference typeReference) { - return decodeMessageDataAsync(message, typeReference).block(); + public T deserializeMessageData(BinaryContent message, TypeReference typeReference) { + return deserializeMessageDataAsync(message, typeReference).block(); } /** @@ -208,14 +208,14 @@ public T decodeMessageData(MessageWithMetadata message, TypeReference typ * * @param message Object to encode. * @param typeReference Message to encode to. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return A Mono that completes when the message encoded. If {@code message.getBodyAsBinaryData()} is null or * empty, then an empty Mono is returned. * * @throws NullPointerException if {@code message} or {@code typeReference} is null. */ - public Mono decodeMessageDataAsync(MessageWithMetadata message, TypeReference typeReference) { + public Mono deserializeMessageDataAsync(BinaryContent message, TypeReference typeReference) { if (message == null) { return monoError(logger, new NullPointerException("'message' cannot be null.")); } else if (typeReference == null) { @@ -282,10 +282,10 @@ public Mono decodeMessageDataAsync(MessageWithMetadata message, TypeRefer contents.reset(); } - return decodeMessageDataAsync(schemaId, contents, typeReference); + return deserializeMessageDataAsync(schemaId, contents, typeReference); } - private Mono decodeMessageDataAsync(String schemaId, ByteBuffer buffer, TypeReference typeReference) { + private Mono deserializeMessageDataAsync(String schemaId, ByteBuffer buffer, TypeReference typeReference) { return this.schemaRegistryClient.getSchema(schemaId) .handle((registryObject, sink) -> { final byte[] payloadSchema = registryObject.getDefinition().getBytes(StandardCharsets.UTF_8); @@ -305,7 +305,7 @@ private Mono decodeMessageDataAsync(String schemaId, ByteBuffer buffer, T * @throws RuntimeException if an instance of {@code T} could not be instantiated. */ @SuppressWarnings("unchecked") - private static T createNoArgumentInstance(TypeReference typeReference) { + private static T createNoArgumentInstance(TypeReference typeReference) { final Optional> constructor = Arrays.stream(typeReference.getJavaClass().getDeclaredConstructors()) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderBuilder.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java similarity index 80% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderBuilder.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java index 8886719469981..1b3114adf3d84 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderBuilder.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java @@ -15,15 +15,15 @@ import java.util.Objects; /** - * The builder implementation for building {@link SchemaRegistryApacheAvroEncoder}. + * The builder implementation for building {@link SchemaRegistryApacheAvroSerializer}. * - * @see SchemaRegistryApacheAvroEncoder + * @see SchemaRegistryApacheAvroSerializer */ -public final class SchemaRegistryApacheAvroEncoderBuilder { +public final class SchemaRegistryApacheAvroSerializerBuilder { private static final boolean AVRO_SPECIFIC_READER_DEFAULT = false; private static final int MAX_CACHE_SIZE = 128; - private final ClientLogger logger = new ClientLogger(SchemaRegistryApacheAvroEncoderBuilder.class); + private final ClientLogger logger = new ClientLogger(SchemaRegistryApacheAvroSerializerBuilder.class); private Boolean autoRegisterSchemas; private Boolean avroSpecificReader; private SchemaRegistryAsyncClient schemaRegistryAsyncClient; @@ -32,7 +32,7 @@ public final class SchemaRegistryApacheAvroEncoderBuilder { /** * Instantiates instance of Builder class. Supplies client defaults. */ - public SchemaRegistryApacheAvroEncoderBuilder() { + public SchemaRegistryApacheAvroSerializerBuilder() { this.autoRegisterSchemas = false; this.avroSpecificReader = false; } @@ -46,9 +46,9 @@ public SchemaRegistryApacheAvroEncoderBuilder() { * * @param schemaGroup Azure Schema Registry schema group * - * @return updated {@link SchemaRegistryApacheAvroEncoderBuilder} instance + * @return updated {@link SchemaRegistryApacheAvroSerializerBuilder} instance */ - public SchemaRegistryApacheAvroEncoderBuilder schemaGroup(String schemaGroup) { + public SchemaRegistryApacheAvroSerializerBuilder schemaGroup(String schemaGroup) { this.schemaGroup = schemaGroup; return this; } @@ -64,9 +64,9 @@ public SchemaRegistryApacheAvroEncoderBuilder schemaGroup(String schemaGroup) { * * @param autoRegisterSchemas flag for schema auto-registration * - * @return updated {@link SchemaRegistryApacheAvroEncoderBuilder} instance + * @return updated {@link SchemaRegistryApacheAvroSerializerBuilder} instance */ - public SchemaRegistryApacheAvroEncoderBuilder autoRegisterSchema(boolean autoRegisterSchemas) { + public SchemaRegistryApacheAvroSerializerBuilder autoRegisterSchema(boolean autoRegisterSchemas) { this.autoRegisterSchemas = autoRegisterSchemas; return this; } @@ -78,9 +78,9 @@ public SchemaRegistryApacheAvroEncoderBuilder autoRegisterSchema(boolean autoReg * @param avroSpecificReader {@code true} to deserialize into {@link SpecificRecord} via {@link * SpecificDatumReader}; {@code false} otherwise. * - * @return updated {@link SchemaRegistryApacheAvroEncoderBuilder} instance. + * @return updated {@link SchemaRegistryApacheAvroSerializerBuilder} instance. */ - public SchemaRegistryApacheAvroEncoderBuilder avroSpecificReader(boolean avroSpecificReader) { + public SchemaRegistryApacheAvroSerializerBuilder avroSpecificReader(boolean avroSpecificReader) { this.avroSpecificReader = avroSpecificReader; return this; } @@ -90,9 +90,9 @@ public SchemaRegistryApacheAvroEncoderBuilder avroSpecificReader(boolean avroSpe * * @param schemaRegistryAsyncClient The {@link SchemaRegistryAsyncClient}. * - * @return updated {@link SchemaRegistryApacheAvroEncoderBuilder} instance. + * @return updated {@link SchemaRegistryApacheAvroSerializerBuilder} instance. */ - public SchemaRegistryApacheAvroEncoderBuilder schemaRegistryAsyncClient( + public SchemaRegistryApacheAvroSerializerBuilder schemaRegistryAsyncClient( SchemaRegistryAsyncClient schemaRegistryAsyncClient) { this.schemaRegistryAsyncClient = schemaRegistryAsyncClient; return this; @@ -101,13 +101,13 @@ public SchemaRegistryApacheAvroEncoderBuilder schemaRegistryAsyncClient( /** * Creates a new instance of Schema Registry serializer. * - * @return A new instance of {@link SchemaRegistryApacheAvroEncoder}. + * @return A new instance of {@link SchemaRegistryApacheAvroSerializer}. * * @throws NullPointerException if {@link #schemaRegistryAsyncClient(SchemaRegistryAsyncClient)} is {@code null} * @throws IllegalStateException if {@link #autoRegisterSchema(boolean)} is {@code true} but {@link * #schemaGroup(String) schemaGroup} is {@code null}. */ - public SchemaRegistryApacheAvroEncoder buildEncoder() { + public SchemaRegistryApacheAvroSerializer buildSerializer() { final boolean isAutoRegister = autoRegisterSchemas != null && autoRegisterSchemas; if (Objects.isNull(schemaRegistryAsyncClient)) { @@ -126,6 +126,6 @@ public SchemaRegistryApacheAvroEncoder buildEncoder() { EncoderFactory.get(), DecoderFactory.get()); final SerializerOptions options = new SerializerOptions(schemaGroup, isAutoRegister, MAX_CACHE_SIZE); - return new SchemaRegistryApacheAvroEncoder(schemaRegistryAsyncClient, codec, options); + return new SchemaRegistryApacheAvroSerializer(schemaRegistryAsyncClient, codec, options); } } diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/README.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/README.md index fe8c37a9f7998..cf8e66173e4b9 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/README.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/README.md @@ -40,7 +40,7 @@ This project welcomes contributions and suggestions. See [Contributing][sdk_read [sdk_readme_troubleshooting]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md#troubleshooting [sdk_readme_next_steps]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md#next-steps [sdk_readme_contributing]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md#contributing -[sample_avro_serialization]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java +[sample_avro_serialization]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java [sample_avro_deserialization]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%schemaregistry%2Fazure-data-schemaregistry-apacheavro%2Fsrc%2Fsamples%2README.png) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ReadmeSamples.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ReadmeSamples.java index eb685bb70f700..de1af19d97c67 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ReadmeSamples.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ReadmeSamples.java @@ -4,7 +4,7 @@ package com.azure.data.schemaregistry.apacheavro; import com.azure.core.credential.TokenCredential; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.experimental.models.BinaryContent; import com.azure.core.util.BinaryData; import com.azure.core.util.serializer.TypeReference; import com.azure.data.schemaregistry.SchemaRegistryAsyncClient; @@ -19,10 +19,10 @@ public class ReadmeSamples { /** - * Sample to demonstrate creation of {@link SchemaRegistryApacheAvroEncoder}. - * @return The {@link SchemaRegistryApacheAvroEncoder}. + * Sample to demonstrate creation of {@link SchemaRegistryApacheAvroSerializer}. + * @return The {@link SchemaRegistryApacheAvroSerializer}. */ - public SchemaRegistryApacheAvroEncoder createAvroSchemaRegistryEncoder() { + public SchemaRegistryApacheAvroSerializer createAvroSchemaRegistrySerializer() { // BEGIN: readme-sample-createSchemaRegistryAsyncClient TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); @@ -34,50 +34,50 @@ public SchemaRegistryApacheAvroEncoder createAvroSchemaRegistryEncoder() { .buildAsyncClient(); // END: readme-sample-createSchemaRegistryAsyncClient - // BEGIN: readme-sample-createSchemaRegistryAvroEncoder - SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + // BEGIN: readme-sample-createSchemaRegistryAvroSerializer + SchemaRegistryApacheAvroSerializer serializer = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") - .buildEncoder(); - // END: readme-sample-createSchemaRegistryAvroEncoder + .buildSerializer(); + // END: readme-sample-createSchemaRegistryAvroSerializer - return encoder; + return serializer; } /** * Encode a strongly-typed object into avro payload compatible with schema registry. */ - public void encodeSample() { - SchemaRegistryApacheAvroEncoder encoder = createAvroSchemaRegistryEncoder(); + public void serializeSample() { + SchemaRegistryApacheAvroSerializer serializer = createAvroSchemaRegistrySerializer(); - // BEGIN: readme-sample-encodeSample + // BEGIN: readme-sample-serializeSample PlayingCard playingCard = new PlayingCard(); playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); playingCard.setIsFaceCard(false); playingCard.setCardValue(5); - MessageWithMetadata message = encoder.encodeMessageData(playingCard, - TypeReference.createInstance(MessageWithMetadata.class)); - // END: readme-sample-encodeSample + BinaryContent message = serializer.serializeMessageData(playingCard, + TypeReference.createInstance(BinaryContent.class)); + // END: readme-sample-serializeSample } /** * Decode avro payload compatible with schema registry into a strongly-type object. */ - public void decodeSample() { - // BEGIN: readme-sample-decodeSample - SchemaRegistryApacheAvroEncoder encoder = createAvroSchemaRegistryEncoder(); - MessageWithMetadata message = getSchemaRegistryAvroMessage(); - PlayingCard playingCard = encoder.decodeMessageData(message, TypeReference.createInstance(PlayingCard.class)); - // END: readme-sample-decodeSample + public void deserializeSample() { + // BEGIN: readme-sample-deserializeSample + SchemaRegistryApacheAvroSerializer serializer = createAvroSchemaRegistrySerializer(); + BinaryContent message = getSchemaRegistryAvroMessage(); + PlayingCard playingCard = serializer.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); + // END: readme-sample-deserializeSample } /** * Non-functional method not visible on README sample * @return a new message. */ - private MessageWithMetadata getSchemaRegistryAvroMessage() { - return new MessageWithMetadata() + private BinaryContent getSchemaRegistryAvroMessage() { + return new BinaryContent() .setBodyAsBinaryData(BinaryData.fromBytes(new byte[1])) .setContentType("avro/binary+schema_id"); } diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java similarity index 77% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java index bb168300362e1..38e7f39e3a959 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java @@ -4,7 +4,7 @@ package com.azure.data.schemaregistry.apacheavro; import com.azure.core.credential.TokenCredential; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.experimental.models.BinaryContent; import com.azure.core.util.serializer.TypeReference; import com.azure.data.schemaregistry.SchemaRegistryAsyncClient; import com.azure.data.schemaregistry.SchemaRegistryClientBuilder; @@ -13,9 +13,9 @@ import com.azure.identity.DefaultAzureCredentialBuilder; /** - * Sample to demonstrate using {@link SchemaRegistryApacheAvroEncoder} for serialization and deserialization of data. + * Sample to demonstrate using {@link SchemaRegistryApacheAvroSerializer} for serialization and deserialization of data. */ -public class SchemaRegistryApacheAvroEncoderSample { +public class SchemaRegistryApacheAvroSerializerSample { /** * Main method to run this sample. * @@ -33,11 +33,11 @@ public static void main(String[] args) { // Create the encoder instance by configuring it with the schema registry client and // enabling auto registering of new schemas - SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + SchemaRegistryApacheAvroSerializer serializer = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") .avroSpecificReader(true) - .buildEncoder(); + .buildSerializer(); PlayingCard playingCard = new PlayingCard(); playingCard.setCardValue(5); @@ -45,7 +45,7 @@ public static void main(String[] args) { playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); // Serialize the playing card object and write to the output stream. - MessageWithMetadata message = encoder.encodeMessageData(playingCard, - TypeReference.createInstance(MessageWithMetadata.class)); + BinaryContent message = serializer.serializeMessageData(playingCard, + TypeReference.createInstance(BinaryContent.class)); } } diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java index 04b1b0fbe9597..fb836f1f819e5 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java @@ -4,7 +4,7 @@ package com.azure.data.schemaregistry.apacheavro; import com.azure.core.credential.TokenCredential; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.experimental.models.BinaryContent; import com.azure.core.util.BinaryData; import com.azure.core.util.serializer.TypeReference; import com.azure.data.schemaregistry.SchemaRegistryAsyncClient; @@ -37,27 +37,27 @@ public static void main(String[] args) { // Create the encoder instance by configuring it with the schema registry client and // enabling auto registering of new schemas - SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") .avroSpecificReader(true) .autoRegisterSchema(true) - .buildEncoder(); + .buildSerializer(); // Get serialized avro data to deserialize into strongly-typed object. - MessageWithMetadata inputStream = getMessageToDeserialize(); - PlayingCard deserializedObject = encoder.decodeMessageData(inputStream, + BinaryContent inputStream = getMessageToDeserialize(); + PlayingCard deserializedObject = encoder.deserializeMessageData(inputStream, TypeReference.createInstance(PlayingCard.class)); } - private static MessageWithMetadata getMessageToDeserialize() { + private static BinaryContent getMessageToDeserialize() { PlayingCard playingCard = new PlayingCard(); playingCard.setCardValue(5); playingCard.setIsFaceCard(false); playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); try { - return new MessageWithMetadata() + return new BinaryContent() .setBodyAsBinaryData(BinaryData.fromBytes(playingCard.toByteBuffer().array())) .setContentType("avro/binary+schema_id"); } catch (IOException e) { diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderIntegrationTest.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java similarity index 91% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderIntegrationTest.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java index 186f1b36a6476..b2323fe7d0323 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderIntegrationTest.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java @@ -6,7 +6,7 @@ import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.credential.TokenRequestContext; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.experimental.models.BinaryContent; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; @@ -38,7 +38,7 @@ /** * Tests end to end experience of the schema registry class. */ -public class SchemaRegistryApacheAvroEncoderIntegrationTest extends TestBase { +public class SchemaRegistryApacheAvroSerializerIntegrationTest extends TestBase { static final String SCHEMA_REGISTRY_ENDPOINT = "SCHEMA_REGISTRY_ENDPOINT"; static final String SCHEMA_REGISTRY_GROUP = "SCHEMA_REGISTRY_GROUP"; @@ -99,11 +99,11 @@ protected void afterTest() { public void registerAndGetSchema() { // Arrange final SchemaRegistryClient registryClient = builder.buildClient(); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaGroup(schemaGroup) .schemaRegistryAsyncClient(builder.buildAsyncClient()) .avroSpecificReader(true) - .buildEncoder(); + .buildSerializer(); final PlayingCard playingCard = PlayingCard.newBuilder() .setCardValue(1) @@ -131,14 +131,14 @@ public void registerAndGetSchema() { assertNotNull(schemaProperties); // Act & Assert - final MessageWithMetadata encodedMessage = encoder.encodeMessageData(cards, - TypeReference.createInstance(MessageWithMetadata.class)); + final BinaryContent encodedMessage = encoder.serializeMessageData(cards, + TypeReference.createInstance(BinaryContent.class)); assertNotNull(encodedMessage); final byte[] outputArray = encodedMessage.getBodyAsBinaryData().toBytes(); assertTrue(outputArray.length > 0, "There should have been contents in array."); - final HandOfCards actual = encoder.decodeMessageData(encodedMessage, + final HandOfCards actual = encoder.deserializeMessageData(encodedMessage, TypeReference.createInstance(HandOfCards.class)); assertNotNull(actual); diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderTest.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java similarity index 84% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderTest.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java index cbbcd55414de2..fc8bda6f4b7c2 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderTest.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java @@ -6,7 +6,7 @@ import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.credential.TokenRequestContext; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.experimental.models.BinaryContent; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; @@ -56,12 +56,12 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoder.AVRO_MIME_TYPE; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoder.RECORD_FORMAT_INDICATOR; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoder.RECORD_FORMAT_INDICATOR_SIZE; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoder.SCHEMA_ID_SIZE; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoderIntegrationTest.PLAYBACK_ENDPOINT; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoderIntegrationTest.PLAYBACK_TEST_GROUP; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializer.AVRO_MIME_TYPE; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializer.RECORD_FORMAT_INDICATOR; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializer.RECORD_FORMAT_INDICATOR_SIZE; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializer.SCHEMA_ID_SIZE; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializerIntegrationTest.PLAYBACK_ENDPOINT; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializerIntegrationTest.PLAYBACK_TEST_GROUP; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -72,9 +72,9 @@ import static org.mockito.Mockito.when; /** - * Unit tests for {@link SchemaRegistryApacheAvroEncoder}. + * Unit tests for {@link SchemaRegistryApacheAvroSerializer}. */ -public class SchemaRegistryApacheAvroEncoderTest { +public class SchemaRegistryApacheAvroSerializerTest { private static final String MOCK_GUID = new String(new char[SCHEMA_ID_SIZE]).replace("\0", "a"); private static final String MOCK_SCHEMA_GROUP = "mock-group"; private static final int MOCK_CACHE_SIZE = 128; @@ -136,11 +136,11 @@ public void testRegistryGuidPrefixedToPayload() { playingClassSchema.toString(), SchemaFormat.AVRO)).thenReturn(Mono.just(registered)); final String expectedContentType = AVRO_MIME_TYPE + "+" + MOCK_GUID; - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); - StepVerifier.create(encoder.encodeMessageDataAsync(playingCard, - TypeReference.createInstance(MessageWithMetadata.class))) + StepVerifier.create(encoder.serializeMessageDataAsync(playingCard, + TypeReference.createInstance(BinaryContent.class))) .assertNext(message -> { // guid should match preloaded SchemaRegistryObject guid assertEquals(expectedContentType, message.getContentType()); @@ -155,13 +155,13 @@ public void testNullPayloadThrowsSerializationException() { final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, false, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, avroSerializer, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); - final MessageWithMetadata message = new MessageWithMetadata(); + final BinaryContent message = new BinaryContent(); // Act & Assert - StepVerifier.create(encoder.encodeMessageDataAsync(message, null)) + StepVerifier.create(encoder.serializeMessageDataAsync(message, null)) .verifyError(NullPointerException.class); } @@ -174,7 +174,7 @@ public void testIfRegistryNullThenThrow() { // Act & Assert assertThrows(NullPointerException.class, - () -> new SchemaRegistryApacheAvroEncoder(null, encoder, serializerOptions)); + () -> new SchemaRegistryApacheAvroSerializer(null, encoder, serializerOptions)); } @Test @@ -188,7 +188,7 @@ void testGetSchemaAndDeserialize() throws IOException { final SchemaRegistrySchema registrySchema = new SchemaRegistrySchema(registered, playingClassSchema); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, decoder, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, decoder, serializerOptions); assertNotNull(registrySchema.getProperties()); @@ -206,7 +206,7 @@ void testGetSchemaAndDeserialize() throws IOException { final MockMessage message = getPayload(playingCard); - StepVerifier.create(encoder.decodeMessageDataAsync(message, TypeReference.createInstance(PlayingCard.class))) + StepVerifier.create(encoder.deserializeMessageDataAsync(message, TypeReference.createInstance(PlayingCard.class))) .assertNext(actual -> { assertEquals(playingCard.getPlayingCardSuit(), actual.getPlayingCardSuit()); assertEquals(playingCard.getCardValue(), actual.getCardValue()); @@ -219,7 +219,7 @@ public static Stream testEmptyPayload() { return Stream.of( Arguments.of( new MockMessage(), - new MessageWithMetadata().setContentType("avro/binary")) + new BinaryContent().setContentType("avro/binary")) ); } @@ -228,16 +228,16 @@ public static Stream testEmptyPayload() { */ @MethodSource @ParameterizedTest - public void testEmptyPayload(MessageWithMetadata message) { + public void testEmptyPayload(BinaryContent message) { // Arrange final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); // Act & Assert - StepVerifier.create(encoder.decodeMessageDataAsync(message, TypeReference.createInstance(PlayingCard.class))) + StepVerifier.create(encoder.deserializeMessageDataAsync(message, TypeReference.createInstance(PlayingCard.class))) .expectComplete() .verify(); } @@ -252,11 +252,11 @@ public void testEmptyPayloadSync() { final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); final MockMessage message = new MockMessage(); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); // Act - final Person actual = encoder.decodeMessageData(message, TypeReference.createInstance(Person.class)); + final Person actual = encoder.deserializeMessageData(message, TypeReference.createInstance(Person.class)); // Assert assertNull(actual); @@ -270,11 +270,11 @@ public void testNullPayload() { final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); // Null payload should throw NullPointerException. - StepVerifier.create(encoder.encodeMessageDataAsync(null, null)) + StepVerifier.create(encoder.serializeMessageDataAsync(null, null)) .expectError(NullPointerException.class) .verify(); } @@ -287,11 +287,11 @@ public void testNullPayloadSync() { final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder( + SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer( client, avroSerializer, serializerOptions); // Null payload should throw NullPointerException. - assertThrows(NullPointerException.class, () -> encoder.decodeMessageData(null, null)); + assertThrows(NullPointerException.class, () -> encoder.deserializeMessageData(null, null)); } /** @@ -317,15 +317,15 @@ public void serializeFromPortal() { .build(); final SchemaRegistryAsyncClient client = getSchemaRegistryClient(testInfo, TestMode.PLAYBACK); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaGroup(PLAYBACK_TEST_GROUP) .schemaRegistryAsyncClient(client) .avroSpecificReader(true) - .buildEncoder(); + .buildSerializer(); final String expectedContentType = AVRO_MIME_TYPE + "+64fc737160ff41bdb8a0b8af028e6827"; // Act - StepVerifier.create(encoder.encodeMessageDataAsync(record, TypeReference.createInstance(MockMessage.class))) + StepVerifier.create(encoder.serializeMessageDataAsync(record, TypeReference.createInstance(MockMessage.class))) .assertNext(message -> { assertEquals(expectedContentType, message.getContentType()); assertNotNull(message.getBodyAsBinaryData()); @@ -343,11 +343,11 @@ public void serializeFromPortal() { public void serializeForwardCompatibility() { // Arrange final SchemaRegistryAsyncClient client = getSchemaRegistryClient(testInfo, TestMode.PLAYBACK); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaGroup(PLAYBACK_TEST_GROUP) .schemaRegistryAsyncClient(client) .avroSpecificReader(true) - .buildEncoder(); + .buildSerializer(); final String expectedContentType = AVRO_MIME_TYPE + "+f047cfa64b374167b3a1d101370c1483"; final String name = "Jackson"; @@ -362,10 +362,10 @@ public void serializeForwardCompatibility() { .setFavouriteColour(colour) .setFavouritePet(pet) .build(); - final AtomicReference outputData = new AtomicReference<>(); + final AtomicReference outputData = new AtomicReference<>(); // Act: Serialize the new Person2. - StepVerifier.create(encoder.encodeMessageDataAsync(writerPerson, TypeReference.createInstance(MockMessage.class))) + StepVerifier.create(encoder.serializeMessageDataAsync(writerPerson, TypeReference.createInstance(MockMessage.class))) .assertNext(message -> { assertEquals(expectedContentType, message.getContentType()); @@ -379,7 +379,7 @@ public void serializeForwardCompatibility() { // Act: Deserialize Person (the older schema) assertNotNull(outputData.get(), "Value should have been set from the test."); - final Person readerPerson = encoder.decodeMessageData(outputData.get(), TypeReference.createInstance(Person.class)); + final Person readerPerson = encoder.deserializeMessageData(outputData.get(), TypeReference.createInstance(Person.class)); assertNotNull(readerPerson); assertEquals(name, readerPerson.getName()); @@ -396,14 +396,14 @@ public void throwsWhenConstructorNotAvailable() { // Arrange final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder( + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer( client, avroSerializer, serializerOptions); final PlayingCard playingCard = new PlayingCard(true, 10, PlayingCardSuit.DIAMONDS); final TypeReference typeReference = TypeReference.createInstance(InvalidMessage.class); // Act & Assert - StepVerifier.create(encoder.encodeMessageDataAsync(playingCard, typeReference)) + StepVerifier.create(encoder.serializeMessageDataAsync(playingCard, typeReference)) .expectError(IllegalArgumentException.class) .verify(); } @@ -424,7 +424,7 @@ public void backwardsCompatiblePreamble() throws IOException { final AvroSerializer avroSerializer = new AvroSerializer(true, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, avroSerializer, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); when(client.getSchema(MOCK_GUID)).thenReturn(Mono.just(schemaResponse)); @@ -448,7 +448,7 @@ public void backwardsCompatiblePreamble() throws IOException { message.setBodyAsBinaryData(binaryData); // Act - final PlayingCard actual = encoder.decodeMessageData(message, TypeReference.createInstance(PlayingCard.class)); + final PlayingCard actual = encoder.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); // Assert assertNotNull(actual); @@ -506,7 +506,7 @@ private SchemaRegistryAsyncClient getSchemaRegistryClient(TestInfo testInfo, Tes endpoint = PLAYBACK_ENDPOINT; } else { tokenCredential = new DefaultAzureCredentialBuilder().build(); - endpoint = System.getenv(SchemaRegistryApacheAvroEncoderIntegrationTest.SCHEMA_REGISTRY_ENDPOINT); + endpoint = System.getenv(SchemaRegistryApacheAvroSerializerIntegrationTest.SCHEMA_REGISTRY_ENDPOINT); assertNotNull(endpoint, "'endpoint' cannot be null in LIVE/RECORD mode."); } @@ -527,15 +527,15 @@ private SchemaRegistryAsyncClient getSchemaRegistryClient(TestInfo testInfo, Tes } /** - * Test class that extends from MessageWithMetadata + * Test class that extends from BinaryContent */ - static class MockMessage extends MessageWithMetadata { + static class MockMessage extends BinaryContent { } /** * This class does not expose the no-args constructor that we look for. */ - static class InvalidMessage extends MessageWithMetadata { + static class InvalidMessage extends BinaryContent { InvalidMessage(String contents) { super(); diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderIntegrationTest.registerAndGetSchema.json b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerIntegrationTest.registerAndGetSchema.json similarity index 100% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderIntegrationTest.registerAndGetSchema.json rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerIntegrationTest.registerAndGetSchema.json diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderTest.serializeForwardCompatibility.json b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerTest.serializeForwardCompatibility.json similarity index 100% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderTest.serializeForwardCompatibility.json rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerTest.serializeForwardCompatibility.json diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderTest.serializeFromPortal.json b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerTest.serializeFromPortal.json similarity index 100% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderTest.serializeFromPortal.json rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerTest.serializeFromPortal.json