001: /******************************************************************
002: * File: TestOWLRules.java
003: * Created by: Dave Reynolds
004: * Created on: 11-Apr-2003
005: *
006: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
007: * [See end of file]
008: * $Id: TestOWLRules.java,v 1.33 2008/01/02 12:08:19 andy_seaborne Exp $
009: *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys.test;
010:
011: import com.hp.hpl.jena.reasoner.ReasonerFactory;
012: import com.hp.hpl.jena.reasoner.rulesys.*;
013: import com.hp.hpl.jena.reasoner.rulesys.impl.oldCode.*;
014:
015: import junit.framework.TestCase;
016: import junit.framework.TestSuite;
017: import java.io.IOException;
018:
019: /**
020: * Test suite to test the production rule version of the OWL reasoner
021: *
022: * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
023: * @version $Revision: 1.33 $ on $Date: 2008/01/02 12:08:19 $
024: */
025: public class TestOWLRules extends TestCase {
026:
027: /** The name of the manifest file to test */
028: protected String manifest;
029:
030: /** Set to true to test the pure forward instead of a hybrid reasoner */
031: protected static boolean testForward = false;
032:
033: /** Set to true to test the experimental hybrid instead of the released one */
034: protected static boolean testExpt = false;
035:
036: /** Flag to control whether tracing and logging enabled */
037: protected static boolean enableTracing = false;
038:
039: /** Flag to control whether to print performance stats as we go */
040: protected static boolean printStats = false;
041:
042: /**
043: * Boilerplate for junit
044: */
045: public TestOWLRules(String manifest) {
046: super (manifest);
047: this .manifest = manifest;
048: }
049:
050: /**
051: * Boilerplate for junit.
052: * This is its own test suite
053: */
054: public static TestSuite suite() {
055: TestSuite suite = new TestSuite();
056:
057: // Basic property and equivalence tests
058: suite.addTest(new TestOWLRules(
059: "SymmetricProperty/Manifest001.rdf"));
060: suite.addTest(new TestOWLRules(
061: "SymmetricProperty/Manifest001.rdf"));
062: suite.addTest(new TestOWLRules(
063: "FunctionalProperty/Manifest001.rdf"));
064: suite.addTest(new TestOWLRules(
065: "FunctionalProperty/Manifest002.rdf"));
066: suite.addTest(new TestOWLRules(
067: "FunctionalProperty/Manifest003.rdf"));
068: suite.addTest(new TestOWLRules(
069: "InverseFunctionalProperty/Manifest001.rdf"));
070: suite.addTest(new TestOWLRules(
071: "InverseFunctionalProperty/Manifest002.rdf"));
072: suite.addTest(new TestOWLRules(
073: "InverseFunctionalProperty/Manifest003.rdf"));
074:
075: suite
076: .addTest(new TestOWLRules(
077: "rdf-charmod-uris/Manifest.rdf"));
078: suite.addTest(new TestOWLRules("I4.6/Manifest003.rdf"));
079: suite.addTest(new TestOWLRules("I5.2/Manifest002.rdf"));
080: suite.addTest(new TestOWLRules("I5.5/Manifest001.rdf"));
081: suite.addTest(new TestOWLRules("I5.5/Manifest002.rdf"));
082: suite.addTest(new TestOWLRules("I5.5/Manifest003.rdf"));
083: suite.addTest(new TestOWLRules("I5.5/Manifest004.rdf"));
084: suite.addTest(new TestOWLRules("inverseOf/Manifest001.rdf"));
085: suite.addTest(new TestOWLRules(
086: "TransitiveProperty/Manifest001.rdf"));
087: suite.addTest(new TestOWLRules(
088: "equivalentClass/Manifest001.rdf")); // bx - long
089: suite.addTest(new TestOWLRules(
090: "equivalentClass/Manifest002.rdf")); // bx - long but terminates
091: suite.addTest(new TestOWLRules(
092: "equivalentClass/Manifest003.rdf")); // bx - long but terminates
093: suite.addTest(new TestOWLRules(
094: "equivalentClass/Manifest005.rdf")); // bx - timeout
095: suite.addTest(new TestOWLRules(
096: "equivalentProperty/Manifest001.rdf")); // bx - long but terminates
097: suite.addTest(new TestOWLRules(
098: "equivalentProperty/Manifest002.rdf")); // bx - long but terminates
099: suite.addTest(new TestOWLRules(
100: "equivalentProperty/Manifest003.rdf"));
101: suite.addTest(new TestOWLRules("I5.1/Manifest001.rdf")); // bx - v. long but terminates
102: suite.addTest(new TestOWLRules("I5.24/Manifest001.rdf"));
103: suite.addTest(new TestOWLRules("I5.24/Manifest002-mod.rdf"));
104: suite.addTest(new TestOWLRules(
105: "equivalentProperty/Manifest006.rdf"));
106: suite
107: .addTest(new TestOWLRules(
108: "intersectionOf/Manifest001.rdf")); // bx - takes a long time
109:
110: // Disjointness tests
111: suite
112: .addTest(new TestOWLRules(
113: "differentFrom/Manifest001.rdf"));
114: suite.addTest(new TestOWLRules("disjointWith/Manifest001.rdf"));
115: suite.addTest(new TestOWLRules("disjointWith/Manifest002.rdf"));
116: suite.addTest(new TestOWLRules("AllDifferent/Manifest001.rdf")); // bx gets lost
117:
118: // Restriction tests
119: suite
120: .addTest(new TestOWLRules(
121: "allValuesFrom/Manifest001.rdf")); // bx - long but terminates
122: suite
123: .addTest(new TestOWLRules(
124: "allValuesFrom/Manifest002.rdf")); // bx - slow
125: suite
126: .addTest(new TestOWLRules(
127: "someValuesFrom/Manifest002.rdf")); // bx - slow
128: suite
129: .addTest(new TestOWLRules(
130: "maxCardinality/Manifest001.rdf"));
131: suite
132: .addTest(new TestOWLRules(
133: "maxCardinality/Manifest002.rdf"));
134: suite.addTest(new TestOWLRules(
135: "FunctionalProperty/Manifest005-mod.rdf"));
136: suite.addTest(new TestOWLRules("I5.24/Manifest004-mod.rdf")); // bx - long
137: suite.addTest(new TestOWLRules(
138: "cardinality/Manifest001-mod.rdf")); // bx gets lost
139: suite.addTest(new TestOWLRules(
140: "cardinality/Manifest002-mod.rdf")); // bx gets lost
141: suite.addTest(new TestOWLRules(
142: "cardinality/Manifest003-mod.rdf")); // bx gets lost
143: suite.addTest(new TestOWLRules(
144: "cardinality/Manifest004-mod.rdf")); // bx gets lost
145: suite.addTest(new TestOWLRules("I5.24/Manifest003-mod.rdf"));
146: suite.addTest(new TestOWLRules(
147: "cardinality/Manifest005-mod.rdf")); // bx gets lost
148: suite.addTest(new TestOWLRules(
149: "cardinality/Manifest006-mod.rdf")); // bx gets lost
150: suite.addTest(new TestOWLRules(
151: "equivalentClass/Manifest004.rdf")); // bx - timeout
152:
153: // Needs prototype creation rule
154: suite
155: .addTest(new TestOWLRules(
156: "someValuesFrom/Manifest001.rdf")); // bx needs creation rule
157:
158: // New local tests
159: suite.addTest(new TestOWLRules("localtests/Manifest001.rdf"));
160: suite.addTest(new TestOWLRules("localtests/Manifest002.rdf"));
161: suite.addTest(new TestOWLRules("localtests/Manifest003.rdf"));
162: suite.addTest(new TestOWLRules("localtests/Manifest004.rdf"));
163: suite.addTest(new TestOWLRules("localtests/Manifest005.rdf"));
164: suite.addTest(new TestOWLRules("localtests/Manifest006.rdf"));
165:
166: // Duplications of tests included earlier
167: // suite.addTest(new TestOWLRules("differentFrom/Manifest002.rdf")); // Duplication of AllDifferent#1
168: // suite.addTest(new TestOWLRules("distinctMembers/Manifest001.rdf")); // Duplication of AllDifferent#1
169:
170: // Consistency tests - not yet implemented by this tester
171: // suite.addTest(new TestOWLRules("I5.3/Manifest005.rdf"));
172: // suite.addTest(new TestOWLRules("I5.3/Manifest006.rdf"));
173: // suite.addTest(new TestOWLRules("I5.3/Manifest007.rdf"));
174: // suite.addTest(new TestOWLRules("I5.3/Manifest008.rdf"));
175: // suite.addTest(new TestOWLRules("I5.3/Manifest009.rdf"));
176: // suite.addTest(new TestOWLRules("Nothing/Manifest001.rdf"));
177: // suite.addTest(new TestOWLRules("miscellaneous/Manifest001.rdf"));
178: // suite.addTest(new TestOWLRules("miscellaneous/Manifest002.rdf"));
179:
180: // Non-feature tests
181: // suite.addTest(new TestOWLRules("I3.2/Manifest001.rdf"));
182: // suite.addTest(new TestOWLRules("I3.2/Manifest002.rdf"));
183: // suite.addTest(new TestOWLRules("I3.2/Manifest003.rdf"));
184: // suite.addTest(new TestOWLRules("I3.4/Manifest001.rdf"));
185: // suite.addTest(new TestOWLRules("I4.1/Manifest001.rdf"));
186:
187: // Outside (f)lite set - hasValue, oneOf, complementOf, unionOf
188: /*
189: suite.addTest(new TestOWLRules("unionOf/Manifest001.rdf"));
190: suite.addTest(new TestOWLRules("unionOf/Manifest002.rdf"));
191: suite.addTest(new TestOWLRules("oneOf/Manifest001.rdf"));
192: suite.addTest(new TestOWLRules("oneOf/Manifest002.rdf"));
193: suite.addTest(new TestOWLRules("oneOf/Manifest003.rdf"));
194: suite.addTest(new TestOWLRules("oneOf/Manifest004.rdf"));
195: suite.addTest(new TestOWLRules("complementOf/Manifest001.rdf"));
196: suite.addTest(new TestOWLRules("FunctionalProperty/Manifest004.rdf"));
197: suite.addTest(new TestOWLRules("InverseFunctionalProperty/Manifest004.rdf"));
198: suite.addTest(new TestOWLRules("equivalentClass/Manifest007.rdf"));
199: suite.addTest(new TestOWLRules("equivalentClass/Manifest006.rdf"));
200: suite.addTest(new TestOWLRules("equivalentProperty/Manifest004.rdf"));
201: suite.addTest(new TestOWLRules("equivalentProperty/Manifest005.rdf"));
202: suite.addTest(new TestOWLRules("Nothing/Manifest002.rdf"));
203: */
204:
205: return suite;
206: }
207:
208: /**
209: * Test the basic functioning of an RDFS reasoner
210: */
211: /*
212: public void testOWLReasoner() throws IOException {
213: OWLWGTester tester = new OWLWGTester(OWLRuleReasonerFactory.theInstance(), this, null);
214: tester.runTests("SymmetricProperty/Manifest001.rdf");
215: }
216: */
217:
218: /**
219: * The test runner
220: */
221: protected void runTest() throws IOException {
222: if (testForward) {
223: OWLWGTester tester = new OWLWGTester(OWLRuleReasonerFactory
224: .theInstance(), this , null);
225: tester.runTests(manifest, enableTracing, printStats);
226: // OWLRuleReasoner.printStats();
227: } else {
228: ReasonerFactory rf = testExpt ? OWLExptRuleReasonerFactory
229: .theInstance() : OWLFBRuleReasonerFactory
230: .theInstance();
231: OWLWGTester tester = new OWLWGTester(rf, this , null);
232: tester.runTests(manifest, enableTracing, printStats);
233: }
234: }
235:
236: /** Dummy test which just delays for 2s */
237: private static class DelayTest extends TestCase {
238: public DelayTest(String name) {
239: super (name);
240: }
241:
242: protected void runTest() throws InterruptedException {
243: Thread.sleep(2000);
244: assertTrue(true);
245: }
246: }
247:
248: /**
249: * Debug purposes only
250: */
251: public static void main(String[] args) {
252: try {
253: String test = "FunctionalProperty/Manifest002.rdf";
254: ReasonerFactory rf = OWLExptRuleReasonerFactory
255: .theInstance();
256: // ReasonerFactory rf = OWLFBRuleReasonerFactory.theInstance();
257: OWLWGTester tester = new OWLWGTester(rf, null, null);
258: System.out.println("Start test ...");
259: tester.runTests(test, false /*tracing*/, true /*stats*/);
260: System.out.println("...end test\n");
261:
262: } catch (Exception e) {
263: // TODO Auto-generated catch block
264: e.printStackTrace();
265: }
266: }
267:
268: }
269:
270: /*
271: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
272: All rights reserved.
273:
274: Redistribution and use in source and binary forms, with or without
275: modification, are permitted provided that the following conditions
276: are met:
277:
278: 1. Redistributions of source code must retain the above copyright
279: notice, this list of conditions and the following disclaimer.
280:
281: 2. Redistributions in binary form must reproduce the above copyright
282: notice, this list of conditions and the following disclaimer in the
283: documentation and/or other materials provided with the distribution.
284:
285: 3. The name of the author may not be used to endorse or promote products
286: derived from this software without specific prior written permission.
287:
288: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
289: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
290: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
291: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
292: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
293: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
294: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
295: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
296: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
297: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
298: */
|