|
3 | 3 | import java.util.ArrayList;
|
4 | 4 | import java.util.List;
|
5 | 5 |
|
| 6 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 7 | +import com.fasterxml.jackson.annotation.JsonProperty; |
6 | 8 | import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
7 | 9 | import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
|
8 | 10 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
@@ -32,6 +34,20 @@ static class EmptyStrings25
|
32 | 34 | public String b = "NOT SET";
|
33 | 35 | }
|
34 | 36 |
|
| 37 | + // [dataformat-xml#427] |
| 38 | + static class Stuff427 { |
| 39 | + String str; |
| 40 | + |
| 41 | + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) |
| 42 | + public Stuff427(String s) { str = s; } |
| 43 | + } |
| 44 | + |
| 45 | + static class Product427 { |
| 46 | + Stuff427 stuff; |
| 47 | + |
| 48 | + public Product427(@JsonProperty("stuff") Stuff427 s) { stuff = s; } |
| 49 | + } |
| 50 | + |
35 | 51 | /*
|
36 | 52 | /**********************************************************
|
37 | 53 | /* Test methods
|
@@ -89,4 +105,16 @@ public void testEmptyStringFromElemAndAttr() throws Exception
|
89 | 105 | assertEquals("", ob.a);
|
90 | 106 | assertEquals("", ob.b);
|
91 | 107 | }
|
| 108 | + |
| 109 | + // [dataformat-xml#427] |
| 110 | + public void testEmptyIssue427() throws Exception |
| 111 | + { |
| 112 | + String xml = "<product><stuff></stuff></product>"; |
| 113 | + |
| 114 | + Product427 product = MAPPER.readValue(xml, Product427.class); |
| 115 | + |
| 116 | + assertNotNull(product); |
| 117 | + assertNotNull(product.stuff); |
| 118 | + assertEquals("", product.stuff.str); |
| 119 | + } |
92 | 120 | }
|
0 commit comments