diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestEnums.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestEnums.java index 88f740643..0c148fe48 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestEnums.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestEnums.java @@ -1,16 +1,9 @@ package com.fasterxml.jackson.dataformat.xml.deser; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import com.fasterxml.jackson.dataformat.xml.XmlTestBase; +import com.fasterxml.jackson.dataformat.xml.*; public class TestEnums extends XmlTestBase { - /* - /********************************************************** - /* Helper types - /********************************************************** - */ - static enum TestEnum { A, B, C; } static class EnumBean @@ -27,11 +20,12 @@ public EnumBean() { } /********************************************************** */ + private final XmlMapper MAPPER = new XmlMapper(); + public void testEnum() throws Exception { - XmlMapper mapper = new XmlMapper(); - String str = mapper.writeValueAsString(new EnumBean(TestEnum.B)); - EnumBean result = mapper.readValue(str, EnumBean.class); + String xml = MAPPER.writeValueAsString(new EnumBean(TestEnum.B)); + EnumBean result = MAPPER.readValue(xml, EnumBean.class); assertNotNull(result); assertEquals(TestEnum.B, result.value); } diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/TestEnums.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/TestEnums.java index 76fcbfb04..7c572091d 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/TestEnums.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/TestEnums.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.ObjectMapper; + import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.XmlTestBase; @@ -27,6 +28,8 @@ public UntypedEnumBean() { } /********************************************************** */ + private final XmlMapper MAPPER = new XmlMapper(); + public void testUntypedEnum() throws Exception { ObjectMapper mapper = new XmlMapper(); @@ -43,4 +46,13 @@ 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); + } }