Permalink
Browse files

Fix broken TaxonomyIOTest

It was broken, because a stream was closed before anything could be read from it.

Additionally, the clipse formatter is updated.
  • Loading branch information...
aifargonos committed Jun 22, 2016
1 parent 64aa2a2 commit 92783f4a06bae6bae8e81b83f975d848eca7340e
@@ -65,7 +65,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
@@ -162,6 +162,7 @@ public static void dumpInstanceTaxomomy(
writer.write(
"\n# Hash code: " + getInstanceHashString(taxonomy) + "\n");
}
writer.flush();
}
/**
@@ -88,8 +88,7 @@
@Test
public void classTaxonomyRoundtrip() throws IOException, Owl2ParseException,
ElkInconsistentOntologyException, ElkException {
Taxonomy<ElkClass> original = loadAndClassify("io/taxonomy.owl")
.getInstanceTaxonomy();
Taxonomy<ElkClass> original = loadAndClassify("io/taxonomy.owl");
StringWriter writer = new StringWriter();
TaxonomyPrinter.dumpTaxomomy(original, writer, false);
@@ -119,7 +118,7 @@ public void classTaxonomyRoundtrip() throws IOException, Owl2ParseException,
public void instanceTaxonomyRoundtrip() throws IOException,
Owl2ParseException, ElkInconsistentOntologyException, ElkException {
InstanceTaxonomy<ElkClass, ElkNamedIndividual> original = loadAndClassify(
"io/instance_taxonomy.owl").getInstanceTaxonomy();
"io/instance_taxonomy.owl");
StringWriter writer = new StringWriter();
TaxonomyPrinter.dumpInstanceTaxomomy(original, writer, false);
@@ -130,7 +129,7 @@ public void instanceTaxonomyRoundtrip() throws IOException,
.load(objectFactory, parser);
final StringWriter loadedWriter = new StringWriter();
TaxonomyPrinter.dumpTaxomomy(loaded, loadedWriter, false);
TaxonomyPrinter.dumpInstanceTaxomomy(loaded, loadedWriter, false);
// compare
// @formatter:off
@@ -148,8 +147,8 @@ public void instanceTaxonomyRoundtrip() throws IOException,
@Test
public void objectPropertyTaxonomyRoundtrip() throws IOException,
Owl2ParseException, ElkInconsistentOntologyException, ElkException {
final Taxonomy<ElkObjectProperty> original = loadAndClassify(
"io/property_taxonomy.owl").getObjectPropertyTaxonomy();
final Taxonomy<ElkObjectProperty> original = loadAndClassifyObjectProperties(
"io/property_taxonomy.owl");
final StringWriter writer = new StringWriter();
TaxonomyPrinter.dumpTaxomomy(original, writer, false);
@@ -227,7 +226,28 @@ public void loadInconsistentObjectPropertyTaxonomy() throws IOException,
assertSame(taxonomy.getTopNode(), taxonomy.getBottomNode());
}
private Reasoner loadAndClassify(String resource) throws IOException,
private InstanceTaxonomy<ElkClass,ElkNamedIndividual> loadAndClassify(String resource) throws IOException,
Owl2ParseException, ElkInconsistentOntologyException, ElkException {
InputStream stream = null;
try {
stream = getClass().getClassLoader().getResourceAsStream(resource);
AxiomLoader streamLoader = new Owl2StreamLoader(
new Owl2FunctionalStyleParserFactory(), stream);
Reasoner reasoner = TestReasonerUtils.createTestReasoner(
streamLoader, new FailingOnInterruptStageExecutor(), 1);
return reasoner.getInstanceTaxonomy();
} finally {
if (stream != null) {
IOUtils.closeQuietly(stream);
}
}
}
private Taxonomy<ElkObjectProperty> loadAndClassifyObjectProperties(String resource) throws IOException,
Owl2ParseException, ElkInconsistentOntologyException, ElkException {
InputStream stream = null;
@@ -240,7 +260,7 @@ private Reasoner loadAndClassify(String resource) throws IOException,
Reasoner reasoner = TestReasonerUtils.createTestReasoner(
streamLoader, new FailingOnInterruptStageExecutor(), 1);
return reasoner;
return reasoner.getObjectPropertyTaxonomy();
} finally {
if (stream != null) {
IOUtils.closeQuietly(stream);

0 comments on commit 92783f4

Please sign in to comment.