1
1
package com .fasterxml .jackson .databind .deser ;
2
2
3
+ import java .math .BigDecimal ;
4
+ import java .math .BigInteger ;
5
+
3
6
import com .fasterxml .jackson .core .JsonFactory ;
4
7
import com .fasterxml .jackson .core .StreamReadConstraints ;
8
+ import com .fasterxml .jackson .core .exc .StreamReadException ;
9
+
5
10
import com .fasterxml .jackson .databind .BaseMapTest ;
6
- import com .fasterxml .jackson .databind .JsonMappingException ;
7
11
import com .fasterxml .jackson .databind .ObjectMapper ;
8
12
import com .fasterxml .jackson .databind .json .JsonMapper ;
9
13
10
- import java .math .BigDecimal ;
11
- import java .math .BigInteger ;
12
-
13
14
public class TestBigNumbers extends BaseMapTest
14
15
{
15
16
static class BigDecimalWrapper {
@@ -59,10 +60,9 @@ public void testDouble() throws Exception
59
60
{
60
61
try {
61
62
MAPPER .readValue (generateJson ("d" ), DoubleWrapper .class );
62
- fail ("expected JsonMappingException" );
63
- } catch (JsonMappingException jsonMappingException ) {
64
- assertTrue ("unexpected exception message: " + jsonMappingException .getMessage (),
65
- jsonMappingException .getMessage ().startsWith ("Malformed numeric value ([number with 1200 characters])" ));
63
+ fail ("expected StreamReadException" );
64
+ } catch (StreamReadException e ) {
65
+ verifyException (e , "Invalid numeric value " , "exceeds the maximum length" );
66
66
}
67
67
}
68
68
@@ -77,10 +77,9 @@ public void testBigDecimal() throws Exception
77
77
{
78
78
try {
79
79
MAPPER .readValue (generateJson ("number" ), BigDecimalWrapper .class );
80
- fail ("expected JsonMappingException" );
81
- } catch (JsonMappingException jsonMappingException ) {
82
- assertTrue ("unexpected exception message: " + jsonMappingException .getMessage (),
83
- jsonMappingException .getMessage ().startsWith ("Malformed numeric value ([number with 1200 characters])" ));
80
+ fail ("expected StreamReadException" );
81
+ } catch (StreamReadException e ) {
82
+ verifyException (e , "Invalid numeric value " , "exceeds the maximum length" );
84
83
}
85
84
}
86
85
@@ -96,10 +95,9 @@ public void testBigInteger() throws Exception
96
95
{
97
96
try {
98
97
MAPPER .readValue (generateJson ("number" ), BigIntegerWrapper .class );
99
- fail ("expected JsonMappingException" );
100
- } catch (JsonMappingException jsonMappingException ) {
101
- assertTrue ("unexpected exception message: " + jsonMappingException .getMessage (),
102
- jsonMappingException .getMessage ().startsWith ("Malformed numeric value ([number with 1200 characters])" ));
98
+ fail ("expected StreamReadException" );
99
+ } catch (StreamReadException e ) {
100
+ verifyException (e , "Invalid numeric value " , "exceeds the maximum length" );
103
101
}
104
102
}
105
103
0 commit comments