From 38a131263490f53d62ce77458738887620276277 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 30 Jun 2020 16:22:59 -0700 Subject: [PATCH] Fixed #121 (main fix in jackson-databind) --- release-notes/VERSION-2.x | 2 ++ .../deser/{TestEnums.java => EnumDeserTest.java} | 15 ++++++++++++--- .../dataformat/xml/failing/EnumIssue9Test.java | 9 --------- 3 files changed, 14 insertions(+), 12 deletions(-) rename src/test/java/com/fasterxml/jackson/dataformat/xml/deser/{TestEnums.java => EnumDeserTest.java} (65%) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 287a62633..5b7ecb294 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,8 @@ Project: jackson-dataformat-xml #97: Weird Exception during read with Type info (reported by Pascal G) +#121: `XmlMapper` not deserializing root-level Enums + (reported by bhkjersten@github) #124: Deserialization if an empty list (with empty XML tag) results in `null` (reported by Denis C) #205: `XmlMapper`/`UntypedObjectDeserializer` swallows duplicated elements in diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestEnums.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EnumDeserTest.java similarity index 65% rename from src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestEnums.java rename to src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EnumDeserTest.java index 0c148fe48..c4181fc8f 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestEnums.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EnumDeserTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.dataformat.xml.*; -public class TestEnums extends XmlTestBase +public class EnumDeserTest extends XmlTestBase { static enum TestEnum { A, B, C; } @@ -21,12 +21,21 @@ public EnumBean() { } */ private final XmlMapper MAPPER = new XmlMapper(); - - public void testEnum() throws Exception + + public void testEnumInBean() throws Exception { String xml = MAPPER.writeValueAsString(new EnumBean(TestEnum.B)); EnumBean result = MAPPER.readValue(xml, EnumBean.class); assertNotNull(result); assertEquals(TestEnum.B, result.value); } + + // [dataformat-xml#121] + public void testRootEnum() throws Exception + { + String xml = MAPPER.writeValueAsString(TestEnum.B); + TestEnum result = MAPPER.readValue(xml, TestEnum.class); + assertNotNull(result); + assertEquals(TestEnum.B, result); + } } diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/EnumIssue9Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/EnumIssue9Test.java index 2385f77ff..a0b9f1905 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/EnumIssue9Test.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/EnumIssue9Test.java @@ -47,13 +47,4 @@ public void testUntypedEnum() throws Exception assertEquals(TestEnum.B, result.value); } - - // [dataformat-xml#121] - public void testRootEnumIssue121() throws Exception - { - String xml = MAPPER.writeValueAsString(TestEnum.B); - TestEnum result = MAPPER.readValue(xml, TestEnum.class); - assertNotNull(result); - assertEquals(TestEnum.B, result); - } }