diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/enums/EnumDeserDupName4409Test.java b/src/test/java/com/fasterxml/jackson/databind/deser/enums/EnumDeserDupName4409Test.java new file mode 100644 index 0000000000..9daa40a94d --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/databind/deser/enums/EnumDeserDupName4409Test.java @@ -0,0 +1,41 @@ +package com.fasterxml.jackson.databind.deser.enums; + +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.testutil.DatabindTestUtil; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +// for [databind#4409 +public class EnumDeserDupName4409Test extends DatabindTestUtil +{ + // for [databind#4409 + enum ColorMode4409Snake { + // Will become "rgb" + RGB, + // Will become "rgba" + RGBa, + // Will become "rgba" as well unless overriden, so: + @JsonProperty("RGBA") + RGBA + } + + private final ObjectMapper MAPPER = jsonMapperBuilder() + .propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE) + .build(); + + // for [databind#4409 + @Test + public void dupNameConflict4409() throws Exception + { + assertEquals(ColorMode4409Snake.RGBa, + MAPPER.readValue(q("RGBa"), ColorMode4409Snake.class)); + + assertEquals(q("RGBA"), + MAPPER.writeValueAsString(ColorMode4409Snake.RGBA)); + } +} diff --git a/src/test/java/com/fasterxml/jackson/databind/introspect/TestNamingStrategyStd.java b/src/test/java/com/fasterxml/jackson/databind/introspect/TestNamingStrategyStd.java index f86ce4ac22..69699e8963 100644 --- a/src/test/java/com/fasterxml/jackson/databind/introspect/TestNamingStrategyStd.java +++ b/src/test/java/com/fasterxml/jackson/databind/introspect/TestNamingStrategyStd.java @@ -238,6 +238,9 @@ public void setUtcZone(String utcZone) { {"uId", "u_id" }, // [databind#2267] {"xCoordinate", "x_coordinate" }, + // [databind#4409] + {"RGBA", "rgba"}, + {"RGBa", "rgba"}, }); final static List UPPER_SNAKE_CASE_NAME_TRANSLATIONS = Arrays.asList(new Object[][] {