| 1 | package testbase; |
| 2 | |
| 3 | import org.junit.Before; |
| 4 | import org.junit.BeforeClass; |
| 5 | import org.semanticweb.owlapi.apibinding.OWLManager; |
| 6 | import org.semanticweb.owlapi.model.OWLDataFactory; |
| 7 | import org.semanticweb.owlapi.model.OWLOntology; |
| 8 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; |
| 9 | import org.semanticweb.owlapi.model.OWLOntologyManager; |
| 10 | import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; |
| 11 | |
| 12 | import uk.ac.manchester.cs.factplusplus.owlapiv3.FaCTPlusPlusReasonerFactory; |
| 13 | |
| 14 | import uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl; |
| 15 | import uk.ac.manchester.cs.owl.owlapi.concurrent.NoOpReadWriteLock; |
| 16 | |
| 17 | @SuppressWarnings("javadoc") |
| 18 | public class TestBase { |
| 19 | |
| 20 | protected static OWLDataFactory df; |
| 21 | protected static OWLOntologyManager masterManager; |
| 22 | protected OWLOntologyManager m; |
| 23 | |
| 24 | protected OWLOntology asString(OWLOntologyManager man, String resource) throws OWLOntologyCreationException { |
| 25 | return man.loadOntologyFromOntologyDocument(getClass().getResourceAsStream(resource)); |
| 26 | } |
| 27 | |
| 28 | @BeforeClass |
| 29 | public static void setupManagers() { |
| 30 | masterManager = OWLManager.createOWLOntologyManager(); |
| 31 | df = masterManager.getOWLDataFactory(); |
| 32 | } |
| 33 | |
| 34 | @Before |
| 35 | public void setupManagersClean() { |
| 36 | m = setupManager(); |
| 37 | } |
| 38 | |
| 39 | protected static OWLOntologyManager setupManager() { |
| 40 | OWLOntologyManager manager = new OWLOntologyManagerImpl(df, new NoOpReadWriteLock()); |
| 41 | manager.getOntologyFactories().set(masterManager.getOntologyFactories()); |
| 42 | manager.getOntologyParsers().set(masterManager.getOntologyParsers()); |
| 43 | manager.getOntologyStorers().set(masterManager.getOntologyStorers()); |
| 44 | manager.getIRIMappers().set(masterManager.getIRIMappers()); |
| 45 | return manager; |
| 46 | } |
| 47 | |
| 48 | protected static OWLReasonerFactory factory() { |
| 49 | return new FaCTPlusPlusReasonerFactory(); |
| 50 | } |
| 51 | } |