File tree 1 file changed +39
-0
lines changed
src/test/java/com/fasterxml/jackson/dataformat/xml/failing
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments