Skip to content
Snippets Groups Projects
Commit 0e983402 authored by Goik Martin's avatar Goik Martin
Browse files

Handling non-wellformed Xml files issuing warnings

parent 8fcc60bd
No related branches found
No related tags found
No related merge requests found
......@@ -2,3 +2,4 @@
/.settings/
.classpath
.project
/A1.log
......@@ -35,18 +35,10 @@ public class InstanceSetEvaluation {
private static Logger log = LogManager.getLogger(InstanceSetEvaluation.class);
final static List<InstanceTest> tests = new Vector<>();
final static StringBuffer warnings = new StringBuffer();
final StringBuffer messages = new StringBuffer(), errorMessages = new StringBuffer();
/**
* @param args unused
*/
public static void main(String[] args) {
final InstanceSetEvaluation ise = new InstanceSetEvaluation("SchemaTest", "Schema/dictionary.xsd");
System.out.println(ise.getMessages());
System.out.println("All tests succeeded:" + ise.allTestsSucceeded);
}
/**
* @return Individual failed test(s) error message(s).
*/
......@@ -58,7 +50,7 @@ public class InstanceSetEvaluation {
* @return Individual test's and aggregated results.
*/
public String getMessages() {
return "\n" + messages.toString();
return "\n" + warnings.toString() + "\n" + messages.toString();
}
/**
......@@ -126,20 +118,15 @@ public class InstanceSetEvaluation {
tests.add(new InstanceTest(xmlTestList.get(0), xmlTestFileDir, xsdSchemaFilename, instanceFilename));
break;
default:
log.error("Fatal: Found " + xmlTestList.size() +
" <?xmltest ... ?> annotations in file '" +
instanceFilename + "'");
System.exit(1);
warnings.append("Found " + xmlTestList.size() + "' annotations in file '" + instanceFilename.getPath() + "'\n");
}
} catch (final JDOMException e) {
log.fatal("Document '" + instanceFilename.getPath() +
log.error("Document '" + instanceFilename.getPath() +
"' is invalid:", e);
System.exit(1);
warnings.append("Unable to parse document " + instanceFilename.getPath() + ": " + e + "\n");
} catch (final IOException e) {
log.fatal("Unable to open '" + instanceFilename.getPath() +
"' for reading:", e);
System.exit(1);
warnings.append("Unable to read document " + instanceFilename.getPath() + ": " + e + "\n");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment