Skip to content

Commit d2a04f8

Browse files
committed
Add failing test for #423
1 parent b697b55 commit d2a04f8

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/XmlTextViaCreator306Test.java

+27
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.beans.ConstructorProperties;
44

5+
import com.fasterxml.jackson.annotation.JsonCreator;
56
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
67
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
78
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
@@ -13,6 +14,7 @@
1314
// special meaning so that annotation CANNOT specify it, either.
1415
public class XmlTextViaCreator306Test extends XmlTestBase
1516
{
17+
// [dataformat-xml#306]
1618
@JacksonXmlRootElement(localName = "ROOT")
1719
static class Root {
1820
@JacksonXmlProperty(localName = "CHILD")
@@ -64,6 +66,21 @@ static class ChildWithoutConstructor {
6466
public String el;
6567
}
6668

69+
// [dataformat-xml#423]
70+
static class Sample423
71+
{
72+
final String text;
73+
final String attribute;
74+
75+
@JsonCreator
76+
public Sample423(@JacksonXmlText String text,
77+
@JacksonXmlProperty(localName = "attribute", isAttribute = true)
78+
String attribute) {
79+
this.text = text;
80+
this.attribute = attribute;
81+
}
82+
}
83+
6784
/*
6885
/********************************************************
6986
/* Test methods
@@ -72,6 +89,7 @@ static class ChildWithoutConstructor {
7289

7390
private final XmlMapper MAPPER = newMapper();
7491

92+
// [dataformat-xml#306]
7593
public void testIssue306WithCtor() throws Exception
7694
{
7795
final String XML = "<ROOT><CHILD attr='attr_value'>text</CHILD></ROOT>";
@@ -85,4 +103,13 @@ public void testIssue306NoCtor() throws Exception
85103
RootWithoutConstructor rootNoCtor = MAPPER.readValue(XML, RootWithoutConstructor.class);
86104
assertNotNull(rootNoCtor);
87105
}
106+
107+
// [dataformat-xml#423]
108+
public void testXmlTextViaCtor423() throws Exception
109+
{
110+
final String XML = "<Sample423 attribute='attrValue'>text value</Sample423>";
111+
Sample423 result = MAPPER.readValue(XML, Sample423.class);
112+
assertEquals("attrValue", result.attribute);
113+
assertEquals("text value", result.text);
114+
}
88115
}

0 commit comments

Comments
 (0)