Merge pull request #13306 from gantoin/master

fix: Typos in Avro module
This commit is contained in:
Loredana Crusoveanu 2023-02-19 13:34:17 +02:00 committed by GitHub
commit 6abe6473da
3 changed files with 23 additions and 23 deletions

View File

@ -1,4 +1,4 @@
package com.baeldung.avro.util.serealization; package com.baeldung.avro.util.serialization;
import com.baeldung.avro.util.model.AvroHttpRequest; import com.baeldung.avro.util.model.AvroHttpRequest;
import org.apache.avro.io.DatumReader; import org.apache.avro.io.DatumReader;
@ -10,11 +10,11 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
public class AvroDeSerealizer { public class AvroDeSerializer {
private static Logger logger = LoggerFactory.getLogger(AvroDeSerealizer.class); private static Logger logger = LoggerFactory.getLogger(AvroDeSerializer.class);
public AvroHttpRequest deSerealizeAvroHttpRequestJSON(byte[] data) { public AvroHttpRequest deSerializeAvroHttpRequestJSON(byte[] data) {
DatumReader<AvroHttpRequest> reader = new SpecificDatumReader<>(AvroHttpRequest.class); DatumReader<AvroHttpRequest> reader = new SpecificDatumReader<>(AvroHttpRequest.class);
Decoder decoder = null; Decoder decoder = null;
try { try {
@ -27,7 +27,7 @@ public class AvroDeSerealizer {
return null; return null;
} }
public AvroHttpRequest deSerealizeAvroHttpRequestBinary(byte[] data) { public AvroHttpRequest deSerializeAvroHttpRequestBinary(byte[] data) {
DatumReader<AvroHttpRequest> employeeReader = new SpecificDatumReader<>(AvroHttpRequest.class); DatumReader<AvroHttpRequest> employeeReader = new SpecificDatumReader<>(AvroHttpRequest.class);
Decoder decoder = DecoderFactory.get() Decoder decoder = DecoderFactory.get()
.binaryDecoder(data, null); .binaryDecoder(data, null);

View File

@ -1,4 +1,4 @@
package com.baeldung.avro.util.serealization; package com.baeldung.avro.util.serialization;
import com.baeldung.avro.util.model.AvroHttpRequest; import com.baeldung.avro.util.model.AvroHttpRequest;
import org.apache.avro.io.*; import org.apache.avro.io.*;
@ -9,11 +9,11 @@ import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
public class AvroSerealizer { public class AvroSerializer {
private static final Logger logger = LoggerFactory.getLogger(AvroSerealizer.class); private static final Logger logger = LoggerFactory.getLogger(AvroSerializer.class);
public byte[] serealizeAvroHttpRequestJSON(AvroHttpRequest request) { public byte[] serializeAvroHttpRequestJSON(AvroHttpRequest request) {
DatumWriter<AvroHttpRequest> writer = new SpecificDatumWriter<>(AvroHttpRequest.class); DatumWriter<AvroHttpRequest> writer = new SpecificDatumWriter<>(AvroHttpRequest.class);
byte[] data = new byte[0]; byte[] data = new byte[0];
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
@ -30,7 +30,7 @@ public class AvroSerealizer {
return data; return data;
} }
public byte[] serealizeAvroHttpRequestBinary(AvroHttpRequest request) { public byte[] serializeAvroHttpRequestBinary(AvroHttpRequest request) {
DatumWriter<AvroHttpRequest> writer = new SpecificDatumWriter<>(AvroHttpRequest.class); DatumWriter<AvroHttpRequest> writer = new SpecificDatumWriter<>(AvroHttpRequest.class);
byte[] data = new byte[0]; byte[] data = new byte[0];
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();

View File

@ -1,4 +1,4 @@
package com.baeldung.avro.util.serealization; package com.baeldung.avro.util.serialization;
import com.baeldung.avro.util.model.Active; import com.baeldung.avro.util.model.Active;
import com.baeldung.avro.util.model.AvroHttpRequest; import com.baeldung.avro.util.model.AvroHttpRequest;
@ -13,16 +13,16 @@ import java.util.Objects;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class AvroSerealizerDeSerealizerIntegrationTest { public class AvroSerializerDeSerializerIntegrationTest {
AvroSerealizer serealizer; AvroSerializer serializer;
AvroDeSerealizer deSerealizer; AvroDeSerializer deserializer;
AvroHttpRequest request; AvroHttpRequest request;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
serealizer = new AvroSerealizer(); serializer = new AvroSerializer();
deSerealizer = new AvroDeSerealizer(); deserializer = new AvroDeSerializer();
ClientIdentifier clientIdentifier = ClientIdentifier.newBuilder() ClientIdentifier clientIdentifier = ClientIdentifier.newBuilder()
.setHostName("localhost") .setHostName("localhost")
@ -49,22 +49,22 @@ public class AvroSerealizerDeSerealizerIntegrationTest {
@Test @Test
public void WhenSerializedUsingJSONEncoder_thenObjectGetsSerialized() { public void WhenSerializedUsingJSONEncoder_thenObjectGetsSerialized() {
byte[] data = serealizer.serealizeAvroHttpRequestJSON(request); byte[] data = serializer.serializeAvroHttpRequestJSON(request);
assertTrue(Objects.nonNull(data)); assertTrue(Objects.nonNull(data));
assertTrue(data.length > 0); assertTrue(data.length > 0);
} }
@Test @Test
public void WhenSerializedUsingBinaryEncoder_thenObjectGetsSerialized() { public void WhenSerializedUsingBinaryEncoder_thenObjectGetsSerialized() {
byte[] data = serealizer.serealizeAvroHttpRequestBinary(request); byte[] data = serializer.serializeAvroHttpRequestBinary(request);
assertTrue(Objects.nonNull(data)); assertTrue(Objects.nonNull(data));
assertTrue(data.length > 0); assertTrue(data.length > 0);
} }
@Test @Test
public void WhenDeserializeUsingJSONDecoder_thenActualAndExpectedObjectsAreEqual() { public void WhenDeserializeUsingJSONDecoder_thenActualAndExpectedObjectsAreEqual() {
byte[] data = serealizer.serealizeAvroHttpRequestJSON(request); byte[] data = serializer.serializeAvroHttpRequestJSON(request);
AvroHttpRequest actualRequest = deSerealizer.deSerealizeAvroHttpRequestJSON(data); AvroHttpRequest actualRequest = deserializer.deSerializeAvroHttpRequestJSON(data);
assertEquals(actualRequest, request); assertEquals(actualRequest, request);
assertTrue(actualRequest.getRequestTime() assertTrue(actualRequest.getRequestTime()
.equals(request.getRequestTime())); .equals(request.getRequestTime()));
@ -72,12 +72,12 @@ public class AvroSerealizerDeSerealizerIntegrationTest {
@Test @Test
public void WhenDeserializeUsingBinaryecoder_thenActualAndExpectedObjectsAreEqual() { public void WhenDeserializeUsingBinaryecoder_thenActualAndExpectedObjectsAreEqual() {
byte[] data = serealizer.serealizeAvroHttpRequestBinary(request); byte[] data = serializer.serializeAvroHttpRequestBinary(request);
AvroHttpRequest actualRequest = deSerealizer.deSerealizeAvroHttpRequestBinary(data); AvroHttpRequest actualRequest = deserializer.deSerializeAvroHttpRequestBinary(data);
assertEquals(actualRequest, request); assertEquals(actualRequest, request);
assertTrue(actualRequest.getRequestTime() assertTrue(actualRequest.getRequestTime()
.equals(request.getRequestTime())); .equals(request.getRequestTime()));
} }
} }