1414
1515import com .fasterxml .jackson .core .JsonProcessingException ;
1616import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
17+ import com .fasterxml .jackson .annotation .JsonProperty ;
1718
1819public class XMLSerializeDeserializeUnitTest {
1920
@@ -48,6 +49,24 @@ public void whenJavaGotFromXmlFile_thenCorrect() throws IOException {
4849 assertTrue (value .getX () == 1 && value .getY () == 2 );
4950 }
5051
52+ @ Test
53+ public void whenJavaGotFromXmlStrWithCapitalElem_thenCorrect () throws IOException {
54+ XmlMapper xmlMapper = new XmlMapper ();
55+ SimpleBeanForCapitalizedFields value = xmlMapper .
56+ readValue ("<SimpleBeanForCapitalizedFields><X>1</X><y>2</y></SimpleBeanForCapitalizedFields>" ,
57+ SimpleBeanForCapitalizedFields .class );
58+ assertTrue (value .getX () == 1 && value .getY () == 2 );
59+ }
60+
61+ @ Test
62+ public void whenJavaSerializedToXmlFileWithCapitalizedField_thenCorrect () throws IOException {
63+ XmlMapper xmlMapper = new XmlMapper ();
64+ xmlMapper .writeValue (new File ("target/simple_bean_capitalized.xml" ),
65+ new SimpleBeanForCapitalizedFields ());
66+ File file = new File ("target/simple_bean_capitalized.xml" );
67+ assertNotNull (file );
68+ }
69+
5170 private static String inputStreamToString (InputStream is ) throws IOException {
5271 BufferedReader br ;
5372 StringBuilder sb = new StringBuilder ();
@@ -83,3 +102,25 @@ public void setY(int y) {
83102 }
84103
85104}
105+
106+ class SimpleBeanForCapitalizedFields {
107+ @ JsonProperty ("X" )
108+ private int x = 1 ;
109+ private int y = 2 ;
110+
111+ public int getX () {
112+ return x ;
113+ }
114+
115+ public void setX (int x ) {
116+ this .x = x ;
117+ }
118+
119+ public int getY () {
120+ return y ;
121+ }
122+
123+ public void setY (int y ) {
124+ this .y = y ;
125+ }
126+ }
0 commit comments