Skip to content

Commit

Permalink
Test the main method of the XsdAggregator
Browse files Browse the repository at this point in the history
  • Loading branch information
rsynek authored and ge0ffrey committed Sep 7, 2020
1 parent efeba7a commit 4aec37d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public static void main(String[] args) {
new XsdAggregator().mergeXmlSchemas(solverXsd, benchmarkXsd, outputXsd);
}

protected static File checkFileExists(File file) {
private static File checkFileExists(File file) {
Objects.requireNonNull(file);
if (!file.exists()) {
throw new IllegalArgumentException(String.format("The file (%s) does not exist.", file.getAbsolutePath()));
}
return file;
}

protected void mergeXmlSchemas(File solverSchemaFile, File benchmarkSchemaFile, File outputSchemaFile) {
private void mergeXmlSchemas(File solverSchemaFile, File benchmarkSchemaFile, File outputSchemaFile) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document solverSchema = parseXml(solverSchemaFile, factory);
Element solverRootElement = solverSchema.getDocumentElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ class XsdAggregatorTest {
@Test
void validateByMergedXsd() throws IOException {
// 1. Use the solver.xsd and the benchmark-with-import.xsd from the classpath.
File solverXsd = XsdAggregator.checkFileExists(getResourceAsFile("/solver.xsd"));
File benchmarkXsd = XsdAggregator.checkFileExists(getResourceAsFile("/benchmark-with-import.xsd"));
File solverXsd = getResourceAsFile("/solver.xsd");
File benchmarkXsd = getResourceAsFile("/benchmark-with-import.xsd");
File mergedBenchmarkXsd = File.createTempFile("benchmark_", ".xsd");
XsdAggregator xsdAggregator = new XsdAggregator();

// 2. Merge them to a single file.
xsdAggregator.mergeXmlSchemas(solverXsd, benchmarkXsd, mergedBenchmarkXsd);
String[] args = new String[] { solverXsd.getAbsolutePath(), benchmarkXsd.getAbsolutePath(),
mergedBenchmarkXsd.getAbsolutePath() };
XsdAggregator.main(args);

// 3. prepare a short benchmarkConfig (including solver config) and validate it
GenericJaxbIO<PlannerBenchmarkConfig> jaxbIO = new GenericJaxbIO<>(PlannerBenchmarkConfig.class);
Expand Down

0 comments on commit 4aec37d

Please sign in to comment.