Skip to content

Commit c106194

Browse files
committed
Add a serialization test for @JsonRawValue to verify functionality
1 parent 426b2d9 commit c106194

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser399Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static class Test {
1919
@JacksonXmlProperty(localName = "test")
2020
@JacksonXmlElementWrapper(useWrapping = false)
2121
List<Test> list = new ArrayList<Test>();
22-
}
22+
}
2323

2424
private final XmlMapper MAPPER = newMapper();
2525

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.fasterxml.jackson.dataformat.xml.ser;
2+
3+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
4+
import com.fasterxml.jackson.annotation.JsonRawValue;
5+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
6+
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
7+
8+
// [dataformat-xml#269]
9+
public class RawValueSerializationTest extends XmlTestBase
10+
{
11+
@JsonPropertyOrder({ "id", "raw" })
12+
static class RawWrapper {
13+
public int id = 42;
14+
15+
@JsonRawValue
16+
public String raw = "Mixed <b>content</b>";
17+
}
18+
19+
/*
20+
/********************************************************
21+
/* Test methods
22+
/********************************************************
23+
*/
24+
25+
private final XmlMapper MAPPER = newMapper();
26+
27+
public void testRawValueSerialization() throws Exception
28+
{
29+
assertEquals("<RawWrapper>"
30+
+"<id>42</id>"
31+
+"<raw>Mixed <b>content</b></raw>"
32+
+"</RawWrapper>",
33+
MAPPER.writeValueAsString(new RawWrapper()).trim());
34+
}
35+
}

0 commit comments

Comments
 (0)