3
3
import java .io .*;
4
4
import java .util .*;
5
5
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 ;
10
6
import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
11
7
import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
12
8
import com .fasterxml .jackson .dataformat .xml .annotation .JacksonXmlCData ;
@@ -68,17 +64,6 @@ static class CDataStringArrayBean
68
64
public String [] value = {"<some<data\" " , "abc" };
69
65
}
70
66
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
-
82
67
static class CustomMap extends LinkedHashMap <String , Integer > { }
83
68
84
69
/*
@@ -87,7 +72,7 @@ static class CustomMap extends LinkedHashMap<String, Integer> { }
87
72
/**********************************************************
88
73
*/
89
74
90
- protected XmlMapper _xmlMapper = new XmlMapper ();
75
+ private final XmlMapper _xmlMapper = new XmlMapper ();
91
76
92
77
public void testSimpleAttribute () throws IOException
93
78
{
@@ -111,17 +96,6 @@ public void testSimpleAttrAndElem() throws IOException
111
96
assertEquals ("<AttrAndElem id=\" 42\" ><elem>whatever</elem></AttrAndElem>" , xml );
112
97
}
113
98
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" )
125
99
public void testMap () throws IOException
126
100
{
127
101
// First, map in a general wrapper
@@ -176,15 +150,6 @@ public void testCDataStringArray() throws IOException
176
150
xml = removeSjsxpNamespace (xml );
177
151
assertEquals ("<CDataStringArrayBean><value><value><![CDATA[<some<data\" ]]></value><value><![CDATA[abc]]></value></value></CDataStringArrayBean>" , xml );
178
152
}
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
- }
188
153
189
154
// manual 'test' to see "what would JAXB do?"
190
155
/*
0 commit comments