KickJava   Java API By Example, From Geeks To Geeks.

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


1 /******************************************************************
2  * File: TestOWLRules.java
3  * Created by: Dave Reynolds
4  * Created on: 11-Apr-2003
5  *
6  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
7  * [See end of file]
8  * $Id: TestOWLRules.java,v 1.30 2005/02/21 12:18:12 andy_seaborne Exp $
9  *****************************************************************/

10 package com.hp.hpl.jena.reasoner.rulesys.test;
11
12 import com.hp.hpl.jena.reasoner.ReasonerFactory;
13 import com.hp.hpl.jena.reasoner.rulesys.*;
14 import com.hp.hpl.jena.reasoner.rulesys.impl.oldCode.*;
15
16 import junit.framework.TestCase;
17 import junit.framework.TestSuite;
18 import java.io.IOException JavaDoc;
19
20 /**
21  * Test suite to test the production rule version of the OWL reasoner
22  *
23  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
24  * @version $Revision: 1.30 $ on $Date: 2005/02/21 12:18:12 $
25  */

26 public class TestOWLRules extends TestCase {
27
28     /** The name of the manifest file to test */
29     protected String JavaDoc manifest;
30        
31     /** Set to true to test the pure forward instead of a hybrid reasoner */
32     protected static boolean testForward = false;
33     
34     /** Set to true to test the experimental hybrid instead of the released one */
35     protected static boolean testExpt = false;
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 = false;
42     
43     /**
44      * Boilerplate for junit
45      */

46     public TestOWLRules( String JavaDoc manifest ) {
47         super( manifest );
48         this.manifest = manifest;
49     }
50     
51     /**
52      * Boilerplate for junit.
53      * This is its own test suite
54      */

55     public static TestSuite suite() {
56         TestSuite suite = new TestSuite();
57         
58         // Basic property and equivalence tests
59
suite.addTest(new TestOWLRules("SymmetricProperty/Manifest001.rdf"));
60         suite.addTest(new TestOWLRules("SymmetricProperty/Manifest001.rdf"));
61         suite.addTest(new TestOWLRules("FunctionalProperty/Manifest001.rdf"));
62         suite.addTest(new TestOWLRules("FunctionalProperty/Manifest002.rdf"));
63         suite.addTest(new TestOWLRules("FunctionalProperty/Manifest003.rdf"));
64         suite.addTest(new TestOWLRules("InverseFunctionalProperty/Manifest001.rdf"));
65         suite.addTest(new TestOWLRules("InverseFunctionalProperty/Manifest002.rdf"));
66         suite.addTest(new TestOWLRules("InverseFunctionalProperty/Manifest003.rdf"));
67         
68         suite.addTest(new TestOWLRules("rdf-charmod-uris/Manifest.rdf"));
69         suite.addTest(new TestOWLRules("I4.6/Manifest003.rdf"));
70         suite.addTest(new TestOWLRules("I5.2/Manifest002.rdf"));
71         suite.addTest(new TestOWLRules("I5.5/Manifest001.rdf"));
72         suite.addTest(new TestOWLRules("I5.5/Manifest002.rdf"));
73         suite.addTest(new TestOWLRules("I5.5/Manifest003.rdf"));
74         suite.addTest(new TestOWLRules("I5.5/Manifest004.rdf"));
75         suite.addTest(new TestOWLRules("inverseOf/Manifest001.rdf"));
76         suite.addTest(new TestOWLRules("TransitiveProperty/Manifest001.rdf"));
77         suite.addTest(new TestOWLRules("equivalentClass/Manifest001.rdf")); // bx - long
78
suite.addTest(new TestOWLRules("equivalentClass/Manifest002.rdf")); // bx - long but terminates
79
suite.addTest(new TestOWLRules("equivalentClass/Manifest003.rdf")); // bx - long but terminates
80
suite.addTest(new TestOWLRules("equivalentClass/Manifest005.rdf")); // bx - timeout
81
suite.addTest(new TestOWLRules("equivalentProperty/Manifest001.rdf")); // bx - long but terminates
82
suite.addTest(new TestOWLRules("equivalentProperty/Manifest002.rdf")); // bx - long but terminates
83
suite.addTest(new TestOWLRules("equivalentProperty/Manifest003.rdf"));
84         suite.addTest(new TestOWLRules("I5.1/Manifest001.rdf")); // bx - v. long but terminates
85
suite.addTest(new TestOWLRules("I5.24/Manifest001.rdf"));
86         suite.addTest(new TestOWLRules("I5.24/Manifest002-mod.rdf"));
87         suite.addTest(new TestOWLRules("equivalentProperty/Manifest006.rdf"));
88         suite.addTest(new TestOWLRules("intersectionOf/Manifest001.rdf")); // bx - takes a long time
89

90         // Disjointness tests
91
suite.addTest(new TestOWLRules("differentFrom/Manifest001.rdf"));
92         suite.addTest(new TestOWLRules("disjointWith/Manifest001.rdf"));
93         suite.addTest(new TestOWLRules("disjointWith/Manifest002.rdf"));
94         suite.addTest(new TestOWLRules("AllDifferent/Manifest001.rdf")); // bx gets lost
95

96         // Restriction tests
97
suite.addTest(new TestOWLRules("allValuesFrom/Manifest001.rdf")); // bx - long but terminates
98
suite.addTest(new TestOWLRules("allValuesFrom/Manifest002.rdf")); // bx - slow
99
suite.addTest(new TestOWLRules("someValuesFrom/Manifest002.rdf")); // bx - slow
100
suite.addTest(new TestOWLRules("maxCardinality/Manifest001.rdf"));
101         suite.addTest(new TestOWLRules("maxCardinality/Manifest002.rdf"));
102         suite.addTest(new TestOWLRules("FunctionalProperty/Manifest005-mod.rdf"));
103         suite.addTest(new TestOWLRules("I5.24/Manifest004-mod.rdf")); // bx - long
104
suite.addTest(new TestOWLRules("cardinality/Manifest001-mod.rdf")); // bx gets lost
105
suite.addTest(new TestOWLRules("cardinality/Manifest002-mod.rdf")); // bx gets lost
106
suite.addTest(new TestOWLRules("cardinality/Manifest003-mod.rdf")); // bx gets lost
107
suite.addTest(new TestOWLRules("cardinality/Manifest004-mod.rdf")); // bx gets lost
108
suite.addTest(new TestOWLRules("I5.24/Manifest003-mod.rdf"));
109         suite.addTest(new TestOWLRules("cardinality/Manifest005-mod.rdf")); // bx gets lost
110
suite.addTest(new TestOWLRules("cardinality/Manifest006-mod.rdf")); // bx gets lost
111
suite.addTest(new TestOWLRules("equivalentClass/Manifest004.rdf")); // bx - timeout
112

113         // Needs prototype creation rule
114
suite.addTest(new TestOWLRules("someValuesFrom/Manifest001.rdf")); // bx needs creation rule
115

116         // New local tests
117
suite.addTest(new TestOWLRules("localtests/Manifest001.rdf"));
118         suite.addTest(new TestOWLRules("localtests/Manifest002.rdf"));
119         suite.addTest(new TestOWLRules("localtests/Manifest003.rdf"));
120         suite.addTest(new TestOWLRules("localtests/Manifest004.rdf"));
121         suite.addTest(new TestOWLRules("localtests/Manifest005.rdf"));
122         suite.addTest(new TestOWLRules("localtests/Manifest006.rdf"));
123         
124         // Duplications of tests included earlier
125
// suite.addTest(new TestOWLRules("differentFrom/Manifest002.rdf")); // Duplication of AllDifferent#1
126
// suite.addTest(new TestOWLRules("distinctMembers/Manifest001.rdf")); // Duplication of AllDifferent#1
127

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

138         // Non-feature tests
139
// suite.addTest(new TestOWLRules("I3.2/Manifest001.rdf"));
140
// suite.addTest(new TestOWLRules("I3.2/Manifest002.rdf"));
141
// suite.addTest(new TestOWLRules("I3.2/Manifest003.rdf"));
142
// suite.addTest(new TestOWLRules("I3.4/Manifest001.rdf"));
143
// suite.addTest(new TestOWLRules("I4.1/Manifest001.rdf"));
144

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

162         
163         return suite;
164     }
165
166     /**
167      * Test the basic functioning of an RDFS reasoner
168      */

169     /*
170     public void testOWLReasoner() throws IOException {
171         OWLWGTester tester = new OWLWGTester(OWLRuleReasonerFactory.theInstance(), this, null);
172         tester.runTests("SymmetricProperty/Manifest001.rdf");
173     }
174     */

175     
176     /**
177      * The test runner
178      */

179     protected void runTest() throws IOException JavaDoc {
180         if (testForward) {
181             OWLWGTester tester = new OWLWGTester(OWLRuleReasonerFactory.theInstance(), this, null);
182             tester.runTests(manifest, enableTracing, printStats);
183 // OWLRuleReasoner.printStats();
184
} else {
185             ReasonerFactory rf = testExpt ? OWLExptRuleReasonerFactory.theInstance()
186                                           : OWLFBRuleReasonerFactory.theInstance();
187             OWLWGTester tester = new OWLWGTester(rf, this, null);
188             tester.runTests(manifest, enableTracing, printStats);
189         }
190     }
191
192     /** Dummy test which just delays for 2s */
193     private static class DelayTest extends TestCase {
194         public DelayTest(String JavaDoc name) {
195             super(name);
196         }
197         protected void runTest() throws InterruptedException JavaDoc {
198             Thread.sleep(2000);
199             assertTrue(true);
200         }
201     }
202     
203     /**
204      * Debug purposes only
205      */

206     public static void main(String JavaDoc[] args) {
207         try {
208             String JavaDoc test = "FunctionalProperty/Manifest002.rdf";
209             ReasonerFactory rf = OWLExptRuleReasonerFactory.theInstance();
210 // ReasonerFactory rf = OWLFBRuleReasonerFactory.theInstance();
211
OWLWGTester tester = new OWLWGTester(rf, null, null);
212             System.out.println("Start test ...");
213             tester.runTests(test, false /*tracing*/, true /*stats*/);
214             System.out.println("...end test\n");
215             
216         } catch (Exception JavaDoc e) {
217             // TODO Auto-generated catch block
218
e.printStackTrace();
219         }
220     }
221     
222 }
223
224 /*
225     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
226     All rights reserved.
227
228     Redistribution and use in source and binary forms, with or without
229     modification, are permitted provided that the following conditions
230     are met:
231
232     1. Redistributions of source code must retain the above copyright
233        notice, this list of conditions and the following disclaimer.
234
235     2. Redistributions in binary form must reproduce the above copyright
236        notice, this list of conditions and the following disclaimer in the
237        documentation and/or other materials provided with the distribution.
238
239     3. The name of the author may not be used to endorse or promote products
240        derived from this software without specific prior written permission.
241
242     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
243     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
244     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
245     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
246     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
247     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
248     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
249     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
250     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
251     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
252 */

253
254
Popular Tags