File tree 2 files changed +17
-11
lines changed
src/test/java/com/fasterxml/jackson/dataformat/xml
2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .dataformat .xml .deser ;
2
2
3
- import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
4
- import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
3
+ import com .fasterxml .jackson .dataformat .xml .*;
5
4
6
5
public class TestEnums extends XmlTestBase
7
6
{
8
- /*
9
- /**********************************************************
10
- /* Helper types
11
- /**********************************************************
12
- */
13
-
14
7
static enum TestEnum { A , B , C ; }
15
8
16
9
static class EnumBean
@@ -27,11 +20,12 @@ public EnumBean() { }
27
20
/**********************************************************
28
21
*/
29
22
23
+ private final XmlMapper MAPPER = new XmlMapper ();
24
+
30
25
public void testEnum () throws Exception
31
26
{
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 );
35
29
assertNotNull (result );
36
30
assertEquals (TestEnum .B , result .value );
37
31
}
Original file line number Diff line number Diff line change 3
3
import com .fasterxml .jackson .annotation .JsonTypeInfo ;
4
4
5
5
import com .fasterxml .jackson .databind .ObjectMapper ;
6
+
6
7
import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
7
8
import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
8
9
@@ -27,6 +28,8 @@ public UntypedEnumBean() { }
27
28
/**********************************************************
28
29
*/
29
30
31
+ private final XmlMapper MAPPER = new XmlMapper ();
32
+
30
33
public void testUntypedEnum () throws Exception
31
34
{
32
35
ObjectMapper mapper = new XmlMapper ();
@@ -43,4 +46,13 @@ public void testUntypedEnum() throws Exception
43
46
44
47
assertEquals (TestEnum .B , result .value );
45
48
}
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
+ }
46
58
}
You can’t perform that action at this time.
0 commit comments