22
33import org .junit .jupiter .api .Test ;
44
5- import com .fasterxml .jackson .core .JUnit5TestBase ;
6- import com .fasterxml .jackson .core .JsonGenerator ;
7- import com .fasterxml .jackson .core .JsonParseException ;
5+ import com .fasterxml .jackson .core .*;
86import com .fasterxml .jackson .core .io .ContentReference ;
97
108import static org .junit .jupiter .api .Assertions .*;
1412 */
1513class JsonReadContextTest extends JUnit5TestBase
1614{
15+ static class MyContext extends JsonReadContext {
16+ public MyContext (JsonReadContext parent , int nestingDepth , DupDetector dups ,
17+ int type , int lineNr , int colNr ) {
18+ super (parent , nestingDepth , dups , type , lineNr , colNr );
19+ }
20+ }
21+
1722 @ Test
1823 void setCurrentNameTwiceWithSameNameRaisesJsonParseException () throws Exception
19- {
24+ {
2025 DupDetector dupDetector = DupDetector .rootDetector ((JsonGenerator ) null );
2126 JsonReadContext jsonReadContext = new JsonReadContext ((JsonReadContext ) null , 0 ,
2227 dupDetector , 2441 , 2441 , 2441 );
@@ -27,21 +32,21 @@ void setCurrentNameTwiceWithSameNameRaisesJsonParseException() throws Exception
2732 } catch (JsonParseException e ) {
2833 verifyException (e , "Duplicate field 'dupField'" );
2934 }
30- }
35+ }
3136
3237 @ Test
3338 void setCurrentName () throws Exception
34- {
39+ {
3540 JsonReadContext jsonReadContext = JsonReadContext .createRootContext (0 , 0 , (DupDetector ) null );
3641 jsonReadContext .setCurrentName ("abc" );
3742 assertEquals ("abc" , jsonReadContext .getCurrentName ());
3843 jsonReadContext .setCurrentName (null );
3944 assertNull (jsonReadContext .getCurrentName ());
40- }
45+ }
4146
4247 @ Test
4348 void reset ()
44- {
49+ {
4550 DupDetector dupDetector = DupDetector .rootDetector ((JsonGenerator ) null );
4651 JsonReadContext jsonReadContext = JsonReadContext .createRootContext (dupDetector );
4752 final ContentReference bogusSrc = ContentReference .unknown ();
@@ -57,6 +62,12 @@ void reset()
5762 assertEquals ("?" , jsonReadContext .typeDesc ());
5863 assertEquals (500 , jsonReadContext .startLocation (bogusSrc ).getLineNr ());
5964 assertEquals (200 , jsonReadContext .startLocation (bogusSrc ).getColumnNr ());
60- }
65+ }
6166
62- }
67+ // [core#1421]
68+ @ Test
69+ void testExtension () {
70+ MyContext context = new MyContext (null , 0 , null , 0 , 0 , 0 );
71+ assertNotNull (context );
72+ }
73+ }
0 commit comments