1313 */
1414package org .cyclonedx .schema ;
1515
16- import static java .util .Objects .requireNonNull ;
1716import static org .junit .jupiter .api .Assertions .assertFalse ;
1817import static org .junit .jupiter .api .Assertions .assertTrue ;
1918
2928import com .networknt .schema .JsonSchemaFactory ;
3029import com .networknt .schema .NonValidationKeyword ;
3130import com .networknt .schema .SchemaId ;
31+ import com .networknt .schema .SchemaLocation ;
3232import com .networknt .schema .SchemaValidatorsConfig ;
33+ import com .networknt .schema .resource .ClasspathSchemaLoader ;
34+ import com .networknt .schema .resource .DisallowSchemaLoader ;
3335import java .io .IOException ;
3436import java .io .InputStream ;
35- import java .net .URISyntaxException ;
3637import java .util .ArrayList ;
3738import java .util .Collection ;
3839import java .util .List ;
@@ -44,6 +45,9 @@ class JsonSchemaVerificationTest extends BaseSchemaVerificationTest {
4445
4546 private static final ObjectMapper MAPPER = new JsonMapper ();
4647
48+ private static final String JSF_NAMESPACE = "http://cyclonedx.org/schema/jsf-0.82.schema.json" ;
49+ private static final String SPDX_NAMESPACE = "http://cyclonedx.org/schema/spdx.schema.json" ;
50+
4751 private static final JsonSchema VERSION_12 ;
4852 private static final JsonSchema VERSION_13 ;
4953 private static final JsonSchema VERSION_14 ;
@@ -62,22 +66,15 @@ public JsonMetaSchema getMetaSchema(
6266 .defaultMetaSchemaIri (SchemaId .V7 )
6367 .metaSchema (addCustomKeywords (JsonMetaSchema .getV7 ()))
6468 .metaSchemaFactory (metaSchemaFactory )
69+ .schemaLoaders (b -> b .add (new ClasspathSchemaLoader ()).add (DisallowSchemaLoader .getInstance ()))
70+ .schemaMappers (b -> b .mapPrefix (SPDX_NAMESPACE , "classpath:spdx.schema.json" )
71+ .mapPrefix (JSF_NAMESPACE , "classpath:jsf-0.82.schema.json" ))
6572 .build ();
66- ClassLoader cl = JsonSchemaVerificationTest .class .getClassLoader ();
67- try {
68- VERSION_12 = factory .getSchema (
69- requireNonNull (cl .getResource ("bom-1.2-strict.schema.json" )).toURI ());
70- VERSION_13 = factory .getSchema (
71- requireNonNull (cl .getResource ("bom-1.3-strict.schema.json" )).toURI ());
72- VERSION_14 = factory .getSchema (
73- requireNonNull (cl .getResource ("bom-1.4.schema.json" )).toURI ());
74- VERSION_15 = factory .getSchema (
75- requireNonNull (cl .getResource ("bom-1.5.schema.json" )).toURI ());
76- VERSION_16 = factory .getSchema (
77- requireNonNull (cl .getResource ("bom-1.6.schema.json" )).toURI ());
78- } catch (URISyntaxException e ) {
79- throw new IllegalStateException (e );
80- }
73+ VERSION_12 = factory .getSchema (SchemaLocation .of ("classpath:bom-1.2-strict.schema.json" ));
74+ VERSION_13 = factory .getSchema (SchemaLocation .of ("classpath:bom-1.3-strict.schema.json" ));
75+ VERSION_14 = factory .getSchema (SchemaLocation .of ("classpath:bom-1.4.schema.json" ));
76+ VERSION_15 = factory .getSchema (SchemaLocation .of ("classpath:bom-1.5.schema.json" ));
77+ VERSION_16 = factory .getSchema (SchemaLocation .of ("classpath:bom-1.6.schema.json" ));
8178 }
8279
8380 private static JsonMetaSchema addCustomKeywords (JsonMetaSchema metaSchema ) {
0 commit comments