Skip to content

Commit 12ddad9

Browse files
committed
Mark #307 as fixed; fix already included for one of other List deser bugs.
1 parent cfd377a commit 12ddad9

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Project: jackson-dataformat-xml
2929
(requested by Dave J)
3030
#273: Input mismatch with case-insensitive properties
3131
(reported by Joseph P)
32+
#307: Missing collection item when they are not wrapped during unmarshal
33+
with multiple namespaces
34+
(reported by wanchongtai@github)
3235
#314: Jackson gets confused by parent list element
3336
(reported by Eduard W)
3437
#318: XMLMapper fails to deserialize null (POJO reference) from blank tag
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.fasterxml.jackson.dataformat.xml.lists;
2+
3+
import java.util.List;
4+
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
7+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
8+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
9+
10+
public class ListDeser307Test extends XmlTestBase
11+
{
12+
@JacksonXmlRootElement(localName = "customer")
13+
public class CustomerWithoutWrapper {
14+
public Long customerId;
15+
public String customerName;
16+
17+
@JacksonXmlElementWrapper(useWrapping = false)
18+
public List<Account> account;
19+
}
20+
21+
public class Account {
22+
public Long accountId;
23+
public String accountName;
24+
public String postcode;
25+
}
26+
27+
/*
28+
/********************************************************
29+
/* Test methods
30+
/********************************************************
31+
*/
32+
33+
private final ObjectMapper MAPPER = newMapper();
34+
35+
// [dataformat-xml#307]
36+
public void testListDeser307() throws Exception
37+
{
38+
final String XML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
39+
"<customer xmlns=\"http://www.archer-tech.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
40+
" <customerId>1</customerId>\n" +
41+
" <customerName>Michael Judy</customerName>\n" +
42+
" <account>\n" +
43+
" <accountId>100</accountId>\n" +
44+
" <accountName>Michael</accountName>\n" +
45+
" <postcode xsi:nil=\"true\"></postcode>\n" +
46+
" </account>\n" +
47+
" <account>\n" +
48+
" <accountId>200</accountId>\n" +
49+
" <accountName>Judy</accountName>\n" +
50+
" <postcode xsi:nil=\"true\"></postcode>\n" +
51+
" </account> \n" +
52+
"</customer>";
53+
CustomerWithoutWrapper result =
54+
MAPPER.readValue(XML, CustomerWithoutWrapper.class);
55+
assertNotNull(result);
56+
assertNotNull(result.account);
57+
assertEquals(2, result.account.size());
58+
}
59+
}

0 commit comments

Comments
 (0)