improved test
This commit is contained in:
parent
39e3112016
commit
97ff99ce46
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue