001: /******************************************************************
002: * File: TestInfModel.java
003: * Created by: Dave Reynolds
004: * Created on: 31-Oct-2005
005: *
006: * (c) Copyright 2005, Hewlett-Packard Development Company, LP
007: * [See end of file]
008: * $Id: TestInfModel.java,v 1.4 2008/01/02 12:08:31 andy_seaborne Exp $
009: *****************************************************************/package com.hp.hpl.jena.reasoner.test;
010:
011: import com.hp.hpl.jena.ontology.OntModel;
012: import com.hp.hpl.jena.ontology.OntModelSpec;
013: import com.hp.hpl.jena.rdf.model.*;
014: import com.hp.hpl.jena.reasoner.ReasonerRegistry;
015: import com.hp.hpl.jena.util.PrintUtil;
016: import com.hp.hpl.jena.vocabulary.RDFS;
017:
018: import junit.framework.TestCase;
019: import junit.framework.TestSuite;
020:
021: /**
022: * Test machinery in InfModel which is not associated with any
023: * particular reasoner.
024: *
025: * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
026: * @version $Revision: 1.4 $
027: */
028:
029: public class TestInfModel extends TestCase {
030: /**
031: * Boilerplate for junit
032: */
033: public TestInfModel(String name) {
034: super (name);
035: }
036:
037: /**
038: * Boilerplate for junit.
039: * This is its own test suite
040: */
041: public static TestSuite suite() {
042: return new TestSuite(TestInfModel.class);
043: }
044:
045: /**
046: * Check interface extensions which had an earlier bug with null handling
047: */
048: public void testListWithPosits() {
049: String NS = PrintUtil.egNS;
050: Model data = ModelFactory.createDefaultModel();
051: Resource c1 = data.createResource(NS + "C1");
052: Resource c2 = data.createResource(NS + "C2");
053: Resource c3 = data.createResource(NS + "C3");
054: data.add(c2, RDFS.subClassOf, c3);
055: Model premise = ModelFactory.createDefaultModel();
056: premise.add(c1, RDFS.subClassOf, c2);
057: InfModel im = ModelFactory.createInfModel(ReasonerRegistry
058: .getRDFSReasoner(), data);
059: TestUtil.assertIteratorValues(this , im.listStatements(c1,
060: RDFS.subClassOf, null, premise), new Object[] {
061: data.createStatement(c1, RDFS.subClassOf, c2),
062: data.createStatement(c1, RDFS.subClassOf, c3),
063: data.createStatement(c1, RDFS.subClassOf, c1) });
064:
065: OntModel om = ModelFactory.createOntologyModel(
066: OntModelSpec.RDFS_MEM_RDFS_INF, data);
067: TestUtil.assertIteratorValues(this , om.listStatements(c1,
068: RDFS.subClassOf, null, premise), new Object[] {
069: data.createStatement(c1, RDFS.subClassOf, c2),
070: data.createStatement(c1, RDFS.subClassOf, c3),
071: data.createStatement(c1, RDFS.subClassOf, c1) });
072: }
073:
074: }
075:
076: /*
077: (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
078: All rights reserved.
079:
080: Redistribution and use in source and binary forms, with or without
081: modification, are permitted provided that the following conditions
082: are met:
083:
084: 1. Redistributions of source code must retain the above copyright
085: notice, this list of conditions and the following disclaimer.
086:
087: 2. Redistributions in binary form must reproduce the above copyright
088: notice, this list of conditions and the following disclaimer in the
089: documentation and/or other materials provided with the distribution.
090:
091: 3. The name of the author may not be used to endorse or promote products
092: derived from this software without specific prior written permission.
093:
094: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
095: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
096: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
097: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
098: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
099: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
100: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
101: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
102: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
103: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104: */
|