martin-g commented on a change in pull request #1391:
URL: https://github.com/apache/avro/pull/1391#discussion_r743468730



##########
File path: 
lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflectDatumWithAnonymousEnum.java
##########
@@ -0,0 +1,185 @@
+package org.apache.avro.reflect;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.avro.Schema;
+import org.apache.avro.io.Decoder;
+import org.apache.avro.io.DecoderFactory;
+import org.apache.avro.io.Encoder;
+import org.apache.avro.io.EncoderFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * https://issues.apache.org/jira/browse/AVRO-1851
+ */
+public class TestReflectDatumWithAnonymousEnum {
+  private static Pojo pojo;
+
+  @BeforeClass
+  public static void init() {
+    pojo = new Pojo();
+    Person person = new Person();
+    person.setAddress("Address");
+    pojo.setTestEnum(TestEnum.V);
+    pojo.setPerson(person);
+  }
+
+  // Properly serializes and deserializes a POJO with an enum instance 
(TestEnum#V)
+  @Test
+  public void handleProperlyEnumInstances() throws IOException {
+    byte[] output = serialize(pojo);
+    Pojo deserializedPojo = deserialize(output);
+    assertEquals(pojo, deserializedPojo);
+  }
+
+  // The test fails because the Schema doesn't support null value for the 
Person's name
+  @Test(expected = NullPointerException.class)
+  public void avroEnumWithNotNullTest() throws IOException {

Review comment:
       Removed it!
   And made the test more fancy by using anonymous instances for Pojo and 
Person too.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to