@SuppressWarnings("javadoc") public class BadDataPropertyRT extends TestCase { private static final OWLDataFactory factory = Factory.getFactory(); public static final String NS = "http://test.org/DataPropertyRestriction.owl"; public static final OWLDataProperty P = factory.getOWLDataProperty(IRI.create(NS + "#p")); public static final OWLClass A = factory.getOWLClass(IRI.create(NS + "#A")); @Test public void testBadDataproperty() throws Exception { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology ontology = manager.createOntology(IRI.create(NS)); OWLClassExpression restriction = factory.getOWLDataSomeValuesFrom( P, factory.getOWLDatatype(XSDVocabulary.DURATION.getIRI())); OWLAxiom axiom = factory.getOWLSubClassOfAxiom(A, restriction); manager.addAxiom(ontology, axiom); assertTrue(ontology.containsDataPropertyInSignature(P.getIRI())); StringDocumentTarget t = new StringDocumentTarget(); manager.saveOntology(ontology, new RDFXMLOntologyFormat(), t); manager.removeOntology(ontology); ontology = manager.loadOntologyFromOntologyDocument(new StringDocumentSource(t.toString())); assertTrue(ontology.containsDataPropertyInSignature(P.getIRI())); } }
@Override protected Set<? extends OWLAxiom> createAxioms() { OWLAnnotationProperty subProp = AnnotationProperty(IRI("http://ont.com#myLabel")); OWLAnnotationProperty superProp = RDFSLabel(); OWLAxiom ax = Factory.getFactory().getOWLSubAnnotationPropertyOfAxiom(subProp, superProp); return Collections.singleton(ax); }
@Test public void testMinusInf() throws Exception { String input = "Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" + "Prefix(owl:=<http://www.w3.org/2002/07/owl#>)\n" + "Prefix(:=<http://test.org/test#>)\n" + "Ontology(\nDeclaration(NamedIndividual(:a))\n" + "Declaration(DataProperty(:dp))\n" + "Declaration(Class(:A))\n" + "SubClassOf(:A DataAllValuesFrom(:dp owl:real))" + "\nSubClassOf(:A \n" + "DataSomeValuesFrom(:dp DataOneOf(\"-INF\"^^xsd:float \"-0\"^^xsd:integer))" + "\n)" + "\n" + "ClassAssertion(:A :a)" + "\n)"; StringDocumentSource in = new StringDocumentSource(input); OWLOntologyManager m = Factory.getManager(); OWLOntology o = m.loadOntologyFromOntologyDocument(in); StringDocumentTarget t = new StringDocumentTarget(); m.saveOntology(o, t); assertTrue(t.toString() + " should contain -INF", t.toString().contains("-INF")); OWLOntology o1 = m.loadOntologyFromOntologyDocument(new StringDocumentSource(t.toString())); assertEquals( "Obtologies were supposed to be the same", o.getLogicalAxioms(), o1.getLogicalAxioms()); }
@Test(expected = OWLOntologyAlreadyExistsException.class) public void testCreateDuplicateOntologyWithIRI() throws Exception { OWLOntologyManager manager = Factory.getManager(); IRI ontologyIRI = IRI("http://www.semanticweb.org/ontologies/ontology"); manager.createOntology(ontologyIRI); manager.createOntology(ontologyIRI); }
@Test public void testCreateAnonymousOntology() throws Exception { OWLOntologyManager manager = Factory.getManager(); OWLOntology ontology = manager.createOntology(); assertNotNull("ontology should not be null", ontology); assertNotNull("ontology id should not be null", ontology.getOntologyID()); assertNull(ontology.getOntologyID().getDefaultDocumentIRI()); assertNull(ontology.getOntologyID().getOntologyIRI()); assertNull(ontology.getOntologyID().getVersionIRI()); assertNotNull("iri should not be null", manager.getOntologyDocumentIRI(ontology)); }
@Test(expected = OWLOntologyDocumentAlreadyExistsException.class) public void testCreateDuplicatedDocumentIRI() throws Exception { OWLOntologyManager manager = Factory.getManager(); IRI ontologyIRI = IRI("http://www.semanticweb.org/ontologies/ontology"); IRI ontologyIRI2 = IRI("http://www.semanticweb.org/ontologies/ontology2"); IRI documentIRI = IRI("file:documentIRI"); manager.addIRIMapper(new SimpleIRIMapper(ontologyIRI, documentIRI)); manager.addIRIMapper(new SimpleIRIMapper(ontologyIRI2, documentIRI)); manager.createOntology(new OWLOntologyID(ontologyIRI)); manager.createOntology(new OWLOntologyID(ontologyIRI2)); }
@Test public void testCreateOntologyWithIRI() throws Exception { OWLOntologyManager manager = Factory.getManager(); IRI ontologyIRI = IRI("http://www.semanticweb.org/ontologies/ontology"); OWLOntology ontology = manager.createOntology(ontologyIRI); assertNotNull("ontology should not be null", ontology); assertNotNull("ontology id should not be null", ontology.getOntologyID()); assertEquals(ontologyIRI, ontology.getOntologyID().getDefaultDocumentIRI()); assertEquals(ontologyIRI, ontology.getOntologyID().getOntologyIRI()); assertNull(ontology.getOntologyID().getVersionIRI()); assertEquals(ontologyIRI, manager.getOntologyDocumentIRI(ontology)); }
@Test public void testNamedOntologyToString() throws Exception { OWLOntologyManager man = Factory.getManager(); IRI ontIRI = IRI("http://owlapi.sourceforge.net/ont"); OWLOntology ont = man.createOntology(ontIRI); String s = ont.toString(); String expected = "Ontology(" + ont.getOntologyID().toString() + ") [Axioms: " + ont.getAxiomCount() + " Logical Axioms: " + ont.getLogicalAxiomCount() + "]"; assertEquals(expected, s); }
@Test public void testCreateOntologyWithIRIAndVersionIRIWithMapper() throws Exception { OWLOntologyManager manager = Factory.getManager(); IRI ontologyIRI = IRI("http://www.semanticweb.org/ontologies/ontology"); IRI versionIRI = IRI("http://www.semanticweb.org/ontologies/ontology/version"); IRI documentIRI = IRI("file:documentIRI"); SimpleIRIMapper mapper = new SimpleIRIMapper(versionIRI, documentIRI); manager.addIRIMapper(mapper); OWLOntology ontology = manager.createOntology(new OWLOntologyID(ontologyIRI, versionIRI)); assertNotNull("ontology should not be null", ontology); assertNotNull("ontology id should not be null", ontology.getOntologyID()); assertEquals(versionIRI, ontology.getOntologyID().getDefaultDocumentIRI()); assertEquals(ontologyIRI, ontology.getOntologyID().getOntologyIRI()); assertEquals(versionIRI, ontology.getOntologyID().getVersionIRI()); assertEquals(documentIRI, manager.getOntologyDocumentIRI(ontology)); }
@Test public void testBottomDataPropertyPositive() { OWLDataPropertyExpression prop = Factory.getFactory().getOWLBottomDataProperty(); assertTrue(prop.isOWLBottomDataProperty()); }
@Test public void testTopObjectPropertyPositive() { OWLObjectPropertyExpression prop = Factory.getFactory().getOWLTopObjectProperty(); assertTrue(prop.isOWLTopObjectProperty()); }
private OWLClassExpression getNNF(OWLClassExpression classExpression) { NNF nnf = new NNF(Factory.getFactory()); return classExpression.accept(nnf); }