diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/ApacheAvroInteropUtil.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/ApacheAvroInteropUtil.java index bfe23b616..cf558bf71 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/ApacheAvroInteropUtil.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/ApacheAvroInteropUtil.java @@ -88,7 +88,7 @@ public byte[] apply(Schema schema, Object originalObject) throws IOException { } }; - private static final AvroMapper MAPPER = new AvroMapper(new AvroModule()); + private static final AvroMapper MAPPER = new AvroMapper(); /* * Special subclass of ReflectData that knows how to resolve and bind generic types. This saves us much pain of diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroNameTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroNameTest.java index 3c426e559..4954ecff7 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroNameTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroNameTest.java @@ -1,10 +1,10 @@ package com.fasterxml.jackson.dataformat.avro.interop.annotations; -import java.io.IOException; - import org.apache.avro.reflect.AvroName; import org.junit.Test; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.DatabindException; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; import com.fasterxml.jackson.dataformat.avro.AvroTestBase; import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase; @@ -31,6 +31,7 @@ public static class RecordWithNameCollision { @AvroName("otherField") public String firstField; + @JsonProperty public String otherField; } @@ -42,16 +43,26 @@ public void testRecordWithRenamedField() throws Exception{ assertThat(result).isEqualTo(original); } - // 02-Nov-2023, tatu: This test has been disabled for some reason, but - // without commentary. Fixed it a bit but ultimately can't enable yet + // 02-Nov-2023, tatu: This test had been disabled for long time: + // "Jackson Schema" case did not consider conflict where it was + // possible to select precedence... so needed to add another + // annotation to force problem. - // @Test + @Test public void testRecordWithNameCollision() throws Exception { try { schemaFunctor.apply(RecordWithNameCollision.class); fail("Should not pass"); - } catch (InvalidDefinitionException e) { - AvroTestBase.verifyException(e, "double field entry: otherField"); + } catch (DatabindException e) { + // InvalidDefinitionException with Avro schema + // JsonMapping with Jackson Schema + + final String msg = e.toString(); + + if (!msg.contains("double field entry: otherField") + && !msg.contains("property \"otherField\"")) { + fail("Got exception but without matching message: "+msg); + } } } }