18
18
import java .io .ByteArrayInputStream ;
19
19
import java .io .ByteArrayOutputStream ;
20
20
import java .io .IOException ;
21
- import java .net .URL ;
22
21
import java .nio .charset .StandardCharsets ;
23
22
import java .util .List ;
24
23
import java .util .Set ;
56
55
57
56
class AspectModelAASGeneratorTest {
58
57
59
- public static final String XML_XSD_AAS_SCHEMA_LOCATION =
60
- "https://raw.githubusercontent.com/aas-core-works/aas-core3.0-testgen/403a0a7cca4a787f642b226bc940ae2d2b319dad/test_data/schema.xsd" ;
61
- // "https://raw.githubusercontent.com/admin-shell-io/aas-specs/v3.0.6/schemas/xml /AAS.xsd";
58
+ // The AAS XML Schema is also present in the AAS4j library for testing purposes. So we can read
59
+ // the file from the classpath
60
+ public static final String XML_XSD_AAS_SCHEMA_LOCATION = " /AAS.xsd" ;
62
61
63
62
AspectModelAASGenerator generator = new AspectModelAASGenerator ();
64
63
@@ -291,7 +290,9 @@ private ByteArrayOutputStream getByteArrayOutputStreamFromAspect( final TestAspe
291
290
private void validate (ByteArrayInputStream xmlStream ) throws IOException , SAXException {
292
291
SchemaFactory factory =
293
292
SchemaFactory .newInstance ( XMLConstants .W3C_XML_SCHEMA_NS_URI );
294
- Schema schema = factory .newSchema (new URL ( XML_XSD_AAS_SCHEMA_LOCATION ) );
293
+
294
+ Schema schema = factory .newSchema (
295
+ new StreamSource (getClass ().getResourceAsStream ( XML_XSD_AAS_SCHEMA_LOCATION ) ) );
295
296
Validator validator = schema .newValidator ();
296
297
validator .validate (new StreamSource ( xmlStream ), null );
297
298
@@ -311,5 +312,4 @@ private Environment loadAASX( final ByteArrayInputStream byteStream ) throws Des
311
312
final XmlDeserializer deserializer = new XmlDeserializer ();
312
313
return deserializer .read ( byteStream );
313
314
}
314
-
315
315
}
0 commit comments