33import java .io .*;
44import java .util .*;
55
6- import com .fasterxml .jackson .core .JsonGenerator ;
7- import com .fasterxml .jackson .databind .SerializerProvider ;
8- import com .fasterxml .jackson .databind .ser .std .StdScalarSerializer ;
9- import com .fasterxml .jackson .dataformat .xml .JacksonXmlModule ;
106import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
117import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
128import com .fasterxml .jackson .dataformat .xml .annotation .JacksonXmlCData ;
@@ -68,17 +64,6 @@ static class CDataStringArrayBean
6864 public String [] value = {"<some<data\" " , "abc" };
6965 }
7066
71- static class CustomSerializer extends StdScalarSerializer <String >
72- {
73- public CustomSerializer () { super (String .class ); }
74-
75- @ Override
76- public void serialize (String value , JsonGenerator jgen ,
77- SerializerProvider provider ) throws IOException {
78- jgen .writeString ("custom:" +value );
79- }
80- }
81-
8267 static class CustomMap extends LinkedHashMap <String , Integer > { }
8368
8469 /*
@@ -87,7 +72,7 @@ static class CustomMap extends LinkedHashMap<String, Integer> { }
8772 /**********************************************************
8873 */
8974
90- protected XmlMapper _xmlMapper = new XmlMapper ();
75+ private final XmlMapper _xmlMapper = new XmlMapper ();
9176
9277 public void testSimpleAttribute () throws IOException
9378 {
@@ -111,17 +96,6 @@ public void testSimpleAttrAndElem() throws IOException
11196 assertEquals ("<AttrAndElem id=\" 42\" ><elem>whatever</elem></AttrAndElem>" , xml );
11297 }
11398
114- public void testNil () throws IOException
115- {
116- XmlMapper mapper = new XmlMapper ();
117- mapper .configure (ToXmlGenerator .Feature .WRITE_NULLS_AS_XSI_NIL , true );
118- WrapperBean <String > bean = new WrapperBean <>(null );
119- // First, map in a general wrapper
120- String xml = mapper .writeValueAsString (bean );
121- assertEquals ("<WrapperBean><value xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\" true\" /></WrapperBean>" , xml );
122- }
123-
124- @ SuppressWarnings ("boxing" )
12599 public void testMap () throws IOException
126100 {
127101 // First, map in a general wrapper
@@ -176,15 +150,6 @@ public void testCDataStringArray() throws IOException
176150 xml = removeSjsxpNamespace (xml );
177151 assertEquals ("<CDataStringArrayBean><value><value><![CDATA[<some<data\" ]]></value><value><![CDATA[abc]]></value></value></CDataStringArrayBean>" , xml );
178152 }
179-
180- // for [dataformat-xml#41]
181- public void testCustomSerializer () throws Exception
182- {
183- JacksonXmlModule module = new JacksonXmlModule ();
184- module .addSerializer (String .class , new CustomSerializer ());
185- XmlMapper xml = new XmlMapper (module );
186- assertEquals ("<String>custom:foo</String>" , xml .writeValueAsString ("foo" ));
187- }
188153
189154 // manual 'test' to see "what would JAXB do?"
190155 /*
0 commit comments