Skip to content

Commit 780ea0c

Browse files
committed
Merge branch '2.11' into 2.12
2 parents 008fa6f + f7bf98a commit 780ea0c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyWithScalarsTest.java

+24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import java.math.BigDecimal;
44
import java.math.BigInteger;
55

6+
import com.fasterxml.jackson.databind.DeserializationFeature;
7+
import com.fasterxml.jackson.databind.ObjectReader;
8+
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
69
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
710
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
811
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@@ -67,6 +70,27 @@ public void testPrimitiveFPsWithEmpty() throws Exception
6770
assertEquals(0f, p.f);
6871
}
6972

73+
public void testPrimitivesNoNulls() throws Exception
74+
{
75+
ObjectReader r = MAPPER
76+
.readerFor(NumbersPrimitive.class)
77+
.with(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
78+
_testPrimitivesNoNulls(r, _emptyWrapped("i"));
79+
_testPrimitivesNoNulls(r, _emptyWrapped("l"));
80+
_testPrimitivesNoNulls(r, _emptyWrapped("d"));
81+
_testPrimitivesNoNulls(r, _emptyWrapped("f"));
82+
}
83+
84+
private void _testPrimitivesNoNulls(ObjectReader r, String doc) throws Exception
85+
{
86+
try {
87+
r.readValue(_emptyWrapped("i"));
88+
fail("Should not pass");
89+
} catch (MismatchedInputException e) {
90+
verifyException(e, "Cannot coerce empty String");
91+
}
92+
}
93+
7094
/*
7195
/**********************************************************************
7296
/* Test methods, Numbers / wrapper (or Object)

0 commit comments

Comments
 (0)