1 10 package com.hp.hpl.jena.reasoner.rulesys.test; 11 12 import com.hp.hpl.jena.rdf.model.*; 13 import com.hp.hpl.jena.reasoner.*; 14 import com.hp.hpl.jena.reasoner.rulesys.*; 15 import com.hp.hpl.jena.util.FileManager; 16 import com.hp.hpl.jena.vocabulary.RDF; 17 import com.hp.hpl.jena.vocabulary.ReasonerVocabulary; 18 19 import junit.framework.TestCase; 20 import junit.framework.TestSuite; 21 22 import java.io.IOException ; 23 import java.util.*; 24 25 32 public class TestTrialOWLRules extends TestCase { 33 34 35 protected String manifest; 36 37 38 protected static boolean enableTracing = false; 39 40 41 protected static boolean printStats = true; 42 43 44 protected static Resource configuration; 45 46 static { 47 Model m = ModelFactory.createDefaultModel(); 48 configuration = m.createResource(GenericRuleReasonerFactory.URI); 49 configuration.addProperty(ReasonerVocabulary.PROPruleMode, "hybrid"); 50 configuration.addProperty(ReasonerVocabulary.PROPruleSet, "etc/owl-fb-test.rules"); 51 configuration.addProperty(ReasonerVocabulary.PROPenableOWLTranslation, true); 52 } 53 54 57 public TestTrialOWLRules( String manifest ) { 58 super( manifest ); 59 this.manifest = manifest; 60 } 61 62 66 public static TestSuite suite() { 67 TestSuite suite = new TestSuite(); 68 69 suite.addTest(new TestTrialOWLRules("SymmetricProperty/Manifest001.rdf")); 71 suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest001.rdf")); 72 suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest002.rdf")); 73 suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest003.rdf")); 74 suite.addTest(new TestTrialOWLRules("InverseFunctionalProperty/Manifest001.rdf")); 75 suite.addTest(new TestTrialOWLRules("InverseFunctionalProperty/Manifest002.rdf")); 76 suite.addTest(new TestTrialOWLRules("InverseFunctionalProperty/Manifest003.rdf")); 77 suite.addTest(new TestTrialOWLRules("rdf-charmod-uris/Manifest.rdf")); 78 suite.addTest(new TestTrialOWLRules("I5.5/Manifest001.rdf")); 79 suite.addTest(new TestTrialOWLRules("I5.5/Manifest002.rdf")); 80 suite.addTest(new TestTrialOWLRules("I5.5/Manifest003.rdf")); 81 suite.addTest(new TestTrialOWLRules("I5.5/Manifest004.rdf")); 82 suite.addTest(new TestTrialOWLRules("inverseOf/Manifest001.rdf")); 83 suite.addTest(new TestTrialOWLRules("TransitiveProperty/Manifest001.rdf")); 84 suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest001.rdf")); suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest002.rdf")); suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest003.rdf")); suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest005.rdf")); suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest001.rdf")); suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest002.rdf")); suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest003.rdf")); 91 suite.addTest(new TestTrialOWLRules("I4.6/Manifest001.rdf")); 92 suite.addTest(new TestTrialOWLRules("I4.6/Manifest002.rdf")); 93 suite.addTest(new TestTrialOWLRules("I5.1/Manifest001.rdf")); suite.addTest(new TestTrialOWLRules("I5.24/Manifest001.rdf")); 95 suite.addTest(new TestTrialOWLRules("I5.24/Manifest002-mod.rdf")); 96 suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest006.rdf")); 97 suite.addTest(new TestTrialOWLRules("intersectionOf/Manifest001.rdf")); 99 suite.addTest(new TestTrialOWLRules("differentFrom/Manifest001.rdf")); 101 suite.addTest(new TestTrialOWLRules("disjointWith/Manifest001.rdf")); 102 suite.addTest(new TestTrialOWLRules("disjointWith/Manifest002.rdf")); 103 suite.addTest(new TestTrialOWLRules("AllDifferent/Manifest001.rdf")); 105 suite.addTest(new TestTrialOWLRules("allValuesFrom/Manifest001.rdf")); suite.addTest(new TestTrialOWLRules("allValuesFrom/Manifest002.rdf")); suite.addTest(new TestTrialOWLRules("someValuesFrom/Manifest002.rdf")); suite.addTest(new TestTrialOWLRules("maxCardinality/Manifest001.rdf")); 110 suite.addTest(new TestTrialOWLRules("maxCardinality/Manifest002.rdf")); 111 suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest005-mod.rdf")); 112 suite.addTest(new TestTrialOWLRules("I5.24/Manifest004-mod.rdf")); suite.addTest(new TestTrialOWLRules("localtests/Manifest001.rdf")); suite.addTest(new TestTrialOWLRules("localtests/Manifest002.rdf")); suite.addTest(new TestTrialOWLRules("cardinality/Manifest001-mod.rdf")); suite.addTest(new TestTrialOWLRules("cardinality/Manifest002-mod.rdf")); suite.addTest(new TestTrialOWLRules("cardinality/Manifest003-mod.rdf")); suite.addTest(new TestTrialOWLRules("cardinality/Manifest004-mod.rdf")); suite.addTest(new TestTrialOWLRules("I5.24/Manifest003-mod.rdf")); 120 suite.addTest(new TestTrialOWLRules("cardinality/Manifest005-mod.rdf")); suite.addTest(new TestTrialOWLRules("cardinality/Manifest006-mod.rdf")); suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest004.rdf")); 124 127 131 141 148 165 166 return suite; 167 } 168 169 172 protected void runTest() throws IOException { 173 OWLWGTester tester = new OWLWGTester(GenericRuleReasonerFactory.theInstance(), this, configuration); 174 tester.runTests(manifest, enableTracing, printStats); 176 } 177 178 182 public static void main(String [] args) { 183 Model premises = FileManager.get().loadModel("file:testing/wg/someValuesFrom/premises001.rdf"); 184 Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(configuration); 185 InfModel conclusions = ModelFactory.createInfModel(reasoner, premises); 186 187 System.out.println("Premises = "); 188 for (Iterator i = premises.listStatements(); i.hasNext(); ) { 189 System.out.println(" - " + i.next()); 190 } 191 192 Resource i = conclusions.getResource("http://www.w3.org/2002/03owlt/someValuesFrom/premises001#i"); 193 Property p = conclusions.getProperty("http://www.w3.org/2002/03owlt/someValuesFrom/premises001#p"); 194 Resource c = conclusions.getResource("http://www.w3.org/2002/03owlt/someValuesFrom/premises001#c"); 195 Resource r = conclusions.getResource("http://www.w3.org/2002/03owlt/someValuesFrom/premises001#r"); 196 Resource v = (Resource)i.getRequiredProperty(p).getObject(); 197 System.out.println("Value of i.p = " + v); 198 System.out.println("Types of v are: "); 199 for (Iterator it2 = conclusions.listStatements(v, RDF.type, (RDFNode)null); it2.hasNext(); ) { 200 System.out.println(" - " + it2.next()); 201 } 202 215 } 216 } 217 218 219 | Popular Tags |