Skip to content

Commit

Permalink
Fixed #121 (main fix in jackson-databind)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 30, 2020
1 parent e6b176e commit 38a1312
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 38a1312

Please sign in to comment.