File tree Expand file tree Collapse file tree 2 files changed +67
-0
lines changed
src/test/java/com/fasterxml/jackson/failing Expand file tree Collapse file tree 2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import org .junit .Assert ;
4
+ import org .junit .Test ;
5
+
6
+ import com .fasterxml .jackson .core .*;
7
+
8
+ // For [core#967]
9
+ public class PerfBigDecimalParser967
10
+ {
11
+ private final JsonFactory JSON_F = new JsonFactory ();
12
+
13
+ // For [core#967]: shouldn't take multiple seconds
14
+ @ Test (timeout = 35000 )
15
+ public void bigDecimalFromString () throws Exception {
16
+ // Jackson's BigDecimalParser seems to be slower than JDK's;
17
+ // won't fail if using latter.
18
+ StringBuilder sb = new StringBuilder (900 );
19
+ for (int i = 0 ; i < 500 ; ++i ) {
20
+ sb .append ('1' );
21
+ }
22
+ sb .append ("1e10000000" );
23
+ final String DOC = sb .toString ();
24
+
25
+ try (JsonParser p = JSON_F .createParser (DOC )) {
26
+ assertToken (JsonToken .VALUE_NUMBER_FLOAT , p .nextToken ());
27
+ Assert .assertNotNull (p .getDecimalValue ());
28
+ }
29
+ }
30
+
31
+ protected void assertToken (JsonToken expToken , JsonToken actToken )
32
+ {
33
+ if (actToken != expToken ) {
34
+ Assert .fail ("Expected token " +expToken +", current token " +actToken );
35
+ }
36
+ }
37
+ }
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import org .junit .Assert ;
4
+ import org .junit .Test ;
5
+
6
+ import com .fasterxml .jackson .core .*;
7
+
8
+ // For [core#968]]
9
+ public class PerfBigDecimalToInteger968
10
+ {
11
+ private final JsonFactory JSON_F = new JsonFactory ();
12
+
13
+ // For [core#968]]: shouldn't take multiple seconds
14
+ @ Test (timeout = 3000 )
15
+ public void bigIntegerViaBigDecimal () throws Exception {
16
+ final String DOC = "1e20000000" ;
17
+
18
+ try (JsonParser p = JSON_F .createParser (DOC )) {
19
+ assertToken (JsonToken .VALUE_NUMBER_FLOAT , p .nextToken ());
20
+ Assert .assertNotNull (p .getBigIntegerValue ());
21
+ }
22
+ }
23
+
24
+ protected void assertToken (JsonToken expToken , JsonToken actToken )
25
+ {
26
+ if (actToken != expToken ) {
27
+ Assert .fail ("Expected token " +expToken +", current token " +actToken );
28
+ }
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments