Skip to content

Commit

Permalink
Bit more testing wrt #473
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 4, 2021
1 parent 89c0bc7 commit f7bf98a
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import java.math.BigDecimal;
import java.math.BigInteger;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
Expand Down Expand Up @@ -67,6 +70,27 @@ public void testPrimitiveFPsWithEmpty() throws Exception
assertEquals(0f, p.f);
}

public void testPrimitivesNoNulls() throws Exception
{
ObjectReader r = MAPPER
.readerFor(NumbersPrimitive.class)
.with(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
_testPrimitivesNoNulls(r, _emptyWrapped("i"));
_testPrimitivesNoNulls(r, _emptyWrapped("l"));
_testPrimitivesNoNulls(r, _emptyWrapped("d"));
_testPrimitivesNoNulls(r, _emptyWrapped("f"));
}

private void _testPrimitivesNoNulls(ObjectReader r, String doc) throws Exception
{
try {
r.readValue(_emptyWrapped("i"));
fail("Should not pass");
} catch (MismatchedInputException e) {
verifyException(e, "Cannot coerce empty String");
}
}

/*
/**********************************************************************
/* Test methods, Numbers / wrapper (or Object)
Expand Down

0 comments on commit f7bf98a

Please sign in to comment.