Skip to content

Commit 9781fac

Browse files
committed
2.4->master of tests for #121
1 parent 4067d53 commit 9781fac

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestEnums.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
package com.fasterxml.jackson.dataformat.xml.deser;
22

3-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
4-
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
3+
import com.fasterxml.jackson.dataformat.xml.*;
54

65
public class TestEnums extends XmlTestBase
76
{
8-
/*
9-
/**********************************************************
10-
/* Helper types
11-
/**********************************************************
12-
*/
13-
147
static enum TestEnum { A, B, C; }
158

169
static class EnumBean
@@ -27,11 +20,12 @@ public EnumBean() { }
2720
/**********************************************************
2821
*/
2922

23+
private final XmlMapper MAPPER = new XmlMapper();
24+
3025
public void testEnum() throws Exception
3126
{
32-
XmlMapper mapper = new XmlMapper();
33-
String str = mapper.writeValueAsString(new EnumBean(TestEnum.B));
34-
EnumBean result = mapper.readValue(str, EnumBean.class);
27+
String xml = MAPPER.writeValueAsString(new EnumBean(TestEnum.B));
28+
EnumBean result = MAPPER.readValue(xml, EnumBean.class);
3529
assertNotNull(result);
3630
assertEquals(TestEnum.B, result.value);
3731
}

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/TestEnums.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.annotation.JsonTypeInfo;
44

55
import com.fasterxml.jackson.databind.ObjectMapper;
6+
67
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
78
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
89

@@ -27,6 +28,8 @@ public UntypedEnumBean() { }
2728
/**********************************************************
2829
*/
2930

31+
private final XmlMapper MAPPER = new XmlMapper();
32+
3033
public void testUntypedEnum() throws Exception
3134
{
3235
ObjectMapper mapper = new XmlMapper();
@@ -43,4 +46,13 @@ public void testUntypedEnum() throws Exception
4346

4447
assertEquals(TestEnum.B, result.value);
4548
}
49+
50+
// [dataformat-xml#121]
51+
public void testRootEnumIssue121() throws Exception
52+
{
53+
String xml = MAPPER.writeValueAsString(TestEnum.B);
54+
TestEnum result = MAPPER.readValue(xml, TestEnum.class);
55+
assertNotNull(result);
56+
assertEquals(TestEnum.B, result);
57+
}
4658
}

0 commit comments

Comments
 (0)