File tree 1 file changed +45
-0
lines changed
src/test/java/com/fasterxml/jackson/dataformat/xml
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .dataformat .xml ;
2
+
3
+ import java .util .ArrayList ;
4
+ import java .util .List ;
5
+
6
+ import com .fasterxml .jackson .annotation .JsonIdentityInfo ;
7
+ import com .fasterxml .jackson .annotation .ObjectIdGenerators ;
8
+
9
+ /**
10
+ * Unit test to showcase issue #104, based on TestObjectIdDeserialization unit test in databind package.
11
+ *
12
+ */
13
+ public class TestIssue104 extends XmlTestBase {
14
+ // // Classes for external id from property annotations:
15
+
16
+ static class IdWrapper
17
+ {
18
+ @ JsonIdentityInfo (generator =ObjectIdGenerators .IntSequenceGenerator .class , property ="id" )
19
+ public ValueNode node ;
20
+
21
+ public IdWrapper () { }
22
+ public IdWrapper (int v ) {
23
+ node = new ValueNode (v );
24
+ }
25
+ }
26
+
27
+ static class ValueNode {
28
+ public List <Integer > value = new ArrayList <Integer >();
29
+ public IdWrapper next ;
30
+
31
+ public ValueNode () { this (0 ); }
32
+ public ValueNode (int v ) { value .add (v ); }
33
+ }
34
+
35
+ private final XmlMapper MAPPER = new XmlMapper ();
36
+
37
+ // Another test to ensure ordering is not required (i.e. can do front references)
38
+ public void testSimpleCollectionDeserWithForwardRefs () throws Exception
39
+ {
40
+ IdWrapper result = MAPPER .readValue ("<IdWrapper><node><value><value>7</value></value><next><node>1</node></next><id>1</id></node></IdWrapper>"
41
+ ,IdWrapper .class );
42
+ assertEquals (7 , (int )result .node .value .get (0 ));
43
+ assertSame (result .node , result .node .next .node );
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments