001: /*
002: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: [See end of file]
004: $Id: TestQuery1.java,v 1.10 2008/01/02 12:08:14 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.db.test;
008:
009: import com.hp.hpl.jena.graph.*;
010: import com.hp.hpl.jena.db.*;
011: import com.hp.hpl.jena.shared.*;
012:
013: import java.util.*;
014:
015: import junit.framework.*;
016:
017: /**
018: Apply the abstract query tests to an RDB graph.
019: @author kers
020: */
021: public class TestQuery1 extends AbstractTestQuery1 {
022: public TestQuery1(String name) {
023: super (name);
024: }
025:
026: public static TestSuite suite() {
027: return new TestSuite(TestQuery1.class);
028: }
029:
030: private IDBConnection theConnection;
031: private int count = 0;
032:
033: private List graphs;
034:
035: public void setUp() throws Exception {
036: theConnection = TestConnection.makeTestConnection();
037: graphs = new ArrayList();
038: super .setUp();
039: }
040:
041: public void tearDown() throws Exception {
042: removeGraphs();
043: theConnection.close();
044: super .tearDown();
045: }
046:
047: private void removeGraphs() {
048: for (int i = 0; i < graphs.size(); i += 1)
049: ((GraphRDB) graphs.get(i)).remove();
050: }
051:
052: public Graph getGraph() {
053: return getGraph(ReificationStyle.Minimal);
054: }
055:
056: public Graph getGraph(ReificationStyle style) {
057: String name = "jena-test-rdb-TestQuery1-" + count++;
058: if (theConnection.containsModel(name))
059: makeGraph(name, false, style).remove();
060: GraphRDB result = makeGraph(name, true, style);
061: graphs.add(result);
062: return result;
063: }
064:
065: protected GraphRDB makeGraph(String name, boolean fresh,
066: ReificationStyle style) {
067: return new GraphRDB(theConnection, name, theConnection
068: .getDefaultModelProperties().getGraph(), GraphRDB
069: .styleRDB(style), fresh);
070: }
071:
072: }
073:
074: /*
075: (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
076: All rights reserved.
077:
078: Redistribution and use in source and binary forms, with or without
079: modification, are permitted provided that the following conditions
080: are met:
081:
082: 1. Redistributions of source code must retain the above copyright
083: notice, this list of conditions and the following disclaimer.
084:
085: 2. Redistributions in binary form must reproduce the above copyright
086: notice, this list of conditions and the following disclaimer in the
087: documentation and/or other materials provided with the distribution.
088:
089: 3. The name of the author may not be used to endorse or promote products
090: derived from this software without specific prior written permission.
091:
092: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
093: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
094: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
095: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
096: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
097: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
098: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
099: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
100: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
101: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102: */
|