1
1
package tools .jackson .dataformat .xml .misc ;
2
2
3
- import java .io .IOException ;
4
3
import java .util .ArrayList ;
5
4
import java .util .Arrays ;
6
5
10
9
import tools .jackson .databind .PropertyName ;
11
10
12
11
import tools .jackson .dataformat .xml .XmlTestUtil ;
12
+ import tools .jackson .dataformat .xml .XmlWriteFeature ;
13
13
import tools .jackson .dataformat .xml .XmlMapper ;
14
14
import tools .jackson .dataformat .xml .annotation .JacksonXmlRootElement ;
15
15
16
16
import static org .junit .jupiter .api .Assertions .assertEquals ;
17
17
import static org .junit .jupiter .api .Assertions .fail ;
18
18
19
19
// NOTE: even tho `@JacksonXmlRootElement` will be deprecated in near
20
- // future (possibly in 2.13) -- to be replaced by `@JsonRootName` -- this
20
+ // future -- to be replaced by `@JsonRootName` -- this
21
21
// test will use it to ensure we handle both annotations as expected
22
+ @ SuppressWarnings ({ "serial" })
22
23
public class RootNameTest extends XmlTestUtil
23
24
{
24
25
static class RootBeanBase
@@ -31,19 +32,21 @@ public RootBeanBase(String v) {
31
32
}
32
33
}
33
34
35
+ @ SuppressWarnings ("deprecation" )
34
36
@ JacksonXmlRootElement (localName ="root" )
35
37
static class RootBean extends RootBeanBase
36
38
{
37
39
protected RootBean () { super (); }
38
40
}
39
41
42
+ @ SuppressWarnings ("deprecation" )
40
43
@ JacksonXmlRootElement (localName ="nsRoot" , namespace ="http://foo" )
41
44
static class NsRootBean
42
45
{
43
46
public String value = "abc" ;
44
47
}
45
48
46
- @ SuppressWarnings ("serial " )
49
+ @ SuppressWarnings ("deprecation " )
47
50
@ JacksonXmlRootElement (localName ="TheStrings" )
48
51
static class StringList extends ArrayList <String > {
49
52
public StringList (String ...strings ) {
@@ -57,11 +60,13 @@ public StringList(String...strings) {
57
60
/**********************************************************
58
61
*/
59
62
60
- protected XmlMapper _xmlMapper = new XmlMapper ();
63
+ protected XmlMapper _xmlMapper = mapperBuilder ()
64
+ .disable (XmlWriteFeature .WRITE_NULLS_AS_XSI_NIL )
65
+ .build ();
61
66
62
67
// Unit test to verify that root name is properly set
63
68
@ Test
64
- public void testRootNameAnnotation () throws IOException
69
+ public void testRootNameAnnotation ()
65
70
{
66
71
String xml = _xmlMapper .writeValueAsString (new StringBean ());
67
72
@@ -87,7 +92,7 @@ public void testRootNameAnnotation() throws IOException
87
92
}
88
93
89
94
@ Test
90
- public void testDynamicRootName () throws IOException
95
+ public void testDynamicRootName ()
91
96
{
92
97
String xml ;
93
98
@@ -105,7 +110,7 @@ public void testDynamicRootName() throws IOException
105
110
}
106
111
107
112
@ Test
108
- public void testDynamicRootNameForList () throws IOException
113
+ public void testDynamicRootNameForList ()
109
114
{
110
115
String xml ;
111
116
0 commit comments