Skip to content

Commit 35555a2

Browse files
committed
Merge branch '2.11' into 2.12
2 parents a5d9e1b + 6c46d9b commit 35555a2

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListSerializationTest.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import java.io.IOException;
44
import java.util.ArrayList;
5+
import java.util.Iterator;
56
import java.util.List;
67

8+
import com.fasterxml.jackson.annotation.JsonProperty;
79
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
810
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
911
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
@@ -44,13 +46,35 @@ public StringListBean(String... texts)
4446
}
4547
}
4648

49+
// [dataformat-xml#148]
50+
static class Bean148 {
51+
@JsonProperty("item")
52+
@JacksonXmlElementWrapper(localName = "list")
53+
public Iterator<String> items() {
54+
return new Iterator<String>() {
55+
int item = 3;
56+
57+
@Override
58+
public boolean hasNext() {
59+
return item > 0;
60+
}
61+
62+
@Override
63+
public String next() {
64+
item--;
65+
return Integer.toString(item);
66+
}
67+
};
68+
}
69+
}
70+
4771
/*
4872
/**********************************************************
4973
/* Unit tests
5074
/**********************************************************
5175
*/
5276

53-
private final XmlMapper MAPPER = new XmlMapper();
77+
private final XmlMapper MAPPER = newMapper();
5478

5579
public void testSimpleWrappedList() throws IOException
5680
{
@@ -70,4 +94,11 @@ public void testStringList() throws IOException
7094
+"<strings><text>c</text></strings>"
7195
+"</stringList></StringListBean>", xml);
7296
}
97+
98+
// [dataformat-xml#148]
99+
public void testIteratorSerialization() throws Exception
100+
{
101+
assertEquals("<Bean148><item>2</item><item>1</item><item>0</item></Bean148>",
102+
MAPPER.writeValueAsString(new Bean148()).trim());
103+
}
73104
}

0 commit comments

Comments
 (0)