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