01: /*
02: (c) (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: [See end of file]
04: $Id: TestMixedGraphMem.java,v 1.8 2008/01/02 12:09:00 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.mem.test;
08:
09: import java.util.*;
10:
11: import junit.framework.TestSuite;
12:
13: import com.hp.hpl.jena.graph.*;
14: import com.hp.hpl.jena.mem.*;
15: import com.hp.hpl.jena.mem.MixedGraphMem;
16:
17: /**
18: @author hedgehog
19: */
20: public class TestMixedGraphMem extends TestGraphMem {
21: public TestMixedGraphMem(String name) {
22: super (name);
23: }
24:
25: public static TestSuite suite() {
26: return new TestSuite(TestMixedGraphMem.class);
27: }
28:
29: public Graph getGraph() {
30: return new MixedGraphMem();
31: }
32:
33: public void testRepeatedAddSuppressesPredicateAndObject() {
34: final List history = new ArrayList();
35: MixedGraphMemStore t = new MixedGraphMemStore(getGraph()) {
36: protected boolean add(Node key, Triple t) {
37: history.add(key);
38: return super .add(key, t);
39: }
40: };
41: t.add(triple("s P o"));
42: assertEquals(nodeList("s P o"), history);
43: t.add(triple("s P o"));
44: assertEquals(nodeList("s P o s"), history);
45: }
46:
47: public void testUnnecessaryMatches() {
48: /* test not appropriate for subclass */
49: }
50:
51: public void testRemoveAbsentSuppressesPredicateAndObject() {
52: final List history = new ArrayList();
53: MixedGraphMemStore t = new MixedGraphMemStore(getGraph()) {
54: protected boolean remove(Node key, Triple t) {
55: history.add(key);
56: return super .remove(key, t);
57: }
58: };
59: t.remove(triple("s P o"));
60: assertEquals(nodeList("s"), history);
61: }
62: }
63:
64: /*
65: * (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
66: * All rights reserved.
67: *
68: * Redistribution and use in source and binary forms, with or without
69: * modification, are permitted provided that the following conditions
70: * are met:
71: * 1. Redistributions of source code must retain the above copyright
72: * notice, this list of conditions and the following disclaimer.
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: * 3. The name of the author may not be used to endorse or promote products
77: * derived from this software without specific prior written permission.
78:
79: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
80: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
81: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
82: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
83: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
84: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
85: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
86: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
87: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
88: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89: */
|