KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > reasoner > test > TestCurrentRDFWG


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

10 package com.hp.hpl.jena.reasoner.test;
11
12 import com.hp.hpl.jena.reasoner.rulesys.RDFSRuleReasonerFactory;
13 import com.hp.hpl.jena.reasoner.*;
14 import com.hp.hpl.jena.rdf.model.*;
15 import com.hp.hpl.jena.shared.impl.JenaParameters;
16 import com.hp.hpl.jena.vocabulary.*;
17
18 import java.io.IOException JavaDoc;
19 import java.util.Iterator JavaDoc;
20
21 import junit.framework.TestCase;
22 import junit.framework.TestSuite;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27 /**
28  * Test the default RDFS reasoner against the current set of working group tests
29  *
30  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
31  * @version $Revision: 1.9 $ on $Date: 2005/02/21 12:18:16 $
32  */

33 public class TestCurrentRDFWG extends ReasonerTestBase {
34     
35     /** Location of the test file directory */
36     public static final String JavaDoc TEST_DIR = "testing/wg20031010/";
37 // public static final String TEST_DIR = "testing/wg/";
38

39     /** The base URI for the results file */
40     public static String JavaDoc BASE_RESULTS_URI = "http://jena.sourceforge.net/data/rdf-results.rdf";
41    
42     /** The model describing the results of the run */
43     Model testResults;
44     
45     /** The resource which acts as a description for the Jena2 instance being tested */
46     Resource jena2;
47     
48     protected static Log logger = LogFactory.getLog(TestCurrentRDFWG.class);
49
50     /**
51      * Boilerplate for junit
52      */

53     public TestCurrentRDFWG( String JavaDoc name ) {
54         super( name );
55     }
56    
57     /**
58      * Initialize the result model.
59      */

60     public void initResults() {
61         testResults = ModelFactory.createDefaultModel();
62         jena2 = testResults.createResource(BASE_RESULTS_URI + "#jena2");
63         jena2.addProperty(RDFS.comment,
64             testResults.createLiteral(
65                 "<a xmlns=\"http://www.w3.org/1999/xhtml\" HREF=\"http://jena.sourceforce.net/\">Jena2</a> includes a rule-based inference engine for RDF processing, " +
66                 "supporting both forward and backward chaining rules. Its OWL rule set is designed to provide sound " +
67                 "but not complete instance resasoning for that fragment of OWL/Full limited to the OWL/lite vocabulary. In" +
68                 "particular it does not support unionOf/complementOf.",
69                 true)
70         );
71         jena2.addProperty(RDFS.label, "Jena2");
72         testResults.setNsPrefix("results", OWLResults.NS);
73     }
74         
75     /**
76      * Boilerplate for junit.
77      * This is its own test suite
78      */

79     public static TestSuite suite() {
80         TestSuite suite = new TestSuite();
81         try {
82             Resource config = newResource()
83             .addProperty(ReasonerVocabulary.PROPsetRDFSLevel, "full");
84             constructRDFWGtests(suite, RDFSRuleReasonerFactory.theInstance(), config);
85                         
86         } catch (IOException JavaDoc e) {
87             // failed to even built the test harness
88
logger.error("Failed to construct RDF WG test harness", e);
89         }
90         return suite;
91     }
92         
93     /**
94      * Build the working group tests for the given reasoner.
95      */

96     private static void constructRDFWGtests(TestSuite suite, ReasonerFactory rf, Resource config) throws IOException JavaDoc {
97         JenaParameters.enableWhitespaceCheckingOfTypedLiterals = true;
98         WGReasonerTester tester = new WGReasonerTester("Manifest.rdf", TEST_DIR);
99         for (Iterator JavaDoc i = tester.listTests().iterator(); i.hasNext(); ) {
100             String JavaDoc test = (String JavaDoc)i.next();
101             suite.addTest(new TestReasonerWG(tester, test, rf, config));
102         }
103     }
104
105     /**
106      * Inner class defining a test framework for invoking a single
107      * RDFCore working group test.
108      */

109     static class TestReasonerWG extends TestCase {
110         
111         /** The tester which already has the test manifest loaded */
112         WGReasonerTester tester;
113         
114         /** The name of the specific test to run */
115         String JavaDoc test;
116         
117         /** The factory for the reasoner type under test */
118         ReasonerFactory reasonerFactory;
119         
120         /** An optional configuration model */
121         Resource config;
122         
123         /** Constructor */
124         TestReasonerWG(WGReasonerTester tester, String JavaDoc test,
125                                  ReasonerFactory reasonerFactory, Resource config) {
126             super(test);
127             this.tester = tester;
128             this.test = test;
129             this.reasonerFactory = reasonerFactory;
130             this.config = config;
131         }
132         
133         /**
134          * The test runner
135          */

136         public void runTest() throws IOException JavaDoc {
137             boolean success = tester.runTest(test, reasonerFactory, this, config);
138 // Resource resultType = null;
139
// if (test.hasProperty(RDF.type, OWLTest.NegativeEntailmentTest)
140
// || test.hasProperty(RDF.type, OWLTest.ConsistencyTest)) {
141
// resultType = success ? OWLResults.PassingRun : OWLResults.FailingRun;
142
// } else {
143
// resultType = success ? OWLResults.PassingRun : OWLResults.IncompleteRun;
144
// }
145
// // log to the rdf result format
146
// Resource result = testResults.createResource()
147
// .addProperty(RDF.type, OWLResults.TestRun)
148
// .addProperty(RDF.type, resultType)
149
// .addProperty(OWLResults.test, test)
150
// .addProperty(OWLResults.system, jena2);
151

152         }
153
154     }
155     
156 }
157
158 /*
159     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
160     All rights reserved.
161
162     Redistribution and use in source and binary forms, with or without
163     modification, are permitted provided that the following conditions
164     are met:
165
166     1. Redistributions of source code must retain the above copyright
167        notice, this list of conditions and the following disclaimer.
168
169     2. Redistributions in binary form must reproduce the above copyright
170        notice, this list of conditions and the following disclaimer in the
171        documentation and/or other materials provided with the distribution.
172
173     3. The name of the author may not be used to endorse or promote products
174        derived from this software without specific prior written permission.
175
176     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
177     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
178     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
179     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
180     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
181     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
182     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
183     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
184     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
185     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
186 */
Popular Tags