Skip to content

Commit c2fe22f

Browse files
committed
Refactoring test
1 parent 4f5fb6b commit c2fe22f

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNil354Test.java renamed to src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilBasicTest.java

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
44
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
55

6-
public class XsiNil354Test extends XmlTestBase
6+
public class XsiNilBasicTest extends XmlTestBase
77
{
88
private final static String XSI_NS_DECL = "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'";
9-
9+
1010
protected static class DoubleWrapper {
1111
public Double d;
1212

@@ -16,6 +16,13 @@ public DoubleWrapper(Double value) {
1616
}
1717
}
1818

19+
protected static class DoubleWrapper2 {
20+
public Double a = 100.0; // init to ensure it gets overwritten
21+
public Double b = 200.0;
22+
23+
public DoubleWrapper2() { }
24+
}
25+
1926
private final XmlMapper MAPPER = newMapper();
2027

2128
public void testWithDoubleAsNull() throws Exception
@@ -44,6 +51,40 @@ public void testWithDoubleAsNonNull() throws Exception
4451
assertEquals(Double.valueOf(0.25), bean.d);
4552
}
4653

54+
public void testWithDoubleAsMixed() throws Exception
55+
{
56+
DoubleWrapper2 bean = MAPPER.readValue(
57+
"<DoubleWrapper "+XSI_NS_DECL+">\n"
58+
+"<a xsi:nil='true'></a>\n"
59+
+"<b xsi:nil='false'>0.25</b>\n"
60+
+"</DoubleWrapper>",
61+
DoubleWrapper2.class);
62+
assertNotNull(bean);
63+
assertNull(bean.a);
64+
assertEquals(Double.valueOf(0.25), bean.b);
65+
66+
bean = MAPPER.readValue(
67+
"<DoubleWrapper "+XSI_NS_DECL+">\n"
68+
+"<a xsi:nil='false'>0.25</a>\n"
69+
+"<b xsi:nil='true'></b>\n"
70+
+"</DoubleWrapper>",
71+
DoubleWrapper2.class);
72+
assertNotNull(bean);
73+
assertEquals(Double.valueOf(0.25), bean.a);
74+
assertNull(bean.b);
75+
76+
// and last one just for ... funsies
77+
DoubleWrapper2 defaultValue = new DoubleWrapper2();
78+
bean = MAPPER.readValue(
79+
"<DoubleWrapper "+XSI_NS_DECL+">\n"
80+
+"</DoubleWrapper>",
81+
DoubleWrapper2.class);
82+
assertNotNull(bean.a);
83+
assertNotNull(bean.b);
84+
assertEquals(defaultValue.a, bean.a);
85+
assertEquals(defaultValue.b, bean.b);
86+
}
87+
4788
public void testRootPojoAsNull() throws Exception
4889
{
4990
Point bean = MAPPER.readValue(

0 commit comments

Comments
 (0)