Skip to content

Commit 54a72b5

Browse files
committed
Add passing test for #547
1 parent e29a1dd commit 54a72b5

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.fasterxml.jackson.dataformat.xml.deser.creator;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
7+
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
8+
9+
public class NestedSingleArgCtors547Test extends XmlTestBase
10+
{
11+
private static final XmlMapper XML_MAPPER = newMapper();
12+
13+
static class Outer547Del {
14+
public Inner547Del inner;
15+
}
16+
17+
static class Inner547Del {
18+
protected String value;
19+
20+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
21+
public Inner547Del(@JsonProperty("value") String v) {
22+
value = v;
23+
}
24+
}
25+
26+
static class Outer547Props {
27+
public Inner547Props inner;
28+
}
29+
30+
static class Inner547Props {
31+
protected String value;
32+
33+
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
34+
public Inner547Props(@JsonProperty("value") String v) {
35+
value = v;
36+
}
37+
38+
protected Inner547Props() { }
39+
}
40+
41+
// [dataformat-xml#547]
42+
public void testNested1ArgCtorsDelegating() throws Exception
43+
{
44+
String xml = "<outer><inner></inner></outer>";
45+
Outer547Del result = XML_MAPPER.readValue(xml, Outer547Del.class);
46+
assertNotNull(result.inner);
47+
assertEquals("", result.inner.value);
48+
}
49+
50+
// [dataformat-xml#547]
51+
public void testNested1ArgCtorsProps() throws Exception
52+
{
53+
String xml = "<outer><inner></inner></outer>";
54+
Outer547Props result = XML_MAPPER.readValue(xml, Outer547Props.class);
55+
assertNotNull(result.inner);
56+
assertNull(result.inner.value);
57+
}
58+
}

0 commit comments

Comments
 (0)