From 97ff99ce468ce9e4bdcc88ea458e8b00eb535f1d Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 16 Mar 2023 17:40:59 +0100 Subject: [PATCH] improved test --- .../org/gcube/grsf/profiles/ProfileTest.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/gcube/grsf/profiles/ProfileTest.java b/src/test/java/org/gcube/grsf/profiles/ProfileTest.java index 3363a83..41ad731 100644 --- a/src/test/java/org/gcube/grsf/profiles/ProfileTest.java +++ b/src/test/java/org/gcube/grsf/profiles/ProfileTest.java @@ -51,19 +51,31 @@ public class ProfileTest { return new File(resourcesDirectory, "profile_schemas"); } - protected File getSchemaFile() throws Exception { + protected File getGRSFSchemaFile() throws Exception { File schemaDirectory = getSchemaDirectory(); return new File(schemaDirectory, "grsf_profile.xsd"); } + protected File getGcatSchemaFile() throws Exception { + File schemaDirectory = getSchemaDirectory(); + return new File(schemaDirectory, "profile5.xsd"); + } + @Test public void validateAgainstXSD() throws Exception { File profilesDirectory = getProfilesDirectory(); - File schemaFile = getSchemaFile(); + File grsfSchemaFile = getGRSFSchemaFile(); + File gcatSchemaFile = getGcatSchemaFile(); + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - Schema schema = factory.newSchema(schemaFile.toURI().toURL()); - Validator validator = schema.newValidator(); + + Schema grsfSchema = factory.newSchema(grsfSchemaFile.toURI().toURL()); + Validator grsfValidator = grsfSchema.newValidator(); + + Schema gcatSchema = factory.newSchema(gcatSchemaFile.toURI().toURL()); + Validator gcatValidator = gcatSchema.newValidator(); + for(File profileFile : profilesDirectory.listFiles()) { @@ -74,7 +86,8 @@ public class ProfileTest { DOMSource xml = new DOMSource(doc); try { - validator.validate(xml); + grsfValidator.validate(xml); + gcatValidator.validate(xml); logger.info("File {} has been successfuly validated against schema.", profileFile.getName()); }catch (Exception e) { logger.error("Error while validating file {}", profileFile.getName());