Skip to content

Commit ab310eb

Browse files
committed
Add failing test for #314
1 parent 1ecd22a commit ab310eb

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.fasterxml.jackson.dataformat.xml.failing;
2+
3+
import java.util.*;
4+
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
7+
8+
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
9+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
10+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
11+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
12+
13+
// [dataformat-xml#314]
14+
public class ListDeser314Test extends XmlTestBase
15+
{
16+
static class Customer314 {
17+
@JacksonXmlElementWrapper(localName = "Customer", useWrapping = false)
18+
@JacksonXmlProperty(localName = "Address")
19+
public List<Address314> address;
20+
}
21+
22+
static class Address314 {
23+
public String stateProv;
24+
public CountryName314 countryName;
25+
}
26+
27+
static class CountryName314 {
28+
public String code;
29+
@JacksonXmlText
30+
public String name;
31+
}
32+
33+
/*
34+
/********************************************************
35+
/* Test methods
36+
/********************************************************
37+
*/
38+
39+
private final ObjectMapper MAPPER = mapperBuilder()
40+
.propertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE)
41+
.build();
42+
43+
// [dataform#314]
44+
public void testDeser314Order1() throws Exception
45+
{
46+
String content = ""
47+
+ "<Customer>\n"
48+
+ " <Address>\n"
49+
+ " <StateProv StateCode='DE-NI'>Niedersachsen</StateProv>\n"
50+
+ " <CountryName Code='DE'>Deutschland</CountryName>\n"
51+
+ " </Address>\n"
52+
+ "</Customer>"
53+
;
54+
Customer314 result = MAPPER.readValue(content, Customer314.class);
55+
assertNotNull(result);
56+
}
57+
58+
public void testDeser314Order2() throws Exception
59+
{
60+
String content = ""
61+
+ "<Customer>\n"
62+
+ " <Address>\n"
63+
+ " <CountryName Code='DE'>Deutschland</CountryName>\n"
64+
+ " <StateProv StateCode='DE-NI'>Niedersachsen</StateProv>\n"
65+
+ " </Address>\n"
66+
+ "</Customer>"
67+
;
68+
Customer314 result = MAPPER.readValue(content, Customer314.class);
69+
assertNotNull(result);
70+
}
71+
72+
public void testDeser314Address() throws Exception
73+
{
74+
String content = ""
75+
+ " <Address>\n"
76+
+ " <CountryName Code=\"DE\">Deutschland</CountryName>\n"
77+
+ " <StateProv StateCode=\"DE-NI\">Niedersachsen</StateProv>\n"
78+
+ " </Address>\n"
79+
;
80+
Address314 result = MAPPER.readValue(content, Address314.class);
81+
assertNotNull(result);
82+
}
83+
}

0 commit comments

Comments
 (0)