001: /*
002: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: [See end of file]
004: $Id: TestModelFactory.java,v 1.36 2008/01/02 12:04:41 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.rdf.model.test;
008:
009: import com.hp.hpl.jena.rdf.model.*;
010: import com.hp.hpl.jena.rdf.model.impl.*;
011: import com.hp.hpl.jena.ontology.*;
012: import com.hp.hpl.jena.reasoner.InfGraph;
013: import com.hp.hpl.jena.reasoner.Reasoner;
014: import com.hp.hpl.jena.reasoner.rulesys.*;
015: import com.hp.hpl.jena.shared.*;
016: import com.hp.hpl.jena.graph.compose.Union;
017:
018: import junit.framework.*;
019:
020: /**
021: Tests the ModelFactory code. Very skeletal at the moment. It's really
022: testing that the methods actually exists, but it doesn't check much in
023: the way of behaviour.
024:
025: @author kers
026: */
027:
028: public class TestModelFactory extends ModelTestBase {
029: public static final Resource DAMLLangResource = resource(ProfileRegistry.DAML_LANG);
030:
031: public TestModelFactory(String name) {
032: super (name);
033: }
034:
035: public static TestSuite suite() {
036: return new TestSuite(TestModelFactory.class);
037: }
038:
039: /**
040: Test that ModelFactory.createDefaultModel() exists. [Should check that the Model
041: is truly a "default" model.]
042: */
043: public void testCreateDefaultModel() {
044: ModelFactory.createDefaultModel().close();
045: }
046:
047: public void testGetDefaultPrefixMapping() {
048: assertSame(ModelCom.getDefaultModelPrefixes(), ModelFactory
049: .getDefaultModelPrefixes());
050: }
051:
052: public void testSetDefaultPrefixMapping() {
053: PrefixMapping original = ModelCom.getDefaultModelPrefixes();
054: PrefixMapping pm = PrefixMapping.Factory.create();
055: ModelFactory.setDefaultModelPrefixes(pm);
056: assertSame(pm, ModelCom.getDefaultModelPrefixes());
057: assertSame(pm, ModelFactory.getDefaultModelPrefixes());
058: ModelCom.setDefaultModelPrefixes(original);
059: }
060:
061: public void testCreateInfModel() {
062: String rule = "-> (eg:r eg:p eg:v).";
063: Reasoner r = new GenericRuleReasoner(Rule.parseRules(rule));
064: InfGraph ig = r.bind(ModelFactory.createDefaultModel()
065: .getGraph());
066: InfModel im = ModelFactory.createInfModel(ig);
067: assertInstanceOf(InfModel.class, im);
068: assertEquals(1, im.size());
069: }
070:
071: /**
072: test that a union model is a model over the union of the two underlying
073: graphs. (We don't check that Union works - that's done in the Union
074: tests, we hope.)
075: */
076: public void testCreateUnion() {
077: Model m1 = ModelFactory.createDefaultModel();
078: Model m2 = ModelFactory.createDefaultModel();
079: Model m = ModelFactory.createUnion(m1, m2);
080: assertInstanceOf(Union.class, m.getGraph());
081: assertSame(m1.getGraph(), ((Union) m.getGraph()).getL());
082: assertSame(m2.getGraph(), ((Union) m.getGraph()).getR());
083: }
084:
085: public void testAssembleModelFromModel() {
086: // TODO Model ModelFactory.assembleModelFrom( Model singleRoot )
087: }
088:
089: public void testFindAssemblerRoots() {
090: // TODO Set ModelFactory.findAssemblerRoots( Model m )
091: }
092:
093: public void testAssmbleModelFromRoot() {
094: // TODO Model assembleModelFrom( Resource root )
095: }
096: }
097:
098: /*
099: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
100: All rights reserved.
101:
102: Redistribution and use in source and binary forms, with or without
103: modification, are permitted provided that the following conditions
104: are met:
105:
106: 1. Redistributions of source code must retain the above copyright
107: notice, this list of conditions and the following disclaimer.
108:
109: 2. Redistributions in binary form must reproduce the above copyright
110: notice, this list of conditions and the following disclaimer in the
111: documentation and/or other materials provided with the distribution.
112:
113: 3. The name of the author may not be used to endorse or promote products
114: derived from this software without specific prior written permission.
115:
116: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
117: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
118: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
119: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
120: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
121: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
122: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
123: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
124: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
125: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
126: */
|