| 1 |
package conformancetests; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
import static org.junit.Assert.*; |
| 9 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Class; |
| 10 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.ClassAssertion; |
| 11 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataProperty; |
| 12 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataPropertyAssertion; |
| 13 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DataSomeValuesFrom; |
| 14 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Datatype; |
| 15 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.DatatypeRestriction; |
| 16 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.EquivalentClasses; |
| 17 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FacetRestriction; |
| 18 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.FunctionalDataProperty; |
| 19 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.IRI; |
| 20 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.Literal; |
| 21 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.NamedIndividual; |
| 22 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.SameIndividual; |
| 23 |
|
| 24 |
import org.junit.Ignore; |
| 25 |
import org.junit.Test; |
| 26 |
import org.semanticweb.owlapi.apibinding.OWLManager; |
| 27 |
import org.semanticweb.owlapi.model.IRI; |
| 28 |
import org.semanticweb.owlapi.model.OWLClass; |
| 29 |
import org.semanticweb.owlapi.model.OWLClassExpression; |
| 30 |
import org.semanticweb.owlapi.model.OWLDataFactory; |
| 31 |
import org.semanticweb.owlapi.model.OWLDataProperty; |
| 32 |
import org.semanticweb.owlapi.model.OWLDataRange; |
| 33 |
import org.semanticweb.owlapi.model.OWLLiteral; |
| 34 |
import org.semanticweb.owlapi.model.OWLNamedIndividual; |
| 35 |
import org.semanticweb.owlapi.model.OWLOntology; |
| 36 |
import org.semanticweb.owlapi.model.OWLOntologyCreationException; |
| 37 |
import org.semanticweb.owlapi.model.OWLOntologyManager; |
| 38 |
import org.semanticweb.owlapi.reasoner.OWLReasoner; |
| 39 |
import org.semanticweb.owlapi.vocab.OWL2Datatype; |
| 40 |
import org.semanticweb.owlapi.vocab.OWLFacet; |
| 41 |
import org.semanticweb.owlapi.vocab.XSDVocabulary; |
| 42 |
|
| 43 |
import testbase.TestBase; |
| 44 |
|
| 45 |
@SuppressWarnings("javadoc") |
| 46 |
public class TestDateTime extends TestBase { |
| 47 |
|
| 48 |
@Test |
| 49 |
public void testEqual() throws OWLOntologyCreationException { |
| 50 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 51 |
OWLOntology o = m.createOntology(); |
| 52 |
OWLDataFactory f = m.getOWLDataFactory(); |
| 53 |
OWLNamedIndividual x = f |
| 54 |
.getOWLNamedIndividual(IRI.create("urn:test:x")); |
| 55 |
OWLNamedIndividual y = f |
| 56 |
.getOWLNamedIndividual(IRI.create("urn:test:y")); |
| 57 |
OWLDataProperty p = f.getOWLDataProperty(IRI.create("urn:test:p")); |
| 58 |
OWLLiteral date = f.getOWLLiteral("2008-07-08T20:44:11.656+01:00", |
| 59 |
OWL2Datatype.XSD_DATE_TIME); |
| 60 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, x, date)); |
| 61 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, y, date)); |
| 62 |
m.addAxiom(o, f.getOWLFunctionalDataPropertyAxiom(p)); |
| 63 |
m.addAxiom(o, f.getOWLSameIndividualAxiom(x, y)); |
| 64 |
OWLReasoner r = factory().createReasoner(o); |
| 65 |
assertTrue( |
| 66 |
"Ontology was supposed to be consistent!\n" |
| 67 |
+ o.getLogicalAxioms(), r.isConsistent()); |
| 68 |
} |
| 69 |
|
| 70 |
@Test |
| 71 |
@Ignore("FaCT++ datatype problems") |
| 72 |
public void testDifferent() throws OWLOntologyCreationException { |
| 73 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 74 |
OWLOntology o = m.createOntology(); |
| 75 |
OWLNamedIndividual x = NamedIndividual(IRI("urn:test:x")); |
| 76 |
OWLNamedIndividual y = NamedIndividual(IRI("urn:test:y")); |
| 77 |
OWLDataProperty p = DataProperty(IRI("urn:test:p")); |
| 78 |
OWLLiteral date1 = Literal("2008-07-08T20:44:11.656+01:00", |
| 79 |
OWL2Datatype.XSD_DATE_TIME); |
| 80 |
OWLLiteral date2 = Literal("2008-07-10T20:44:11.656+01:00", |
| 81 |
OWL2Datatype.XSD_DATE_TIME); |
| 82 |
m.addAxiom(o, DataPropertyAssertion(p, x, date1)); |
| 83 |
m.addAxiom(o, DataPropertyAssertion(p, y, date2)); |
| 84 |
m.addAxiom(o, FunctionalDataProperty(p)); |
| 85 |
m.addAxiom(o, SameIndividual(x, y)); |
| 86 |
OWLReasoner r = factory().createReasoner(o); |
| 87 |
assertFalse( |
| 88 |
"Ontology was supposed to be inconsistent!\n" |
| 89 |
+ o.getLogicalAxioms(), r.isConsistent()); |
| 90 |
} |
| 91 |
|
| 92 |
@Test |
| 93 |
@Ignore("FaCT++ datatype problems") |
| 94 |
public void testBetween() throws OWLOntologyCreationException { |
| 95 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 96 |
OWLOntology o = m.createOntology(); |
| 97 |
OWLNamedIndividual x = NamedIndividual(IRI("urn:test:x")); |
| 98 |
OWLClass c = Class(IRI("urn:test:c")); |
| 99 |
OWLDataProperty p = DataProperty(IRI("urn:test:p")); |
| 100 |
OWLLiteral date1 = Literal("2008-07-08T20:44:11.656+01:00", |
| 101 |
OWL2Datatype.XSD_DATE_TIME); |
| 102 |
OWLLiteral date3 = Literal("2008-07-09T20:44:11.656+01:00", |
| 103 |
OWL2Datatype.XSD_DATE_TIME); |
| 104 |
OWLLiteral date2 = Literal("2008-07-10T20:44:11.656+01:00", |
| 105 |
OWL2Datatype.XSD_DATE_TIME); |
| 106 |
OWLDataRange range = DatatypeRestriction( |
| 107 |
Datatype(OWL2Datatype.XSD_DATE_TIME.getIRI()), |
| 108 |
FacetRestriction(OWLFacet.MIN_INCLUSIVE, date1), |
| 109 |
FacetRestriction(OWLFacet.MAX_INCLUSIVE, date2)); |
| 110 |
OWLClassExpression psome = DataSomeValuesFrom(p, range); |
| 111 |
m.addAxiom(o, EquivalentClasses(c, psome)); |
| 112 |
m.addAxiom(o, DataPropertyAssertion(p, x, date3)); |
| 113 |
m.addAxiom(o, FunctionalDataProperty(p)); |
| 114 |
OWLReasoner r = factory().createReasoner(o); |
| 115 |
assertTrue(r.isConsistent()); |
| 116 |
assertTrue( |
| 117 |
"x was supposed to be an instance of c!\n" |
| 118 |
+ o.getLogicalAxioms(), |
| 119 |
r.isEntailed(ClassAssertion(c, x))); |
| 120 |
} |
| 121 |
|
| 122 |
@Test |
| 123 |
@Ignore("FaCT++ unsipported datatype") |
| 124 |
public void testEqualDate() throws OWLOntologyCreationException { |
| 125 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 126 |
OWLOntology o = m.createOntology(); |
| 127 |
OWLDataFactory f = m.getOWLDataFactory(); |
| 128 |
OWLNamedIndividual x = f |
| 129 |
.getOWLNamedIndividual(IRI.create("urn:test:x")); |
| 130 |
OWLNamedIndividual y = f |
| 131 |
.getOWLNamedIndividual(IRI.create("urn:test:y")); |
| 132 |
OWLDataProperty p = f.getOWLDataProperty(IRI.create("urn:test:p")); |
| 133 |
OWLLiteral date = f.getOWLLiteral("2008-07-08", |
| 134 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 135 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, x, date)); |
| 136 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, y, date)); |
| 137 |
m.addAxiom(o, f.getOWLFunctionalDataPropertyAxiom(p)); |
| 138 |
m.addAxiom(o, f.getOWLSameIndividualAxiom(x, y)); |
| 139 |
OWLReasoner r = factory().createReasoner(o); |
| 140 |
assertTrue( |
| 141 |
"Ontology was supposed to be consistent!\n" |
| 142 |
+ o.getLogicalAxioms(), r.isConsistent()); |
| 143 |
} |
| 144 |
|
| 145 |
@Test |
| 146 |
@Ignore("FaCT++ unsipported datatype") |
| 147 |
public void testDifferentDate() throws OWLOntologyCreationException { |
| 148 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 149 |
OWLOntology o = m.createOntology(); |
| 150 |
OWLDataFactory f = m.getOWLDataFactory(); |
| 151 |
OWLNamedIndividual x = f |
| 152 |
.getOWLNamedIndividual(IRI.create("urn:test:x")); |
| 153 |
OWLNamedIndividual y = f |
| 154 |
.getOWLNamedIndividual(IRI.create("urn:test:y")); |
| 155 |
OWLDataProperty p = f.getOWLDataProperty(IRI.create("urn:test:p")); |
| 156 |
OWLLiteral date1 = f.getOWLLiteral("2008-07-08", |
| 157 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 158 |
OWLLiteral date2 = f.getOWLLiteral("2008-07-10", |
| 159 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 160 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, x, date1)); |
| 161 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, y, date2)); |
| 162 |
m.addAxiom(o, f.getOWLFunctionalDataPropertyAxiom(p)); |
| 163 |
m.addAxiom(o, f.getOWLSameIndividualAxiom(x, y)); |
| 164 |
OWLReasoner r = factory().createReasoner(o); |
| 165 |
assertFalse( |
| 166 |
"Ontology was supposed to be inconsistent!\n" |
| 167 |
+ o.getLogicalAxioms(), r.isConsistent()); |
| 168 |
} |
| 169 |
|
| 170 |
@Test |
| 171 |
@Ignore("FaCT++ unsipported datatype") |
| 172 |
public void testBetweenDate() throws OWLOntologyCreationException { |
| 173 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 174 |
OWLOntology o = m.createOntology(); |
| 175 |
OWLDataFactory f = m.getOWLDataFactory(); |
| 176 |
OWLNamedIndividual x = f |
| 177 |
.getOWLNamedIndividual(IRI.create("urn:test:x")); |
| 178 |
OWLClass c = f.getOWLClass(IRI.create("urn:test:c")); |
| 179 |
OWLDataProperty p = f.getOWLDataProperty(IRI.create("urn:test:p")); |
| 180 |
OWLLiteral date1 = f.getOWLLiteral("2008-07-08", |
| 181 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 182 |
OWLLiteral date3 = f.getOWLLiteral("2008-07-09", |
| 183 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 184 |
OWLLiteral date2 = f.getOWLLiteral("2008-07-10", |
| 185 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 186 |
OWLDataRange range = f.getOWLDatatypeRestriction( |
| 187 |
f.getOWLDatatype(OWL2Datatype.XSD_DATE_TIME.getIRI()), |
| 188 |
f.getOWLFacetRestriction(OWLFacet.MIN_INCLUSIVE, date1), |
| 189 |
f.getOWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, date2)); |
| 190 |
OWLClassExpression psome = f.getOWLDataSomeValuesFrom(p, range); |
| 191 |
m.addAxiom(o, f.getOWLEquivalentClassesAxiom(c, psome)); |
| 192 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, x, date3)); |
| 193 |
m.addAxiom(o, f.getOWLFunctionalDataPropertyAxiom(p)); |
| 194 |
OWLReasoner r = factory().createReasoner(o); |
| 195 |
assertTrue( |
| 196 |
"x was supposed to be an instance of c!\n" |
| 197 |
+ o.getLogicalAxioms(), |
| 198 |
r.isEntailed(f.getOWLClassAssertionAxiom(c, x))); |
| 199 |
} |
| 200 |
} |