Skip to content

Commit

Permalink
Add a failing test for #433
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 13, 2020
1 parent 7fabd98 commit 78448f9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public void testMapperSerialization() throws Exception
}

// [dataformat-xml#282]
@SuppressWarnings("deprecation")
public void testCopyWith() throws Exception
{
XmlMapper xmlMapper = newMapper();
Expand Down
Original file line number Diff line number Diff line change
@@ -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> price;

public List<Price> getPrice() {
if (price == null) {
price = new ArrayList<Price>();
}
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 =
"<Product>\n" +
" <Price>\n" +
" <Start>50</Start>\n" +
" <End>99</End>\n" +
" <Price>2.53</Price>\n" +
" </Price>\n" +
"</Product>";

Product433 main = MAPPER.readValue(XML, Product433.class);
assertNotNull(main);
}
}

0 comments on commit 78448f9

Please sign in to comment.