Skip to content

Commit b65606d

Browse files
committed
Add a test for #3171
1 parent 9cfcf8d commit b65606d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/jdk/EnumDefaultReadTest.java

+13
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,19 @@ public void testWithFailOnNumbersAndReadUnknownAsDefault()
207207
_verifyOkDeserialization(r, "2", CustomEnumWithDefault.class, CustomEnumWithDefault.ZERO);
208208
}
209209

210+
// [databind#3171]: Ensure "" gets returned as Default Value, not coerced
211+
public void testEmptyStringAsDefault() throws Exception
212+
{
213+
ObjectReader r = MAPPER.readerFor(SimpleEnumWithDefault.class)
214+
.with(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE);
215+
assertEquals(SimpleEnumWithDefault.ONE,
216+
r.readValue(quote("ONE")));
217+
assertEquals(SimpleEnumWithDefault.ZERO,
218+
r.readValue(quote("Zero")));
219+
assertEquals(SimpleEnumWithDefault.ZERO,
220+
r.readValue(quote("")));
221+
}
222+
210223
private <T> void _verifyOkDeserialization(ObjectReader reader, String fromValue,
211224
Class<T> toValueType, T expValue)
212225
throws IOException

0 commit comments

Comments
 (0)