@@ -32,7 +32,7 @@ public class JsonPointerEvaluatorTest {
32
32
private static final ResourceLoader LOADER = ResourceLoader .DEFAULT ;
33
33
34
34
@ Test
35
- public void sameDocumentSuccess () {
35
+ void sameDocumentSuccess () {
36
36
JsonPointerEvaluator pointer = JsonPointerEvaluator .forDocument (rootSchemaJson , "#/definitions/Bar" );
37
37
JsonObject actual = pointer .query ().getQueryResult ().requireObject ();
38
38
assertEquals ("dummy schema at #/definitions/Bar" , actual .require ("description" ).requireString ());
@@ -41,7 +41,7 @@ public void sameDocumentSuccess() {
41
41
}
42
42
43
43
@ Test
44
- public void sameDocumentNotFound () {
44
+ void sameDocumentNotFound () {
45
45
Assertions .assertThrows (SchemaException .class , () -> {
46
46
JsonPointerEvaluator pointer = JsonPointerEvaluator .forDocument (rootSchemaJson , "#/definitions/NotFound" );
47
47
JsonObject actual = pointer .query ().getQueryResult ().requireObject ();
@@ -52,21 +52,21 @@ public void sameDocumentNotFound() {
52
52
}
53
53
54
54
@ Test
55
- public void arrayIndexSuccess () {
55
+ void arrayIndexSuccess () {
56
56
JsonPointerEvaluator pointer = JsonPointerEvaluator .forDocument (rootSchemaJson , "#/definitions/Array/0" );
57
57
JsonObject actual = pointer .query ().getQueryResult ().requireObject ();
58
58
assertEquals ("dummy schema in array" , actual .require ("description" ).requireString ());
59
59
}
60
60
61
61
@ Test
62
- public void rootRefSuccess () {
62
+ void rootRefSuccess () {
63
63
JsonPointerEvaluator pointer = JsonPointerEvaluator .forDocument (rootSchemaJson , "#" );
64
64
JsonObject actual = pointer .query ().getQueryResult ().requireObject ();
65
65
assertSame (rootSchemaJson , actual );
66
66
}
67
67
68
68
@ Test
69
- public void escaping () {
69
+ void escaping () {
70
70
JsonPointerEvaluator pointer = JsonPointerEvaluator .forDocument (rootSchemaJson , "#/definitions/Escaping/sla~1sh/ti~0lde" );
71
71
JsonObject actual = pointer .query ().getQueryResult ().requireObject ();
72
72
assertEquals ("tiled" , actual .require ("description" ).requireString ());
@@ -82,7 +82,7 @@ private LoadingState createLoadingState(SchemaClient schemaClient, String ref) {
82
82
}
83
83
84
84
@ Test
85
- public void remoteDocumentSuccess () throws URISyntaxException {
85
+ void remoteDocumentSuccess () throws URISyntaxException {
86
86
SchemaClient schemaClient = mock (SchemaClient .class );
87
87
when (schemaClient .get ("http://localhost:1234/hello" )).thenReturn (rootSchemaJsonAsStream ());
88
88
JsonPointerEvaluator pointer = JsonPointerEvaluator
@@ -94,9 +94,21 @@ public void remoteDocumentSuccess() throws URISyntaxException {
94
94
assertEquals (new SchemaLocation (new URI ("http://localhost:1234/hello" ), asList ("definitions" , "Bar" )),
95
95
actual .ls .pointerToCurrentObj );
96
96
}
97
+
98
+ @ Test
99
+ void remoteDocument_jsonParsingFailure () {
100
+ SchemaClient schemaClient = mock (SchemaClient .class );
101
+ when (schemaClient .get ("http://localhost:1234/hello" )).thenReturn (asStream ("unparseable" ));
102
+ try {
103
+ JsonPointerEvaluator .forURL (schemaClient , "http://localhost:1234/hello#/foo" , createLoadingState (schemaClient , "" )).query ();
104
+ fail ("did not throw exception for unparseable json" );
105
+ } catch (SchemaException e ) {
106
+ assertEquals ("http://localhost:1234/hello" , e .getSchemaLocation ());
107
+ }
108
+ }
97
109
98
110
@ Test
99
- public void schemaExceptionForInvalidURI () {
111
+ void schemaExceptionForInvalidURI () {
100
112
try {
101
113
SchemaClient schemaClient = mock (SchemaClient .class );
102
114
JsonPointerEvaluator subject = JsonPointerEvaluator .forURL (schemaClient , "||||" ,
0 commit comments