KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > reasoner > rulesys > test > TestTrialOWLRules


1 /******************************************************************
2  * File: TestTrialOWLRules.java
3  * Created by: Dave Reynolds
4  * Created on: 09-Jul-2003
5  *
6  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
7  * [See end of file]
8  * $Id: TestTrialOWLRules.java,v 1.11 2005/04/11 11:27:04 der Exp $
9  *****************************************************************/

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 JavaDoc;
23 import java.util.*;
24
25 /**
26  * Test suite to test experimental versions of the OWL reasoner, not
27  * included in the master regression test suite.
28  *
29  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
30  * @version $Revision: 1.11 $ on $Date: 2005/04/11 11:27:04 $
31  */

32 public class TestTrialOWLRules extends TestCase {
33
34     /** The name of the manifest file to test */
35     protected String JavaDoc manifest;
36        
37     /** Flag to control whether tracing and logging enabled */
38     protected static boolean enableTracing = false;
39     
40     /** Flag to control whether to print performance stats as we go */
41     protected static boolean printStats = true;
42     
43     /** Configuration spec for the reasoner under test */
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     /**
55      * Boilerplate for junit
56      */

57     public TestTrialOWLRules( String JavaDoc manifest ) {
58         super( manifest );
59         this.manifest = manifest;
60     }
61     
62     /**
63      * Boilerplate for junit.
64      * This is its own test suite
65      */

66     public static TestSuite suite() {
67         TestSuite suite = new TestSuite();
68         
69         // Basic property and equivalence tests
70
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")); // bx - long
85
suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest002.rdf")); // bx - long but terminates
86
suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest003.rdf")); // bx - long but terminates
87
suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest005.rdf")); // bx - timeout
88
suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest001.rdf")); // bx - long but terminates
89
suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest002.rdf")); // bx - long but terminates
90
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")); // bx - v. long but terminates
94
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")); // bx - takes a long time
98

99         // Disjointness tests
100
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")); // bx gets lost
104

105         // Restriction tests
106
suite.addTest(new TestTrialOWLRules("allValuesFrom/Manifest001.rdf")); // bx - long but terminates
107
suite.addTest(new TestTrialOWLRules("allValuesFrom/Manifest002.rdf")); // bx - slow
108
suite.addTest(new TestTrialOWLRules("someValuesFrom/Manifest002.rdf")); // bx - slow
109
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")); // bx - long
113
suite.addTest(new TestTrialOWLRules("localtests/Manifest001.rdf")); // bx - long but terminates
114
suite.addTest(new TestTrialOWLRules("localtests/Manifest002.rdf")); // bx - long but terminates
115
suite.addTest(new TestTrialOWLRules("cardinality/Manifest001-mod.rdf")); // bx gets lost
116
suite.addTest(new TestTrialOWLRules("cardinality/Manifest002-mod.rdf")); // bx gets lost
117
suite.addTest(new TestTrialOWLRules("cardinality/Manifest003-mod.rdf")); // bx gets lost
118
suite.addTest(new TestTrialOWLRules("cardinality/Manifest004-mod.rdf")); // bx gets lost
119
suite.addTest(new TestTrialOWLRules("I5.24/Manifest003-mod.rdf"));
120         suite.addTest(new TestTrialOWLRules("cardinality/Manifest005-mod.rdf")); // bx gets lost
121
suite.addTest(new TestTrialOWLRules("cardinality/Manifest006-mod.rdf")); // bx gets lost
122
suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest004.rdf")); // bx - timeout
123

124         // Needs prototype creation rule
125
// suite.addTest(new TestTrialOWLRules("someValuesFrom/Manifest001.rdf")); // bx needs creation rule
126

127         // Duplications of tests included earlier
128
// suite.addTest(new TestTrialOWLRules("differentFrom/Manifest002.rdf")); // Duplication of AllDifferent#1
129
// suite.addTest(new TestTrialOWLRules("distinctMembers/Manifest001.rdf")); // Duplication of AllDifferent#1
130

131         // Consistency tests - not yet implemented by tester
132
// suite.addTest(new TestTrialOWLRules("I5.3/Manifest005.rdf"));
133
// suite.addTest(new TestTrialOWLRules("I5.3/Manifest006.rdf"));
134
// suite.addTest(new TestTrialOWLRules("I5.3/Manifest007.rdf"));
135
// suite.addTest(new TestTrialOWLRules("I5.3/Manifest008.rdf"));
136
// suite.addTest(new TestTrialOWLRules("I5.3/Manifest009.rdf"));
137
// suite.addTest(new TestTrialOWLRules("Nothing/Manifest001.rdf"));
138
// suite.addTest(new TestTrialOWLRules("miscellaneous/Manifest001.rdf"));
139
// suite.addTest(new TestTrialOWLRules("miscellaneous/Manifest002.rdf"));
140

141         // Non-feature tests
142
// suite.addTest(new TestTrialOWLRules("I3.2/Manifest001.rdf"));
143
// suite.addTest(new TestTrialOWLRules("I3.2/Manifest002.rdf"));
144
// suite.addTest(new TestTrialOWLRules("I3.2/Manifest003.rdf"));
145
// suite.addTest(new TestTrialOWLRules("I3.4/Manifest001.rdf"));
146
// suite.addTest(new TestTrialOWLRules("I4.1/Manifest001.rdf"));
147

148         // Outside (f)lite set - hasValue, oneOf, complementOf, unionOf
149
/*
150         suite.addTest(new TestTrialOWLRules("unionOf/Manifest001.rdf"));
151         suite.addTest(new TestTrialOWLRules("unionOf/Manifest002.rdf"));
152         suite.addTest(new TestTrialOWLRules("oneOf/Manifest001.rdf"));
153         suite.addTest(new TestTrialOWLRules("oneOf/Manifest002.rdf"));
154         suite.addTest(new TestTrialOWLRules("oneOf/Manifest003.rdf"));
155         suite.addTest(new TestTrialOWLRules("oneOf/Manifest004.rdf"));
156         suite.addTest(new TestTrialOWLRules("complementOf/Manifest001.rdf"));
157         suite.addTest(new TestTrialOWLRules("FunctionalProperty/Manifest004.rdf"));
158         suite.addTest(new TestTrialOWLRules("InverseFunctionalProperty/Manifest004.rdf"));
159         suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest007.rdf"));
160         suite.addTest(new TestTrialOWLRules("equivalentClass/Manifest006.rdf"));
161         suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest004.rdf"));
162         suite.addTest(new TestTrialOWLRules("equivalentProperty/Manifest005.rdf"));
163         suite.addTest(new TestTrialOWLRules("Nothing/Manifest002.rdf"));
164         */

165         
166         return suite;
167     }
168    
169     /**
170      * The test runner
171      */

172     protected void runTest() throws IOException JavaDoc {
173         OWLWGTester tester = new OWLWGTester(GenericRuleReasonerFactory.theInstance(), this, configuration);
174 // OWLWGTester tester = new OWLWGTester(OWLExptRuleReasonerFactory.theInstance(), this, null);
175
tester.runTests(manifest, enableTracing, printStats);
176     }
177
178     /**
179      * Boiler plate code for loading up and exploring a specific test case
180      * for use during debugging.
181      */

182     public static void main(String JavaDoc[] 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 // System.out.println("Things of type r are: ");
203
// for (Iterator it = conclusions.listStatements(null, RDF.type, r); it.hasNext(); ) {
204
// System.out.println(" - " + it.next());
205
// }
206
// System.out.println("Types of i are: ");
207
// for (Iterator it = conclusions.listStatements(i, RDF.type, (RDFNode)null); it.hasNext(); ) {
208
// System.out.println(" - " + it.next());
209
// }
210
// System.out.println("Things of type r are: ");
211
// for (Iterator it = conclusions.listStatements(null, RDF.type, r); it.hasNext(); ) {
212
// System.out.println(" - " + it.next());
213
// }
214

215     }
216 }
217
218
219 /*
220     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
221     All rights reserved.
222
223     Redistribution and use in source and binary forms, with or without
224     modification, are permitted provided that the following conditions
225     are met:
226
227     1. Redistributions of source code must retain the above copyright
228        notice, this list of conditions and the following disclaimer.
229
230     2. Redistributions in binary form must reproduce the above copyright
231        notice, this list of conditions and the following disclaimer in the
232        documentation and/or other materials provided with the distribution.
233
234     3. The name of the author may not be used to endorse or promote products
235        derived from this software without specific prior written permission.
236
237     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
238     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
239     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
240     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
241     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
242     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
243     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
245     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
246     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
247 */
Popular Tags