Skip to content

Commit 6195a21

Browse files
committed
Test for #108
1 parent a7f74c9 commit 6195a21

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.fasterxml.jackson.dataformat.xml.failing;
2+
3+
import java.util.*;
4+
5+
import com.fasterxml.jackson.dataformat.xml.*;
6+
import com.fasterxml.jackson.dataformat.xml.annotation.*;
7+
8+
public class AttributeFailIssue108Test extends XmlTestBase
9+
{
10+
static class Foo {
11+
@JacksonXmlElementWrapper(useWrapping = false)
12+
public List<Bar> firstBar = new ArrayList<Bar>();
13+
@JacksonXmlElementWrapper(useWrapping = false)
14+
public List<Bar> secondBar = new ArrayList<Bar>();
15+
}
16+
17+
static class Bar {
18+
public String value;
19+
20+
@JacksonXmlProperty(isAttribute = true)
21+
public int id;
22+
}
23+
24+
public void testIdsFromAttributes() throws Exception {
25+
XmlMapper xmlMapper = new XmlMapper();
26+
Foo foo = new Foo();
27+
Bar bar1 = new Bar();
28+
bar1.id = 1;
29+
bar1.value = "FIRST";
30+
foo.firstBar.add(bar1);
31+
Bar bar2 = new Bar();
32+
bar2.value = "SECOND";
33+
bar2.id = 2;
34+
foo.secondBar.add(bar2);
35+
String string = xmlMapper.writeValueAsString(foo);
36+
Foo fooRead = xmlMapper.readValue(string, Foo.class);
37+
assertEquals(foo.secondBar.get(0).id, fooRead.secondBar.get(0).id);
38+
}
39+
}

0 commit comments

Comments
 (0)