Skip to content

Commit e003de0

Browse files
authored
Create XmlClassDeser735Test.java (#776)
1 parent c33e1e5 commit e003de0

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.dataformat.xml.records.failing;
1+
package com.fasterxml.jackson.dataformat.xml.records.tofix;
22

33
import org.junit.jupiter.api.Test;
44

@@ -9,8 +9,8 @@
99

1010
import static org.junit.jupiter.api.Assertions.*;
1111

12-
// [dataformat-xml#734]
13-
public class XmlRecordDeser734Test extends XmlTestUtil
12+
// [dataformat-xml#735]
13+
public class XmlRecordDeser735Test extends XmlTestUtil
1414
{
1515
record Amount(@JacksonXmlText String value,
1616
@JacksonXmlProperty(isAttribute = true, localName = "Ccy") String currency) {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.dataformat.xml.records.failing;
1+
package com.fasterxml.jackson.dataformat.xml.records.tofix;
22

33
import java.util.List;
44

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.fasterxml.jackson.dataformat.xml.deser;
2+
3+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
4+
import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
5+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
6+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
7+
import org.junit.jupiter.api.Test;
8+
9+
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
11+
// [dataformat-xml#735]
12+
public class XmlClassDeser735Test extends XmlTestUtil
13+
{
14+
public static class Amount {
15+
@JacksonXmlText
16+
private String value;
17+
18+
@JacksonXmlProperty(isAttribute = true, localName = "Ccy")
19+
private String currency;
20+
21+
// Need default constructor for deserialization (failure without it)
22+
public Amount() {
23+
24+
}
25+
26+
public Amount(String value, String currency) {
27+
this.value = value;
28+
this.currency = currency;
29+
}
30+
31+
public String getValue() {
32+
return value;
33+
}
34+
35+
public String getCurrency() {
36+
return currency;
37+
}
38+
}
39+
40+
private final String XML =
41+
a2q("<Amt Ccy='EUR'>1</Amt>");
42+
43+
@Test
44+
public void testDeser() throws Exception {
45+
XmlMapper mapper = new XmlMapper();
46+
Amount amt = mapper.readValue(XML, Amount.class);
47+
assertEquals("1", amt.value);
48+
assertEquals("EUR", amt.currency);
49+
}
50+
}

0 commit comments

Comments
 (0)