diff --git a/owlapi/pom.xml b/owlapi/pom.xml index c71605999..ebe32e7de 100644 --- a/owlapi/pom.xml +++ b/owlapi/pom.xml @@ -7,7 +7,7 @@ 2.4.0-SNAPSHOT pellet-owlapi - Pellet :: OWL API (ignazio1977 fork) + Pellet :: OWL API ${project.groupId} diff --git a/pom.xml b/pom.xml index fcdbef2f2..b7ec43173 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ pellet-parent 2.4.0-SNAPSHOT pom - Pellet :: Parent POM + Pellet The Clark and Parsia Pellet OWL Reasoner https://github.com/clarkparsia/pellet @@ -42,7 +42,7 @@ 4.11 1.7.5 - [4.0.2,4.2) + 4.2.7 2.13.0 UTF-8 UTF-8 diff --git a/test/src/test/java/com/clarkparsia/modularity/test/PersistenceUpdatesTest.java b/test/src/test/java/com/clarkparsia/modularity/test/PersistenceUpdatesTest.java index b5607beb1..b11ae91d4 100644 --- a/test/src/test/java/com/clarkparsia/modularity/test/PersistenceUpdatesTest.java +++ b/test/src/test/java/com/clarkparsia/modularity/test/PersistenceUpdatesTest.java @@ -108,16 +108,15 @@ public void testPersistenceRemoves(String inputOnt) throws IOException { // at this point there should be a change to the ontology that is not applied yet to the classifier // this should cause the save operation to fail + FileOutputStream fos = new FileOutputStream( testFile ); try { - FileOutputStream fos = new FileOutputStream( testFile ); - IncrementalClassifierPersistence.save( modular, fos ); fail( "The incremental classifer must not allow itself to be persisted if there are any unapplied changes to the ontology" ); - - fos.close(); } catch( IllegalStateException e ) { - assertTrue( testFile.delete() ); // correct behavior + } finally { + fos.close(); + assertTrue( testFile.delete() ); } } finally { @@ -155,17 +154,16 @@ public void testPersistenceAdds(String inputOnt) throws IOException { // at this point there should be a change to the ontology that is not applied yet to the classifier // this should cause the save operation to fail + FileOutputStream fos = new FileOutputStream( testFile ); try { - FileOutputStream fos = new FileOutputStream( testFile ); - IncrementalClassifierPersistence.save( modular, fos ); fail( "The incremental classifer must not allow itself to be persisted if there are any unapplied changes to the ontology" ); - - fos.close(); } catch( IllegalStateException e ) { - assertTrue( testFile.delete() ); // correct behavior - } + } finally { + fos.close(); + assertTrue( testFile.delete() ); + } modular.dispose(); } finally { @@ -208,13 +206,15 @@ public void testAllowedUpdates(String inputOnt) throws IOException { modular.classify(); // at this point, the ontology should be updated (despite the changes), and the save should succeed. + FileOutputStream fos = new FileOutputStream( testFile ); - - IncrementalClassifierPersistence.save( modular, fos ); - - fos.close(); - - assertTrue( testFile.delete() ); + try { + IncrementalClassifierPersistence.save( modular, fos ); + } finally { + fos.close(); + assertTrue( testFile.delete() ); + } + } finally { OWL.manager.removeOntology( ontology ); } @@ -239,18 +239,23 @@ public void testUpdatesAfterPersistence(String inputOnt) throws IOException { IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner( ontology, moduleExtractor ); modular.classify(); - FileOutputStream fos = new FileOutputStream( testFile ); - - IncrementalClassifierPersistence.save( modular, fos ); - - fos.close(); - - - FileInputStream fis = new FileInputStream( testFile ); - - modular = IncrementalClassifierPersistence.load( fis ); - - fis.close(); + try { + FileOutputStream fos = new FileOutputStream( testFile ); + try { + IncrementalClassifierPersistence.save( modular, fos ); + } finally { + fos.close(); + } + + FileInputStream fis = new FileInputStream( testFile ); + try { + modular = IncrementalClassifierPersistence.load( fis ); + } finally { + fis.close(); + } + } finally { + assertTrue( testFile.delete() ); + } // first remove a random axiom List axiomsToRemove = new ArrayList( TestUtils.selectRandomAxioms( ontology, 1 ) ); @@ -286,17 +291,23 @@ public void testUpdatesAfterPersistence2(String inputOnt) throws IOException { IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner( ontology, createModuleExtractor() ); modular.classify(); - FileOutputStream fos = new FileOutputStream( testFile ); - - IncrementalClassifierPersistence.save( modular, fos ); - - fos.close(); - - FileInputStream fis = new FileInputStream( testFile ); - - modular = IncrementalClassifierPersistence.load( fis, ontology ); - - fis.close(); + try { + FileOutputStream fos = new FileOutputStream( testFile ); + try { + IncrementalClassifierPersistence.save( modular, fos ); + } finally { + fos.close(); + } + + FileInputStream fis = new FileInputStream( testFile ); + try { + modular = IncrementalClassifierPersistence.load( fis, ontology ); + } finally { + fis.close(); + } + } finally { + assertTrue( testFile.delete() ); + } // first remove a random axiom List axiomsToRemove = new ArrayList( TestUtils.selectRandomAxioms( ontology, 1 ) ); @@ -323,26 +334,32 @@ public void testUpdatesWhenPersisted(String inputOnt) throws IOException { IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner( ontology, createModuleExtractor() ); modular.classify(); - FileOutputStream fos = new FileOutputStream( testFile ); - - IncrementalClassifierPersistence.save( modular, fos ); - - fos.close(); - - // perform changes while the classifier is stored on disk - // first remove a random axiom - List axiomsToRemove = new ArrayList( TestUtils.selectRandomAxioms( ontology, 1 ) ); - - for( OWLAxiom axiomToRemove : axiomsToRemove ) { - OWL.manager.applyChange( new RemoveAxiom(ontology, axiomToRemove ) ); + try { + FileOutputStream fos = new FileOutputStream( testFile ); + try { + IncrementalClassifierPersistence.save( modular, fos ); + } finally { + fos.close(); + } + + // perform changes while the classifier is stored on disk + // first remove a random axiom + List axiomsToRemove = new ArrayList( TestUtils.selectRandomAxioms( ontology, 1 ) ); + + for( OWLAxiom axiomToRemove : axiomsToRemove ) { + OWL.manager.applyChange( new RemoveAxiom(ontology, axiomToRemove ) ); + } + + FileInputStream fis = new FileInputStream( testFile ); + try { + modular = IncrementalClassifierPersistence.load( fis, ontology ); + } finally { + fis.close(); + } + } finally { + assertTrue( testFile.delete() ); } - FileInputStream fis = new FileInputStream( testFile ); - - modular = IncrementalClassifierPersistence.load( fis, ontology ); - - fis.close(); - PelletReasoner expected = PelletReasonerFactory.getInstance().createReasoner( ontology ); assertClassificationEquals( expected, modular );