Source Code Cross Referenced for OWLUnitTest.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » reasoner » rulesys » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.reasoner.rulesys.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************
002:         * File:        OWLUnitTest.java
003:         * Created by:  Dave Reynolds
004:         * Created on:  19-Mar-2004
005:         * 
006:         * (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP, all rights reserved.
007:         * [See end of file]
008:         * $Id: OWLUnitTest.java,v 1.15 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.rdf.model.ResourceFactory;
012:        import com.hp.hpl.jena.reasoner.*;
013:        import com.hp.hpl.jena.reasoner.rulesys.*;
014:        import com.hp.hpl.jena.reasoner.rulesys.test.OWLWGTester;
015:
016:        import junit.framework.TestCase;
017:        import junit.framework.TestSuite;
018:
019:        import java.io.IOException;
020:
021:        /**
022:         * Version of the OWL unit tests used during development of the mini ruleset.
023:         * 
024:         * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
025:         * @version $Revision: 1.15 $ on $Date: 2008/01/02 12:08:19 $
026:         */
027:        public class OWLUnitTest extends TestCase {
028:
029:            //  --------------  statics defining the whole test suite ---------------------
030:
031:            /** The set of reasoner(factories) to test */
032:            public static ReasonerFactory[] reasonerFactories = {
033:                    OWLFBRuleReasonerFactory.theInstance(),
034:                    OWLMicroReasonerFactory.theInstance(),
035:                    OWLMiniReasonerFactory.theInstance() };
036:
037:            /** The names of the reasoner(factories) to report in the test suite */
038:            public static final String[] reasonerNames = { "full", "Micro",
039:                    "Mini" };
040:
041:            /** bit flag to indicate the test should be passed by the default reasoner */
042:            public static final int FB = 1;
043:
044:            /** bit flag to indicate the test should be passed by the mini reasoner */
045:            public static final int MINI = 2;
046:
047:            /** bit flag to indicate the test should be passed by the micro reasoner */
048:            public static final int MICRO = 4;
049:
050:            // Flags from OWLConsistencyTest, copied here for brevity
051:            public static final int INCONSISTENT = OWLConsistencyTest.INCONSISTENT;
052:            public static final int WARNINGS = OWLConsistencyTest.WARNINGS;
053:            public static final int CLEAN = OWLConsistencyTest.CLEAN;
054:
055:            /** The set of test cases to be used */
056:            public static TestDef[] testDefs = {
057:                    //  /*
058:                    // subClass
059:                    new TestDef("localtests/ManifestSubclass001.rdf", FB
060:                            | MICRO | MINI),
061:
062:                    // equivalentClass
063:                    new TestDef("equivalentClass/Manifest001.rdf", FB | MICRO
064:                            | MINI),
065:                    new TestDef("equivalentClass/Manifest002.rdf", FB | MICRO
066:                            | MINI),
067:                    new TestDef("equivalentClass/Manifest003.rdf", FB | MICRO
068:                            | MINI),
069:                    new TestDef("equivalentClass/Manifest004.rdf", FB | MINI), // Requires prototypes
070:                    new TestDef("equivalentClass/Manifest005.rdf", FB | MICRO
071:                            | MINI),
072:                    new TestDef("localtests/ManifestRestriction001.rdf", FB
073:                            | MICRO | MINI),
074:
075:                    // intersectionOf
076:                    new TestDef("intersectionOf/Manifest001.rdf", FB | MICRO
077:                            | MINI),
078:                    new TestDef("localtests/Manifest001.rdf", FB | MICRO | MINI),
079:                    new TestDef("localtests/Manifest002.rdf", FB | MICRO | MINI),
080:
081:                    // unionOf
082:                    new TestDef("unionOf/Manifest001.rdf", FB | MICRO | MINI),
083:
084:                    // This could be supported but isn't at the moment
085:                    // new TestDef("unionOf/Manifest002.rdf", FB | MICRO | MINI),
086:
087:                    // Property axioms
088:                    new TestDef("SymmetricProperty/Manifest001.rdf", FB | MICRO
089:                            | MINI),
090:                    new TestDef("SymmetricProperty/Manifest001.rdf", FB | MICRO
091:                            | MINI),
092:                    new TestDef("inverseOf/Manifest001.rdf", FB | MICRO | MINI),
093:                    new TestDef("TransitiveProperty/Manifest001.rdf", FB
094:                            | MICRO | MINI),
095:                    new TestDef("localtests/Manifest005.rdf", FB | MICRO | MINI),
096:
097:                    // Equality related
098:                    new TestDef("FunctionalProperty/Manifest001.rdf", FB | MINI),
099:                    new TestDef("FunctionalProperty/Manifest002.rdf", FB | MINI),
100:                    new TestDef("FunctionalProperty/Manifest003.rdf", FB
101:                            | MICRO | MINI),
102:                    new TestDef("InverseFunctionalProperty/Manifest001.rdf", FB
103:                            | MINI),
104:                    new TestDef("InverseFunctionalProperty/Manifest002.rdf", FB
105:                            | MINI),
106:                    new TestDef("InverseFunctionalProperty/Manifest003.rdf", FB
107:                            | MICRO | MINI),
108:                    new TestDef("I5.1/Manifest001.rdf", FB | MINI),
109:
110:                    new TestDef("rdf-charmod-uris/Manifest.rdf", FB | MICRO
111:                            | MINI),
112:                    new TestDef("I4.6/Manifest003.rdf", FB | MICRO | MINI),
113:                    new TestDef("I5.5/Manifest001.rdf", FB | MICRO | MINI),
114:                    new TestDef("I5.5/Manifest002.rdf", FB | MICRO | MINI),
115:                    new TestDef("I5.5/Manifest003.rdf", FB | MICRO | MINI),
116:                    new TestDef("I5.5/Manifest004.rdf", FB | MICRO | MINI),
117:                    new TestDef("inverseOf/Manifest001.rdf", FB | MICRO | MINI),
118:                    new TestDef("TransitiveProperty/Manifest001.rdf", FB
119:                            | MICRO | MINI),
120:                    new TestDef("equivalentProperty/Manifest001.rdf", FB
121:                            | MICRO | MINI),
122:                    new TestDef("equivalentProperty/Manifest002.rdf", FB
123:                            | MICRO | MINI),
124:                    new TestDef("equivalentProperty/Manifest003.rdf", FB
125:                            | MICRO | MINI),
126:                    new TestDef("I5.24/Manifest001.rdf", FB | MICRO | MINI),
127:                    new TestDef("I5.24/Manifest002-mod.rdf", FB | MICRO | MINI),
128:                    new TestDef("equivalentProperty/Manifest006.rdf", FB
129:                            | MICRO | MINI),
130:
131:                    // owl:Nothing
132:                    new TestDef("I5.2/Manifest002.rdf", FB | MINI),
133:
134:                    // Disjointness tests
135:                    new TestDef("differentFrom/Manifest001.rdf", FB | MICRO
136:                            | MINI),
137:                    new TestDef("disjointWith/Manifest001.rdf", FB | MICRO
138:                            | MINI),
139:                    new TestDef("disjointWith/Manifest002.rdf", FB | MICRO
140:                            | MINI),
141:                    new TestDef("AllDifferent/Manifest001.rdf", FB | MICRO
142:                            | MINI),
143:
144:                    // Restriction tests
145:                    new TestDef("allValuesFrom/Manifest001.rdf", FB | MINI), // Want to move this into MICRO
146:                    new TestDef("allValuesFrom/Manifest002.rdf", FB | MICRO
147:                            | MINI),
148:                    new TestDef("someValuesFrom/Manifest002.rdf", FB | MICRO
149:                            | MINI),
150:                    new TestDef("maxCardinality/Manifest001.rdf", FB | MICRO
151:                            | MINI),
152:                    new TestDef("maxCardinality/Manifest002.rdf", FB | MICRO
153:                            | MINI),
154:                    new TestDef("FunctionalProperty/Manifest005-mod.rdf", FB
155:                            | MICRO | MINI),
156:                    new TestDef("I5.24/Manifest004-mod.rdf", FB | MINI),
157:                    new TestDef("cardinality/Manifest001-mod.rdf", FB | MINI),
158:                    new TestDef("cardinality/Manifest002-mod.rdf", FB | MINI),
159:                    new TestDef("cardinality/Manifest003-mod.rdf", FB | MINI),
160:                    new TestDef("cardinality/Manifest004-mod.rdf", FB | MINI),
161:                    new TestDef("I5.24/Manifest003-mod.rdf", FB | MICRO | MINI),
162:                    new TestDef("cardinality/Manifest005-mod.rdf", FB | MINI),
163:                    new TestDef("cardinality/Manifest006-mod.rdf", FB | MINI),
164:
165:                    new TestDef("localtests/ManifestHv1.rdf", FB | MINI | MICRO),
166:                    new TestDef("localtests/ManifestHv2.rdf", FB | MINI | MICRO),
167:
168:                    // Needs bNode creation rule
169:                    new TestDef("someValuesFrom/Manifest001.rdf", FB),
170:
171:                    // New local tests
172:                    new TestDef("localtests/Manifest003.rdf", FB | MICRO | MINI),
173:                    new TestDef("localtests/Manifest004.rdf", FB | MINI), // Requires equality
174:                    new TestDef("localtests/Manifest006.rdf", FB), // a oneOF case
175:
176:                    // Inheritance of domain/range by subProperties, inverseof
177:                    new TestDef("localtests/Manifest007.rdf", FB | MICRO | MINI),
178:                    new TestDef("localtests/Manifest008.rdf", FB | MICRO | MINI),
179:
180:                    // Consistency tests
181:                    // clean case
182:                    new TestDef(new OWLConsistencyTest("tbox.owl",
183:                            "consistentData.rdf", CLEAN, null), FB | MICRO
184:                            | MINI),
185:                    // Instance of disjoint classes
186:                    new TestDef(
187:                            new OWLConsistencyTest(
188:                                    "tbox.owl",
189:                                    "inconsistent1.rdf",
190:                                    INCONSISTENT,
191:                                    ResourceFactory
192:                                            .createResource("http://jena.hpl.hp.com/testing/reasoners/owl#ia")),
193:                            FB | MICRO | MINI),
194:                    // Type violation
195:                    new TestDef(new OWLConsistencyTest("tbox.owl",
196:                            "inconsistent2.rdf", INCONSISTENT, null), FB
197:                            | MICRO | MINI),
198:                    // Count violation
199:                    new TestDef(new OWLConsistencyTest("tbox.owl",
200:                            "inconsistent3.rdf", INCONSISTENT, null), FB | MINI),
201:                    // Distinct values for functional property
202:                    new TestDef(new OWLConsistencyTest("tbox.owl",
203:                            "inconsistent4.rdf", INCONSISTENT, null), FB | MINI),
204:                    // Distinct literal values for functional property
205:                    new TestDef(new OWLConsistencyTest("tbox.owl",
206:                            "inconsistent6.rdf", INCONSISTENT, null), FB | MINI),
207:                    // Type clash - allValuesFrom rdfs:Literal
208:                    new TestDef(new OWLConsistencyTest("tbox.owl",
209:                            "inconsistent5.rdf", INCONSISTENT, null), FB
210:                            | MICRO | MINI),
211:                    // Intersection of disjoint classes                                     
212:                    new TestDef(new OWLConsistencyTest("tbox.owl",
213:                            "emptyClass1.rdf", WARNINGS, null), FB | MICRO
214:                            | MINI),
215:                    // Equivalent to Nothing
216:                    new TestDef(new OWLConsistencyTest("tbox.owl",
217:                            "emptyClass2.rdf", WARNINGS, null), FB | MICRO
218:                            | MINI),
219:                    // disjoint with Thing
220:                    new TestDef(new OWLConsistencyTest("tbox.owl",
221:                            "emptyClass3.rdf", WARNINGS, null), FB | MICRO
222:                            | MINI), };
223:
224:            //  --------------  instance variables for a single test ----------------------    
225:
226:            /** The name of the manifest file to test */
227:            protected String manifest;
228:
229:            /** The reasoner factory under test */
230:            protected ReasonerFactory reasonerFactory;
231:
232:            /**
233:             * Boilerplate for junit
234:             */
235:            public OWLUnitTest(String manifest, String rName, ReasonerFactory rf) {
236:                super (rName + ":" + manifest);
237:                this .manifest = manifest;
238:                this .reasonerFactory = rf;
239:            }
240:
241:            /**
242:             * Boilerplate for junit.
243:             * This is its own test suite
244:             */
245:            public static TestSuite suite() {
246:                TestSuite suite = new TestSuite();
247:                for (int i = 0; i < reasonerFactories.length; i++) {
248:                    String rName = reasonerNames[i];
249:                    ReasonerFactory rf = reasonerFactories[i];
250:                    for (int j = 0; j < testDefs.length; j++) {
251:                        TestDef test = testDefs[j];
252:                        if (test.applicableTo(rf)) {
253:                            if (test.spec instanceof  String) {
254:                                suite.addTest(new OWLUnitTest(
255:                                        (String) test.spec, rName, rf));
256:                            } else if (test.spec instanceof  OWLConsistencyTest) {
257:                                OWLConsistencyTest oct = (OWLConsistencyTest) test.spec;
258:                                suite.addTest(new OWLConsistencyTest(oct,
259:                                        rName, rf));
260:                            }
261:                        }
262:                    }
263:                }
264:                return suite;
265:            }
266:
267:            /**
268:             * The test runner
269:             */
270:            protected void runTest() throws IOException {
271:                //        System.out.println(" - " + manifest + " using " + reasonerFactory.getURI());
272:                OWLWGTester tester = new OWLWGTester(reasonerFactory, this ,
273:                        null);
274:                tester.runTests(manifest, false, false);
275:            }
276:
277:            /**
278:             * Inner class - use to represent a single test case and which reasoners
279:             * it is relevant to.
280:             */
281:            static class TestDef {
282:                /** Test spec, could be a the relative URI for a manifest, or a consistecy test object */
283:                public Object spec;
284:
285:                /** Bitmap of the reasoners this test is relevant to */
286:                public int validFor;
287:
288:                /** Constructor */
289:                public TestDef(Object spec, int validFor) {
290:                    this .spec = spec;
291:                    this .validFor = validFor;
292:                }
293:
294:                /** Return the bitflag corresponding to the given reasoner factory */
295:                public int flagFor(ReasonerFactory rf) {
296:                    if (rf.equals(OWLFBRuleReasonerFactory.theInstance())) {
297:                        return FB;
298:                    } else if (rf.equals(OWLMiniReasonerFactory.theInstance())) {
299:                        return MINI;
300:                    } else if (rf.equals(OWLMicroReasonerFactory.theInstance())) {
301:                        return MICRO;
302:                    } else {
303:                        throw new ReasonerException(
304:                                "Unrecognized OWL reasoner config in unit test");
305:                    }
306:                }
307:
308:                /** Return true if the test is relevant to this reasoner factory */
309:                public boolean applicableTo(ReasonerFactory rf) {
310:                    return (validFor & flagFor(rf)) != 0;
311:                }
312:            }
313:
314:        }
315:
316:        /*
317:         (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
318:         All rights reserved.
319:
320:         Redistribution and use in source and binary forms, with or without
321:         modification, are permitted provided that the following conditions
322:         are met:
323:
324:         1. Redistributions of source code must retain the above copyright
325:         notice, this list of conditions and the following disclaimer.
326:
327:         2. Redistributions in binary form must reproduce the above copyright
328:         notice, this list of conditions and the following disclaimer in the
329:         documentation and/or other materials provided with the distribution.
330:
331:         3. The name of the author may not be used to endorse or promote products
332:         derived from this software without specific prior written permission.
333:
334:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
335:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
336:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
337:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
338:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
339:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
340:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
341:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
342:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
343:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
344:         */
w_w__w___.___jav___a2__s___.___c_o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.