Source Code Cross Referenced for OWLConsistencyTest.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:        OWLConsistencyTester.java
003:         * Created by:  Dave Reynolds
004:         * Created on:  14-Feb-2005
005:         * 
006:         * (c) Copyright 2005, Hewlett-Packard Development Company, LP
007:         * [See end of file]
008:         * $Id: OWLConsistencyTest.java,v 1.6 2008/01/02 12:08:20 andy_seaborne Exp $
009:         *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys.test;
010:
011:        import java.util.Iterator;
012:
013:        import junit.framework.TestCase;
014:
015:        import com.hp.hpl.jena.rdf.model.InfModel;
016:        import com.hp.hpl.jena.rdf.model.Model;
017:        import com.hp.hpl.jena.rdf.model.ModelFactory;
018:        import com.hp.hpl.jena.reasoner.Reasoner;
019:        import com.hp.hpl.jena.reasoner.ReasonerFactory;
020:        import com.hp.hpl.jena.reasoner.ValidityReport;
021:        import com.hp.hpl.jena.util.FileManager;
022:
023:        /**
024:         * Utility for checking OWL validation results.
025:         * 
026:         * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds </a>
027:         * @version $Revision: 1.6 $
028:         */
029:
030:        public class OWLConsistencyTest extends TestCase {
031:
032:            /** The base directory for finding the datafiles */
033:            public static final String BASE_DIR = "file:testing/reasoners/owl/";
034:
035:            /** The tbox to be tested, relative to BASE_DIR */
036:            protected String tbox;
037:
038:            /** The abox to be tested, relative to BASE_DIR */
039:            protected String abox;
040:
041:            /** The expected result to check against */
042:            protected int expected;
043:
044:            /** The factory for the reasoner to test */
045:            protected ReasonerFactory rf;
046:
047:            /** Flag for expected result = inconsistent */
048:            public static final int INCONSISTENT = 1;
049:
050:            /** Flag for expected result = consistent but at least 1 warning */
051:            public static final int WARNINGS = 2;
052:
053:            /** Flag for expected result = no errors ow warnings */
054:            public static final int CLEAN = 3;
055:
056:            /** Optional culprit object, should validate with equals */
057:            protected Object culprit;
058:
059:            /**
060:             * Constructor - builds a dummy test which can't be run without setting a
061:             * reasoner factory
062:             * 
063:             * @param tbox
064:             *            The tbox to be tested, relative to BASE_DIR
065:             * @param abox
066:             *            The abox to be tested, relative to BASE_DIR
067:             * @param expected
068:             *            The expected result to check against -
069:             *            INCONSISTENT/WARNINGS/CLEAN
070:             * @param culprit
071:             *            Optional culprit object, should validate with equals, set to
072:             *            null for no test
073:             */
074:            public OWLConsistencyTest(String tbox, String abox, int expected,
075:                    Object culprit) {
076:                super (abox);
077:                this .tbox = tbox;
078:                this .abox = abox;
079:                this .expected = expected;
080:                this .culprit = culprit;
081:            }
082:
083:            /**
084:             * Constructor builds a runnable test from a dummy test.
085:             */
086:            public OWLConsistencyTest(OWLConsistencyTest base,
087:                    String reasonerName, ReasonerFactory rf) {
088:                super (reasonerName + ":" + base.abox);
089:                this .tbox = base.tbox;
090:                this .abox = base.abox;
091:                this .expected = base.expected;
092:                this .culprit = base.culprit;
093:                this .rf = rf;
094:            }
095:
096:            /**
097:             * Define the reasoner to use for the tests.
098:             */
099:            public void setReasonerFactory(ReasonerFactory rf) {
100:                this .rf = rf;
101:            }
102:
103:            /**
104:             * Run the consistency check, returning a ValidityReport.
105:             * 
106:             * @param rf
107:             *            The factory for the reasoner to test
108:             */
109:            public ValidityReport testResults() {
110:                Model t = FileManager.get().loadModel(BASE_DIR + tbox);
111:                Model a = FileManager.get().loadModel(BASE_DIR + abox);
112:                // Work around non-deterministic bug in bindSchema
113:                //        Reasoner r = rf.create(null).bindSchema(t);
114:                Reasoner r = rf.create(null);
115:                a.add(t);
116:                InfModel im = ModelFactory.createInfModel(r, a);
117:                return im.validate();
118:            }
119:
120:            /**
121:             * Run the consistency check and validate the result against expectations.
122:             * 
123:             * @param rf
124:             *            The factory for the reasoner to test
125:             */
126:            public void runTest() {
127:                ValidityReport report = testResults();
128:                switch (expected) {
129:                case INCONSISTENT:
130:                    assertTrue("expected inconsistent", !report.isValid());
131:                    break;
132:                case WARNINGS:
133:                    assertTrue("expected just warnings but reports not valid",
134:                            report.isValid());
135:                    assertFalse("expected warnings but reports clean", report
136:                            .isClean());
137:                    break;
138:                case CLEAN:
139:                    assertTrue("expected clean", report.isClean());
140:                }
141:                if (culprit != null) {
142:                    boolean foundit = false;
143:                    for (Iterator i = report.getReports(); i.hasNext();) {
144:                        ValidityReport.Report r = (ValidityReport.Report) i
145:                                .next();
146:                        if (r.getExtension() != null
147:                                && r.getExtension().equals(culprit)) {
148:                            foundit = true;
149:                            break;
150:                        }
151:                    }
152:                    if (!foundit) {
153:                        assertTrue("Expcted to find a culprint " + culprit,
154:                                false);
155:                    }
156:                }
157:            }
158:
159:        }
160:
161:        /*
162:         * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP All rights
163:         * reserved.
164:         * 
165:         * Redistribution and use in source and binary forms, with or without
166:         * modification, are permitted provided that the following conditions are met:
167:         * 
168:         * 1. Redistributions of source code must retain the above copyright notice,
169:         * this list of conditions and the following disclaimer.
170:         * 
171:         * 2. Redistributions in binary form must reproduce the above copyright notice,
172:         * this list of conditions and the following disclaimer in the documentation
173:         * and/or other materials provided with the distribution.
174:         * 
175:         * 3. The name of the author may not be used to endorse or promote products
176:         * derived from this software without specific prior written permission.
177:         * 
178:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
179:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
180:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
181:         * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
182:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
183:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
184:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
185:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
186:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
187:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
188:         */
w_w_w__._j_av___a_2__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.