Skip to content

Commit b1e8b47

Browse files
committed
Add a failing test for #374
1 parent ea186a0 commit b1e8b47

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/XmlTestBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public String toString() {
197197
+" }"
198198
+"}"
199199
;
200-
200+
201201
/*
202202
/**********************************************************
203203
/* Construction, factory methods
@@ -211,7 +211,7 @@ protected XmlTestBase() {
211211
protected XmlFactoryBuilder streamFactoryBuilder() {
212212
return XmlFactory.builder();
213213
}
214-
214+
215215
protected static XmlMapper newMapper() {
216216
return new XmlMapper();
217217
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.fasterxml.jackson.dataformat.xml.failing;
2+
3+
import com.fasterxml.jackson.annotation.JsonRootName;
4+
import com.fasterxml.jackson.databind.DeserializationFeature;
5+
import com.fasterxml.jackson.databind.SerializationFeature;
6+
import com.fasterxml.jackson.dataformat.xml.*;
7+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
8+
9+
public class Unwrapped374Test extends XmlTestBase
10+
{
11+
@JacksonXmlRootElement(localName = "Root")
12+
@JsonRootName("Root")
13+
static class Root {
14+
public int id = 1;
15+
}
16+
17+
private final XmlMapper MAPPER = mapperBuilder()
18+
.enable(SerializationFeature.WRAP_ROOT_VALUE)
19+
.enable(DeserializationFeature.UNWRAP_ROOT_VALUE)
20+
.build();
21+
22+
public void testUnwrappedRoundTrip() throws Exception
23+
{
24+
String xml = MAPPER.writeValueAsString(new Root());
25+
System.err.println("XML: "+xml);
26+
// assertEquals("<Root><id>hello</id></Root>", xml);
27+
Root result = MAPPER.readValue(xml, Root.class);
28+
assertNotNull(result);
29+
}
30+
}

0 commit comments

Comments
 (0)