From 78448f9fdcb3b47f3f03380d96616d40805aa62f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 13 Nov 2020 13:15:01 -0800 Subject: [PATCH] Add a failing test for #433 --- .../dataformat/xml/MapperCopyTest.java | 1 - .../xml/failing/ListDeser433Test.java | 60 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ListDeser433Test.java diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/MapperCopyTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/MapperCopyTest.java index ad0e13508..61ffb1c15 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/xml/MapperCopyTest.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/MapperCopyTest.java @@ -73,7 +73,6 @@ public void testMapperSerialization() throws Exception } // [dataformat-xml#282] - @SuppressWarnings("deprecation") public void testCopyWith() throws Exception { XmlMapper xmlMapper = newMapper(); diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ListDeser433Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ListDeser433Test.java new file mode 100644 index 000000000..5f860cbe9 --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ListDeser433Test.java @@ -0,0 +1,60 @@ +package com.fasterxml.jackson.dataformat.xml.failing; + +import java.math.BigDecimal; +import java.util.*; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.fasterxml.jackson.dataformat.xml.XmlTestBase; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + +// [dataformat-xml#433] +public class ListDeser433Test extends XmlTestBase +{ + @JacksonXmlRootElement(localName = "Product") + static class Product433 { + @JsonProperty("Prices") + public Prices prices; + } + + static class Prices { + @JsonProperty("Price") + public List price; + + public List getPrice() { + if (price == null) { + price = new ArrayList(); + } + return this.price; + } + } + + static class Price { + @JsonProperty("Start") + public Integer start; + @JsonProperty("End") + public Integer end; + @JsonProperty("Price") + public BigDecimal price; + } + + private final XmlMapper MAPPER = mapperBuilder() + .defaultUseWrapper(false) +// .annotationIntrospector(new XmlJaxbAnnotationIntrospector(TypeFactory.defaultInstance())) + .build(); + + // [dataformat-xml#433] + public void testIssue433() throws Exception { + final String XML = +"\n" + +" \n" + +" 50\n" + +" 99\n" + +" 2.53\n" + +" \n" + +""; + + Product433 main = MAPPER.readValue(XML, Product433.class); + assertNotNull(main); + } +}