Source Code Cross Referenced for TestRDFSRules.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:        TestRDFSRules.java
003:         * Created by:  Dave Reynolds
004:         * Created on:  08-Apr-03
005:         * 
006:         * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
007:         * [See end of file]
008:         * $Id: TestRDFSRules.java,v 1.24 2008/01/02 12:08:20 andy_seaborne Exp $
009:         *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys.test;
010:
011:        import com.hp.hpl.jena.reasoner.*;
012:        import com.hp.hpl.jena.reasoner.test.*;
013:        import com.hp.hpl.jena.util.FileManager; // import com.hp.hpl.jena.util.PrintUtil;
014:        import com.hp.hpl.jena.vocabulary.OWL;
015:        import com.hp.hpl.jena.vocabulary.RDF;
016:        import com.hp.hpl.jena.vocabulary.RDFS;
017:        import com.hp.hpl.jena.reasoner.rdfsReasoner1.RDFSReasonerFactory;
018:        import com.hp.hpl.jena.reasoner.rulesys.*;
019:        import com.hp.hpl.jena.rdf.model.*;
020:
021:        import junit.framework.TestCase;
022:        import junit.framework.TestSuite;
023:        import java.io.IOException;
024:        import java.util.Iterator;
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:
028:        /** * Test suite to test the production rule version of the RDFS implementation.
029:         * <p> The tests themselves have been replaced by an updated version
030:         * of the top level TestRDFSReasoners but this file is maintained for now since
031:         * the top level timing test can sometimes be useful. </p>
032:         *  * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a> * @version $Revision: 1.24 $ on $Date: 2008/01/02 12:08:20 $ */
033:        public class TestRDFSRules extends TestCase {
034:            /** Base URI for the test names */
035:            public static final String NAMESPACE = "http://www.hpl.hp.com/semweb/2003/query_tester/";
036:
037:            protected static Log logger = LogFactory
038:                    .getLog(TestRDFSRules.class);
039:
040:            /**
041:             * Boilerplate for junit
042:             */
043:            public TestRDFSRules(String name) {
044:                super (name);
045:            }
046:
047:            /**
048:             * Boilerplate for junit.
049:             * This is its own test suite
050:             */
051:            public static TestSuite suite() {
052:                return new TestSuite(TestRDFSRules.class);
053:                //        TestSuite suite = new TestSuite();
054:                //        suite.addTest(new TestRDFSRules( "hiddenTestRDFSReasonerDebug" ));
055:                //        return suite;
056:            }
057:
058:            /**
059:             * Test a single RDFS case.
060:             */
061:            public void hiddenTestRDFSReasonerDebug() throws IOException {
062:                ReasonerTester tester = new ReasonerTester(
063:                        "rdfs/manifest-nodirect-noresource.rdf");
064:                ReasonerFactory rf = RDFSRuleReasonerFactory.theInstance();
065:
066:                assertTrue(
067:                        "RDFS hybrid-tgc reasoner test",
068:                        tester
069:                                .runTest(
070:                                        "http://www.hpl.hp.com/semweb/2003/query_tester/rdfs/test11",
071:                                        rf, this , null));
072:            }
073:
074:            /**
075:             * Test the basic functioning of the hybrid RDFS rule reasoner
076:             */
077:            public void testRDFSFBReasoner() throws IOException {
078:                ReasonerTester tester = new ReasonerTester(
079:                        "rdfs/manifest-nodirect-noresource.rdf");
080:                ReasonerFactory rf = RDFSFBRuleReasonerFactory.theInstance();
081:                assertTrue("RDFS hybrid reasoner tests", tester.runTests(rf,
082:                        this , null));
083:            }
084:
085:            /**
086:             * Test the basic functioning of the hybrid RDFS rule reasoner with TGC cache
087:             */
088:            public void testRDFSExptReasoner() throws IOException {
089:                ReasonerTester tester = new ReasonerTester(
090:                        "rdfs/manifest-nodirect-noresource.rdf");
091:                ReasonerFactory rf = RDFSRuleReasonerFactory.theInstance();
092:                assertTrue("RDFS experimental (hybrid+tgc) reasoner tests",
093:                        tester.runTests(rf, this , null));
094:            }
095:
096:            /**
097:             * Test the capabilities description.
098:             */
099:            public void testRDFSDescription() {
100:                ReasonerFactory rf = RDFSFBRuleReasonerFactory.theInstance();
101:                Reasoner r = rf.create(null);
102:                assertTrue(r.supportsProperty(RDFS.subClassOf));
103:                assertTrue(r.supportsProperty(RDFS.domain));
104:                assertTrue(!r.supportsProperty(OWL.allValuesFrom));
105:            }
106:
107:            /**
108:             * Time a trial list of results from an inf graph.
109:             */
110:            private static void doTiming(Reasoner r, Model tbox, Model data,
111:                    String name, int loop) {
112:                Resource C1 = ResourceFactory
113:                        .createResource("http://www.hpl.hp.com/semweb/2003/eg#C1");
114:                Resource C2 = ResourceFactory
115:                        .createResource("http://www.hpl.hp.com/semweb/2003/eg#C2");
116:
117:                long t1 = System.currentTimeMillis();
118:                int count = 0;
119:                for (int lp = 0; lp < loop; lp++) {
120:                    Model m = ModelFactory.createModelForGraph(r.bindSchema(
121:                            tbox.getGraph()).bind(data.getGraph()));
122:                    count = 0;
123:                    for (Iterator i = m.listStatements(null, RDF.type, C1); i
124:                            .hasNext(); i.next())
125:                        count++;
126:                }
127:                long t2 = System.currentTimeMillis();
128:                long time10 = (t2 - t1) * 10 / loop;
129:                long time = time10 / 10;
130:                long timeFraction = time10 - (time * 10);
131:                System.out.println(name + ": " + count + " results in " + time
132:                        + "." + timeFraction + "ms");
133:                //        t1 = System.currentTimeMillis();
134:                //        for (int j = 0; j < 10; j++) {
135:                //            count = 0;
136:                //            for (Iterator i = m.listStatements(null, RDF.type, C1); i.hasNext(); i.next()) count++;
137:                //        }
138:                //        t2 = System.currentTimeMillis();
139:                //        System.out.println(name + ": " + count + " results in " + (t2-t1)/10 +"ms");
140:            }
141:
142:            /**
143:             * Simple timing test used to just a broad feel for how performance of the
144:             * pure FPS rules compares with the hand-crafted version.
145:             * The test ontology and data is very small. The test query is designed to
146:             * require an interesting fraction of the inferences to be made but not all of them.
147:             * The bigger the query the more advantage the FPS (which eagerly computes everything)
148:             * would have over the normal approach.
149:             */
150:            public static void main(String[] args) {
151:                try {
152:                    Model tbox = FileManager.get().loadModel(
153:                            "testing/reasoners/rdfs/timing-tbox.rdf");
154:                    Model data = FileManager.get().loadModel(
155:                            "testing/reasoners/rdfs/timing-data.rdf");
156:                    Reasoner rdfsFBRule = RDFSFBRuleReasonerFactory
157:                            .theInstance().create(null);
158:                    Reasoner rdfs1 = RDFSReasonerFactory.theInstance().create(
159:                            null);
160:                    Reasoner rdfsFinal = RDFSRuleReasonerFactory.theInstance()
161:                            .create(null);
162:
163:                    doTiming(rdfs1, tbox, data, "RDFS1", 1);
164:                    doTiming(rdfsFBRule, tbox, data, "RDFS FB rule", 1);
165:                    doTiming(rdfsFinal, tbox, data, "RDFS final rule", 1);
166:                    doTiming(rdfs1, tbox, data, "RDFS1", 50);
167:                    doTiming(rdfsFBRule, tbox, data, "RDFS FB rule", 50);
168:                    doTiming(rdfsFinal, tbox, data, "RDFS final rule", 50);
169:
170:                } catch (Exception e) {
171:                    System.out.println("Problem: " + e.toString());
172:                    e.printStackTrace();
173:                }
174:            }
175:
176:        }
177:
178:        /*
179:         (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
180:         All rights reserved.
181:
182:         Redistribution and use in source and binary forms, with or without
183:         modification, are permitted provided that the following conditions
184:         are met:
185:
186:         1. Redistributions of source code must retain the above copyright
187:         notice, this list of conditions and the following disclaimer.
188:
189:         2. Redistributions in binary form must reproduce the above copyright
190:         notice, this list of conditions and the following disclaimer in the
191:         documentation and/or other materials provided with the distribution.
192:
193:         3. The name of the author may not be used to endorse or promote products
194:         derived from this software without specific prior written permission.
195:
196:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
197:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
198:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
199:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
200:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
201:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
202:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
203:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
204:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
205:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
206:         */
w__ww___.j__a_v___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.