001: /*
002: (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: All rights reserved - see end of file.
004: $Id: AllAccept.java,v 1.8 2008/01/02 12:10:32 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.assembler.acceptance;
008:
009: import java.io.*;
010:
011: import junit.extensions.TestSetup;
012: import junit.framework.*;
013:
014: import com.hp.hpl.jena.assembler.*;
015: import com.hp.hpl.jena.assembler.test.AssemblerTestBase;
016: import com.hp.hpl.jena.db.*;
017: import com.hp.hpl.jena.db.test.TestConnection;
018: import com.hp.hpl.jena.rdf.model.*;
019: import com.hp.hpl.jena.reasoner.rulesys.GenericRuleReasoner;
020: import com.hp.hpl.jena.util.FileUtils;
021:
022: public class AllAccept extends AssemblerTestBase {
023: public AllAccept(String name) {
024: super (name);
025: }
026:
027: public static TestSuite suite() {
028: TestSuite result = new TestSuite();
029: result.addTestSuite(AllAccept.class);
030: result.addTest(new SetupDatabase(new TestSuite(
031: TestDatabaseModes.class)));
032: return result;
033: }
034:
035: public static class SetupDatabase extends TestSetup {
036: public SetupDatabase(Test tests) {
037: super (tests);
038: }
039:
040: public void setUp() throws Exception {
041: super .setUp();
042: IDBConnection conn = TestConnection
043: .makeAndCleanTestConnection();
044: ModelRDB.createModel(conn, "square");
045: ModelRDB.createModel(conn, "circle");
046: ModelRDB.createModel(conn, "triangle");
047: ModelRDB.createModel(conn, "hex");
048: conn.close();
049: IDBConnection x = ModelFactory.createSimpleRDBConnection();
050: assertEquals(true, x.containsModel("square"));
051: assertEquals(false, x.containsModel("line"));
052: x.close();
053: }
054: }
055:
056: public void testUnadornedInferenceModel() {
057: Resource root = resourceInModel("x ja:reasoner R; R rdf:type ja:ReasonerFactory");
058: Model m = Assembler.general.openModel(root);
059: assertInstanceOf(InfModel.class, m);
060: InfModel inf = (InfModel) m;
061: assertIsoModels(empty, inf.getRawModel());
062: assertInstanceOf(GenericRuleReasoner.class, inf.getReasoner());
063: }
064:
065: public void testWithContent() throws IOException {
066: File f = FileUtils.tempFileName("assembler-acceptance-", ".n3");
067: Model data = model("a P b; b Q c");
068: FileOutputStream fs = new FileOutputStream(f);
069: data.write(fs, "N3");
070: fs.close();
071: Resource root = resourceInModel("x rdf:type ja:MemoryModel; x ja:content y; y ja:externalContent file:"
072: + f.getAbsolutePath());
073: Model m = Assembler.general.openModel(root);
074: assertIsoModels(data, m);
075: }
076: }
077:
078: /*
079: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
080: * All rights reserved.
081: *
082: * Redistribution and use in source and binary forms, with or without
083: * modification, are permitted provided that the following conditions
084: * are met:
085: * 1. Redistributions of source code must retain the above copyright
086: * notice, this list of conditions and the following disclaimer.
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: * 3. The name of the author may not be used to endorse or promote products
091: * derived from this software without specific prior written permission.
092: *
093: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
094: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
095: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
096: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
097: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
098: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
099: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
100: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
101: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
102: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103: */
|