Skip to content
Snippets Groups Projects
Commit 1bd16d73 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- increased readability

parent dbdbec2a
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,7 @@ import static org.junit.Assert.*;
@RunWith(JUnit4.class)
public class TestValidateSchema {
private static XmlFormatValidationPlugin mock;
private XmlFormatValidationPlugin mock;
private final Map<String, String> initp = new HashMap<>();
private URI local2Uri(String sUri) {
......@@ -67,6 +67,8 @@ public class TestValidateSchema {
@org.junit.Test
public void schema_valid() {
System.out.println("-----------------------------------------------------------------------------------");
String testfile = "resources/test/valid/minimod.xml";
ValidationResultHandle resultHandle = new ValidationResultHandle();
ValidationResourceResolver validationResourceResolver = new ValidationResourceResolver(mock.getNamespaceSchemaMap(), resultHandle);
var v = new ValidateSchema(validationResourceResolver, resultHandle);
......@@ -74,19 +76,22 @@ public class TestValidateSchema {
var has_exception = false;
var res = false;
try {
var doc = mock.getDocument("resources/test/valid/minimod.xml");
var doc = mock.getDocument(testfile);
res = v.validateAgainst(doc, local2Uri("example_catalog/mods-3.8/flatten/mods-3-8.xsd"));
} catch ( Exception e) {
e.printStackTrace();
has_exception = true;
}
System.out.println( resultHandle.getLog());
assertFalse("schema validation should not raise an exception", has_exception );
assertTrue("schema validation should return true for sucessful validation", res);
assertFalse("schema validation of " + testfile + " should not raise an exception", has_exception );
assertTrue( "schema validation of " + testfile + " should return true for sucessful validation", res);
}
@org.junit.Test
public void schema_invalid() {
System.out.println("-----------------------------------------------------------------------------------");
String testfile = "resources/test/invalid/minimod.xml";
ValidationResultHandle resultHandle = new ValidationResultHandle();
ValidationResourceResolver validationResourceResolver = new ValidationResourceResolver(mock.getNamespaceSchemaMap(), resultHandle);
var v = new ValidateSchema(validationResourceResolver, resultHandle);
......@@ -94,19 +99,21 @@ public class TestValidateSchema {
var has_exception = false;
var res = false;
try {
var doc = mock.getDocument("resources/test/invalid/minimod.xml");
var doc = mock.getDocument(testfile);
res = v.validateAgainst(doc, local2Uri("example_catalog/mods-3.8/flatten/mods-3-8.xsd"));
} catch ( Exception e) {
System.out.println( "EXCEPTION:" + e.getMessage());
e.printStackTrace();
has_exception = true;
}
assertFalse("schema validation should not raise an exception", has_exception );
assertFalse("schema validation should return false for failed validation", res);
assertFalse("schema validation of " + testfile + " should not raise an exception", has_exception );
assertFalse("schema validation of " + testfile + " should return false for failed validation", res);
}
@org.junit.Test
public void check_import_regression() {
System.out.println("-----------------------------------------------------------------------------------");
String testfile = "resources/test/valid/kml/KML_Samples.kml";
Set<ValidationSchema> nssm = new HashSet<>();
Set<ValidationSchema> old = mock.getNamespaceSchemaMap();
for (ValidationSchema val : old) { // filter Atoim out to trigger error
......@@ -122,14 +129,14 @@ public class TestValidateSchema {
var has_exception = false;
var res = false;
try {
var doc = mock.getDocument("resources/test/valid/kml/KML_Samples.kml");
var doc = mock.getDocument(testfile);
res = v.validateAgainst(doc, local2Uri("example_catalog/kml-2.3.0/ogckml23.xsd"));
} catch ( Exception e) {
System.out.println( "EXCEPTION:" + e.getMessage());
e.printStackTrace();
has_exception = true;
}
assertFalse("schema validation should not raise an exception", has_exception );
assertFalse("schema validation should return false for failed validation", res);
assertFalse("schema validation of " + testfile + " should not raise an exception", has_exception );
assertFalse("schema validation of " + testfile + " should return false for failed validation", res);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment