11package tools .jackson .dataformat .xml .misc ;
22
3- import java .io .IOException ;
43import java .util .ArrayList ;
54import java .util .Arrays ;
65
109import tools .jackson .databind .PropertyName ;
1110
1211import tools .jackson .dataformat .xml .XmlTestUtil ;
12+ import tools .jackson .dataformat .xml .XmlWriteFeature ;
1313import tools .jackson .dataformat .xml .XmlMapper ;
1414import tools .jackson .dataformat .xml .annotation .JacksonXmlRootElement ;
1515
1616import static org .junit .jupiter .api .Assertions .assertEquals ;
1717import static org .junit .jupiter .api .Assertions .fail ;
1818
1919// 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
2121// test will use it to ensure we handle both annotations as expected
22+ @ SuppressWarnings ({ "serial" })
2223public class RootNameTest extends XmlTestUtil
2324{
2425 static class RootBeanBase
@@ -31,19 +32,21 @@ public RootBeanBase(String v) {
3132 }
3233 }
3334
35+ @ SuppressWarnings ("deprecation" )
3436 @ JacksonXmlRootElement (localName ="root" )
3537 static class RootBean extends RootBeanBase
3638 {
3739 protected RootBean () { super (); }
3840 }
3941
42+ @ SuppressWarnings ("deprecation" )
4043 @ JacksonXmlRootElement (localName ="nsRoot" , namespace ="http://foo" )
4144 static class NsRootBean
4245 {
4346 public String value = "abc" ;
4447 }
4548
46- @ SuppressWarnings ("serial " )
49+ @ SuppressWarnings ("deprecation " )
4750 @ JacksonXmlRootElement (localName ="TheStrings" )
4851 static class StringList extends ArrayList <String > {
4952 public StringList (String ...strings ) {
@@ -57,11 +60,13 @@ public StringList(String...strings) {
5760 /**********************************************************
5861 */
5962
60- protected XmlMapper _xmlMapper = new XmlMapper ();
63+ protected XmlMapper _xmlMapper = mapperBuilder ()
64+ .disable (XmlWriteFeature .WRITE_NULLS_AS_XSI_NIL )
65+ .build ();
6166
6267 // Unit test to verify that root name is properly set
6368 @ Test
64- public void testRootNameAnnotation () throws IOException
69+ public void testRootNameAnnotation ()
6570 {
6671 String xml = _xmlMapper .writeValueAsString (new StringBean ());
6772
@@ -87,7 +92,7 @@ public void testRootNameAnnotation() throws IOException
8792 }
8893
8994 @ Test
90- public void testDynamicRootName () throws IOException
95+ public void testDynamicRootName ()
9196 {
9297 String xml ;
9398
@@ -105,7 +110,7 @@ public void testDynamicRootName() throws IOException
105110 }
106111
107112 @ Test
108- public void testDynamicRootNameForList () throws IOException
113+ public void testDynamicRootNameForList ()
109114 {
110115 String xml ;
111116
0 commit comments