77
88import tools .jackson .dataformat .xml .XmlMapper ;
99import tools .jackson .dataformat .xml .XmlTestUtil ;
10+ import tools .jackson .dataformat .xml .annotation .JacksonXmlText ;
1011
1112import static org .junit .jupiter .api .Assertions .assertEquals ;
1213
13- // [dataformat-xml#269]
14+ // [dataformat-xml#269], [dataformat-xml#448]
1415public class RawValueSerializationTest extends XmlTestUtil
1516{
17+ // [dataformat-xml#269]
1618 @ JsonPropertyOrder ({ "id" , "raw" })
1719 public static class RawWrapper {
1820 public int id = 42 ;
@@ -21,6 +23,16 @@ public static class RawWrapper {
2123 public String raw = "Mixed <b>content</b>" ;
2224 }
2325
26+ // [dataformat-xml#448]
27+ @ JsonPropertyOrder ({ "id" , "raw" })
28+ public static class RawWrapperWithXmlText {
29+ public int id = 42 ;
30+
31+ @ JacksonXmlText
32+ @ JsonRawValue
33+ public String raw = "Mixed <b>content</b>" ;
34+ }
35+
2436 /*
2537 /********************************************************
2638 /* Test methods
@@ -30,12 +42,22 @@ public static class RawWrapper {
3042 private final XmlMapper MAPPER = newMapper ();
3143
3244 @ Test
33- void testRawValueSerialization () throws Exception
45+ void testRawValueSerializationRegular () throws Exception
3446 {
3547 assertEquals ("<RawWrapper>"
3648 +"<id>42</id>"
3749 +"<raw>Mixed <b>content</b></raw>"
3850 +"</RawWrapper>" ,
3951 MAPPER .writeValueAsString (new RawWrapper ()).trim ());
4052 }
53+
54+ @ Test
55+ void testRawValueSerializationWithoutWrapping () throws Exception
56+ {
57+ assertEquals ("<RawWrapperWithXmlText>"
58+ +"<id>42</id>"
59+ +"Mixed <b>content</b>"
60+ +"</RawWrapperWithXmlText>" ,
61+ MAPPER .writeValueAsString (new RawWrapperWithXmlText ()).trim ());
62+ }
4163}
0 commit comments