1 10 package com.hp.hpl.jena.reasoner.rulesys.test; 11 12 import com.hp.hpl.jena.rdf.model.ResourceFactory; 13 import com.hp.hpl.jena.reasoner.*; 14 import com.hp.hpl.jena.reasoner.rulesys.*; 15 import com.hp.hpl.jena.reasoner.rulesys.test.OWLWGTester; 16 17 import junit.framework.TestCase; 18 import junit.framework.TestSuite; 19 20 import java.io.IOException ; 21 22 28 public class OWLUnitTest extends TestCase { 29 30 32 33 public static ReasonerFactory[] reasonerFactories = { 34 OWLFBRuleReasonerFactory.theInstance(), 35 OWLMicroReasonerFactory.theInstance(), 36 OWLMiniReasonerFactory.theInstance() 37 }; 38 39 40 public static final String [] reasonerNames = { "full", "Micro", "Mini" }; 41 42 43 public static final int FB = 1; 44 45 46 public static final int MINI = 2; 47 48 49 public static final int MICRO = 4; 50 51 public static final int INCONSISTENT = OWLConsistencyTest.INCONSISTENT; 53 public static final int WARNINGS = OWLConsistencyTest.WARNINGS; 54 public static final int CLEAN = OWLConsistencyTest.CLEAN; 55 56 57 public static TestDef[] testDefs = { 58 new TestDef("localtests/ManifestSubclass001.rdf", FB | MICRO | MINI), 61 62 new TestDef("equivalentClass/Manifest001.rdf", FB | MICRO | MINI), 64 new TestDef("equivalentClass/Manifest002.rdf", FB | MICRO | MINI), 65 new TestDef("equivalentClass/Manifest003.rdf", FB | MICRO | MINI), 66 new TestDef("equivalentClass/Manifest004.rdf", FB | MINI), new TestDef("equivalentClass/Manifest005.rdf", FB | MICRO | MINI), 68 new TestDef("localtests/ManifestRestriction001.rdf", FB | MICRO | MINI), 69 70 new TestDef("intersectionOf/Manifest001.rdf", FB | MICRO | MINI), 72 new TestDef("localtests/Manifest001.rdf", FB | MICRO | MINI), 73 new TestDef("localtests/Manifest002.rdf", FB | MICRO | MINI), 74 75 new TestDef("unionOf/Manifest001.rdf", FB | MICRO | MINI ), 77 78 81 new TestDef("SymmetricProperty/Manifest001.rdf", FB | MICRO | MINI), 83 new TestDef("SymmetricProperty/Manifest001.rdf", FB | MICRO | MINI), 84 new TestDef("inverseOf/Manifest001.rdf", FB | MICRO | MINI), 85 new TestDef("TransitiveProperty/Manifest001.rdf", FB | MICRO | MINI), 86 new TestDef("localtests/Manifest005.rdf", FB | MICRO | MINI), 87 88 new TestDef("FunctionalProperty/Manifest001.rdf", FB | MINI), 90 new TestDef("FunctionalProperty/Manifest002.rdf", FB | MINI), 91 new TestDef("FunctionalProperty/Manifest003.rdf", FB | MICRO | MINI), 92 new TestDef("InverseFunctionalProperty/Manifest001.rdf", FB | MINI), 93 new TestDef("InverseFunctionalProperty/Manifest002.rdf", FB | MINI), 94 new TestDef("InverseFunctionalProperty/Manifest003.rdf", FB | MICRO | MINI), 95 new TestDef("I5.1/Manifest001.rdf", FB | MINI), 96 97 new TestDef("rdf-charmod-uris/Manifest.rdf", FB | MICRO | MINI), 98 new TestDef("I4.6/Manifest003.rdf", FB | MICRO | MINI), 99 new TestDef("I5.5/Manifest001.rdf", FB | MICRO | MINI), 100 new TestDef("I5.5/Manifest002.rdf", FB | MICRO | MINI), 101 new TestDef("I5.5/Manifest003.rdf", FB | MICRO | MINI), 102 new TestDef("I5.5/Manifest004.rdf", FB | MICRO | MINI), 103 new TestDef("inverseOf/Manifest001.rdf", FB | MICRO | MINI), 104 new TestDef("TransitiveProperty/Manifest001.rdf", FB | MICRO | MINI), 105 new TestDef("equivalentProperty/Manifest001.rdf", FB | MICRO | MINI), 106 new TestDef("equivalentProperty/Manifest002.rdf", FB | MICRO | MINI), 107 new TestDef("equivalentProperty/Manifest003.rdf", FB | MICRO | MINI), 108 new TestDef("I5.24/Manifest001.rdf", FB | MICRO | MINI), 109 new TestDef("I5.24/Manifest002-mod.rdf", FB | MICRO | MINI), 110 new TestDef("equivalentProperty/Manifest006.rdf", FB | MICRO | MINI), 111 112 new TestDef("I5.2/Manifest002.rdf", FB | MINI), 114 115 new TestDef("differentFrom/Manifest001.rdf", FB | MICRO | MINI), 117 new TestDef("disjointWith/Manifest001.rdf", FB | MICRO | MINI), 118 new TestDef("disjointWith/Manifest002.rdf", FB | MICRO | MINI), 119 new TestDef("AllDifferent/Manifest001.rdf", FB | MICRO | MINI), 120 121 new TestDef("allValuesFrom/Manifest001.rdf", FB | MINI), new TestDef("allValuesFrom/Manifest002.rdf", FB | MICRO | MINI), 124 new TestDef("someValuesFrom/Manifest002.rdf", FB | MICRO | MINI), 125 new TestDef("maxCardinality/Manifest001.rdf", FB | MICRO | MINI), 126 new TestDef("maxCardinality/Manifest002.rdf", FB | MICRO | MINI), 127 new TestDef("FunctionalProperty/Manifest005-mod.rdf", FB | MICRO | MINI), 128 new TestDef("I5.24/Manifest004-mod.rdf", FB | MINI), 129 new TestDef("cardinality/Manifest001-mod.rdf", FB | MINI), 130 new TestDef("cardinality/Manifest002-mod.rdf", FB | MINI), 131 new TestDef("cardinality/Manifest003-mod.rdf", FB | MINI), 132 new TestDef("cardinality/Manifest004-mod.rdf", FB | MINI), 133 new TestDef("I5.24/Manifest003-mod.rdf", FB | MICRO | MINI), 134 new TestDef("cardinality/Manifest005-mod.rdf", FB | MINI), 135 new TestDef("cardinality/Manifest006-mod.rdf", FB | MINI), 136 137 new TestDef("someValuesFrom/Manifest001.rdf", FB ), 139 140 new TestDef("localtests/Manifest003.rdf", FB | MICRO | MINI), 142 new TestDef("localtests/Manifest004.rdf", FB | MINI), new TestDef("localtests/Manifest006.rdf", FB ), 145 new TestDef("localtests/Manifest007.rdf", FB | MICRO | MINI), 147 148 new TestDef(new OWLConsistencyTest("tbox.owl", "consistentData.rdf", CLEAN, null), FB | MICRO | MINI), 151 new TestDef(new OWLConsistencyTest("tbox.owl", "inconsistent1.rdf", INCONSISTENT, 153 ResourceFactory.createResource("http://jena.hpl.hp.com/testing/reasoners/owl#ia")), FB | MICRO | MINI), 154 new TestDef(new OWLConsistencyTest("tbox.owl", "inconsistent2.rdf", INCONSISTENT, null), FB | MICRO | MINI), 156 new TestDef(new OWLConsistencyTest("tbox.owl", "inconsistent3.rdf", INCONSISTENT, null), FB | MINI), 158 new TestDef(new OWLConsistencyTest("tbox.owl", "inconsistent4.rdf", INCONSISTENT, null), FB | MINI), 160 new TestDef(new OWLConsistencyTest("tbox.owl", "inconsistent6.rdf", INCONSISTENT, null), FB | MINI), 162 new TestDef(new OWLConsistencyTest("tbox.owl", "inconsistent5.rdf", INCONSISTENT, null), FB | MICRO | MINI), 164 new TestDef(new OWLConsistencyTest("tbox.owl", "emptyClass1.rdf", WARNINGS, null), FB | MICRO | MINI), 166 new TestDef(new OWLConsistencyTest("tbox.owl", "emptyClass2.rdf", WARNINGS, null), FB | MICRO | MINI), 168 new TestDef(new OWLConsistencyTest("tbox.owl", "emptyClass3.rdf", WARNINGS, null), FB | MICRO | MINI), 170 }; 171 172 174 175 protected String manifest; 176 177 178 protected ReasonerFactory reasonerFactory; 179 180 183 public OWLUnitTest( String manifest, String rName, ReasonerFactory rf) { 184 super( rName + ":" + manifest ); 185 this.manifest = manifest; 186 this.reasonerFactory = rf; 187 } 188 189 193 public static TestSuite suite() { 194 TestSuite suite = new TestSuite(); 195 for (int i = 0; i < reasonerFactories.length; i++) { 196 String rName = reasonerNames[i]; 197 ReasonerFactory rf = reasonerFactories[i]; 198 for (int j = 0; j < testDefs.length; j++) { 199 TestDef test = testDefs[j]; 200 if (test.applicableTo(rf)) { 201 if (test.spec instanceof String ) { 202 suite.addTest(new OWLUnitTest((String )test.spec, rName, rf)); 203 } else if (test.spec instanceof OWLConsistencyTest) { 204 OWLConsistencyTest oct = (OWLConsistencyTest)test.spec; 205 suite.addTest(new OWLConsistencyTest(oct, rName, rf)); 206 } 207 } 208 } 209 } 210 return suite; 211 } 212 213 216 protected void runTest() throws IOException { 217 OWLWGTester tester = new OWLWGTester(reasonerFactory, this, null); 219 tester.runTests(manifest, false, false); 220 } 221 222 226 static class TestDef { 227 228 public Object spec; 229 230 231 public int validFor; 232 233 234 public TestDef(Object spec, int validFor) { 235 this.spec = spec; 236 this.validFor = validFor; 237 } 238 239 240 public int flagFor(ReasonerFactory rf) { 241 if (rf.equals(OWLFBRuleReasonerFactory.theInstance())) { 242 return FB; 243 } else if (rf.equals(OWLMiniReasonerFactory.theInstance())) { 244 return MINI; 245 } else if (rf.equals(OWLMicroReasonerFactory.theInstance())) { 246 return MICRO; 247 } else { 248 throw new ReasonerException("Unrecognized OWL reasoner config in unit test"); 249 } 250 } 251 252 253 public boolean applicableTo(ReasonerFactory rf) { 254 return (validFor & flagFor(rf)) != 0; 255 } 256 } 257 258 } 259 260 261 | Popular Tags |