Skip to content

Commit 1c36fee

Browse files
authored
Add passing test for #448 (#840)
1 parent 1147a03 commit 1c36fee

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

release-notes/CREDITS

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ Eduard Wirch (@ewirch)
5454
Ruven Chu (@Chubacca)
5555
* Reported #334: `@JacksonXmlElementWrapper(useWrapping=false)` fails when using
5656
a `DeserializerModifier` that delegates
57-
57+
(3.2.0)
58+
59+
Florian Krauthan (@fkrauthan)
60+
* Reported #448: Allow use of `@JsonRawValue` without wrapping element
61+
(3.2.0)
62+
5863
Lon Varscsak (@lonvarscsak)
5964
* Reported #449: Trouble dealing with JacksonXMLText if properties are present or
6065
if element is in a collection

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Version: 3.x (for earlier see VERSION-2.x)
4141
custom `TypeIdResolver`
4242
(reported by @ankagar)
4343
(fix by @cowtowncoder, w/ Claude code)
44+
#448: Allow use of `@JsonRawValue` without wrapping element
45+
(reported by Florian K)
4446
#449: Trouble dealing with JacksonXMLText if properties are present or
4547
if element is in a collection
4648
(reported by Lon V)

src/test/java/tools/jackson/dataformat/xml/ser/RawValueSerializationTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
import tools.jackson.dataformat.xml.XmlMapper;
99
import tools.jackson.dataformat.xml.XmlTestUtil;
10+
import tools.jackson.dataformat.xml.annotation.JacksonXmlText;
1011

1112
import static org.junit.jupiter.api.Assertions.assertEquals;
1213

13-
// [dataformat-xml#269]
14+
// [dataformat-xml#269], [dataformat-xml#448]
1415
public 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

Comments
 (0)