01: /*
02: (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved - see end of file.
04: $Id: TestRemoveSPO.java,v 1.3 2008/01/02 12:04:42 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.rdf.model.test;
08:
09: import java.util.*;
10:
11: import com.hp.hpl.jena.graph.*;
12: import com.hp.hpl.jena.graph.impl.WrappedGraph;
13: import com.hp.hpl.jena.rdf.model.Model;
14: import com.hp.hpl.jena.rdf.model.impl.ModelCom;
15:
16: import junit.framework.TestSuite;
17:
18: public class TestRemoveSPO extends ModelTestBase {
19: public TestRemoveSPO(String name) {
20: super (name);
21: }
22:
23: public static TestSuite suite() {
24: return new TestSuite(TestRemoveSPO.class);
25: }
26:
27: public void testRemoveSPOReturnsModel() {
28: Model m = new ModelCom(Factory.createDefaultGraph());
29: assertSame(m, m.remove(resource("R"), property("P"), rdfNode(m,
30: "17")));
31: }
32:
33: public void testRemoveSPOCallsGraphDeleteTriple() {
34: Graph base = Factory.createDefaultGraph();
35: final List deleted = new ArrayList();
36: Graph wrapped = new WrappedGraph(base) {
37: public void delete(Triple t) {
38: deleted.add(t);
39: }
40: };
41: Model m = new ModelCom(wrapped);
42: m.remove(resource("R"), property("P"), rdfNode(m, "17"));
43: assertEquals(listOfOne(Triple.create("R P 17")), deleted);
44: }
45: }
46:
47: /*
48: * (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
49: * All rights reserved.
50: *
51: * Redistribution and use in source and binary forms, with or without
52: * modification, are permitted provided that the following conditions
53: * are met:
54: * 1. Redistributions of source code must retain the above copyright
55: * notice, this list of conditions and the following disclaimer.
56: * 2. Redistributions in binary form must reproduce the above copyright
57: * notice, this list of conditions and the following disclaimer in the
58: * documentation and/or other materials provided with the distribution.
59: * 3. The name of the author may not be used to endorse or promote products
60: * derived from this software without specific prior written permission.
61: *
62: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
63: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
64: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
65: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
66: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
67: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
68: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
69: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
70: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
71: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72: */
|