Skip to content

Commit e8a13bb

Browse files
committed
minor test cleanup
1 parent 539286d commit e8a13bb

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ protected InnerBean2() { }
5151
public InnerBean2(String s) { str2 = s; }
5252
}
5353

54-
private final XmlMapper MAPPER = newMapper();
55-
5654
public void testIssue469() throws Exception
5755
{
56+
// Here we just use default settings (which defaults to wrappers)
57+
final XmlMapper mapper = newMapper();
58+
5859
// First: create POJO value to test round-trip:
5960
{
6061
OuterBean source = new OuterBean();
@@ -63,10 +64,10 @@ public void testIssue469() throws Exception
6364
items.add(new InnerBean2("foo"));
6465
source.middle.inner2 = items;
6566

66-
String xml = MAPPER.writerWithDefaultPrettyPrinter()
67+
String xml = mapper.writerWithDefaultPrettyPrinter()
6768
.writeValueAsString(source);
6869

69-
OuterBean result = MAPPER.readValue(xml, OuterBean.class);
70+
OuterBean result = mapper.readValue(xml, OuterBean.class);
7071

7172
MiddleBean mid = result.middle;
7273
assertNotNull(mid);
@@ -83,7 +84,7 @@ public void testIssue469() throws Exception
8384
" </Middle>\n" +
8485
"</OuterBean>\n";
8586

86-
OuterBean outer = MAPPER.readValue(xmlInput, OuterBean.class);
87+
OuterBean outer = mapper.readValue(xmlInput, OuterBean.class);
8788

8889
MiddleBean mid = outer.middle;
8990
assertNotNull(mid);

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.List;
77

88
import com.fasterxml.jackson.annotation.JsonProperty;
9+
import com.fasterxml.jackson.dataformat.xml.JacksonXmlAnnotationIntrospector;
910
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
1011
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
1112
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
@@ -81,6 +82,17 @@ public void testSimpleWrappedList() throws IOException
8182
String xml = MAPPER.writeValueAsString(new ListBean(1, 2, 3));
8283
xml = removeSjsxpNamespace(xml);
8384
assertEquals("<ListBean><values><values>1</values><values>2</values><values>3</values></values></ListBean>", xml);
85+
86+
// for [dataformat-xml#469] try forcing wrapping:
87+
XmlMapper unwrapMapper = XmlMapper.builder()
88+
.annotationIntrospector(new JacksonXmlAnnotationIntrospector(false))
89+
.build();
90+
xml = unwrapMapper.writeValueAsString(new ListBean(1, 2, 3));
91+
xml = removeSjsxpNamespace(xml);
92+
assertEquals("<ListBean>"
93+
+"<values>1</values><values>2</values><values>3</values>"
94+
+"</ListBean>",
95+
xml);
8496
}
8597

8698
public void testStringList() throws IOException

0 commit comments

Comments
 (0)