01: /*
02: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: [See end of file]
04: $Id: TestGraphMem.java,v 1.22 2008/01/02 12:09:01 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.mem.test;
08:
09: import com.hp.hpl.jena.graph.*;
10: import com.hp.hpl.jena.mem.*;
11: import com.hp.hpl.jena.shared.JenaException;
12: import com.hp.hpl.jena.util.iterator.ExtendedIterator;
13:
14: import junit.framework.*;
15:
16: /**
17: @author kers
18: */
19: public class TestGraphMem extends AbstractTestGraphMem {
20: public TestGraphMem(String name) {
21: super (name);
22: }
23:
24: public static TestSuite suite() {
25: return new TestSuite(TestGraphMem.class);
26: }
27:
28: public Graph getGraph() {
29: return Factory.createGraphMem();
30: }
31:
32: public void testRemoveAllDoesntUseFind() {
33: Graph g = new GraphMemWithoutFind();
34: graphAdd(g, "x P y; a Q b");
35: g.getBulkUpdateHandler().removeAll();
36: assertEquals(0, g.size());
37: }
38:
39: public void testSizeAfterRemove() {
40: Graph g = getGraphWith("x p y");
41: ExtendedIterator it = g.find(triple("x ?? ??"));
42: it.removeNext();
43: assertEquals(0, g.size());
44: }
45:
46: public void testContainsConcreteDoesntUseFind() {
47: Graph g = new GraphMemWithoutFind();
48: graphAdd(g, "x P y; a Q b");
49: assertTrue(g.contains(triple("x P y")));
50: assertTrue(g.contains(triple("a Q b")));
51: assertFalse(g.contains(triple("a P y")));
52: assertFalse(g.contains(triple("y R b")));
53: }
54:
55: protected final class GraphMemWithoutFind extends GraphMem {
56: public ExtendedIterator graphBaseFind(TripleMatch t) {
57: throw new JenaException("find is Not Allowed");
58: }
59: }
60: }
61:
62: /*
63: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
64: All rights reserved.
65:
66: Redistribution and use in source and binary forms, with or without
67: modification, are permitted provided that the following conditions
68: are met:
69:
70: 1. Redistributions of source code must retain the above copyright
71: notice, this list of conditions and the following disclaimer.
72:
73: 2. Redistributions in binary form must reproduce the above copyright
74: notice, this list of conditions and the following disclaimer in the
75: documentation and/or other materials provided with the distribution.
76:
77: 3. The name of the author may not be used to endorse or promote products
78: derived from this software without specific prior written permission.
79:
80: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
81: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
82: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
83: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
84: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
85: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
86: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
87: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
89: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90: */
|