01: /*
02: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: [See end of file]
04: $Id: TestDelta.java,v 1.8 2008/01/02 12:07:21 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.graph.compose.test;
08:
09: import com.hp.hpl.jena.graph.*;
10: import com.hp.hpl.jena.graph.compose.Delta;
11: import com.hp.hpl.jena.graph.test.*;
12:
13: import junit.framework.*;
14:
15: /**
16: @author kers
17: */
18: public class TestDelta extends GraphTestBase {
19:
20: public TestDelta(String name) {
21: super (name);
22: }
23:
24: public static TestSuite suite() {
25: return new TestSuite(TestDelta.class);
26: }
27:
28: public void testDelta() {
29: Graph x = graphWith("x R y");
30: assertContains("x", "x R y", x);
31: x.delete(triple("x R y"));
32: assertOmits("x", x, "x R y");
33: /* */
34: Graph base = graphWith("x R y; p S q; I like cheese; pins pop balloons");
35: Graph save = graphWith("x R y; p S q; I like cheese; pins pop balloons");
36: Delta delta = new Delta(base);
37: assertContainsAll("Delta", delta,
38: "x R y; p S q; I like cheese; pins pop balloons");
39: assertContainsAll("Delta", base,
40: "x R y; p S q; I like cheese; pins pop balloons");
41: /* */
42: delta.add(triple("pigs fly winglessly"));
43: delta.delete(triple("I like cheese"));
44: /* */
45: assertContainsAll("changed Delta", delta,
46: "x R y; p S q; pins pop balloons; pigs fly winglessly");
47: assertOmits("changed delta", delta, "I like cheese");
48: assertContains("delta additions", "pigs fly winglessly", delta
49: .getAdditions());
50: assertOmits("delta additions", delta.getAdditions(),
51: "I like cheese");
52: assertContains("delta deletions", "I like cheese", delta
53: .getDeletions());
54: assertOmits("delta deletions", delta.getDeletions(),
55: "pigs fly winglessly");
56: }
57: }
58:
59: /*
60: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
61: All rights reserved.
62:
63: Redistribution and use in source and binary forms, with or without
64: modification, are permitted provided that the following conditions
65: are met:
66:
67: 1. Redistributions of source code must retain the above copyright
68: notice, this list of conditions and the following disclaimer.
69:
70: 2. Redistributions in binary form must reproduce the above copyright
71: notice, this list of conditions and the following disclaimer in the
72: documentation and/or other materials provided with the distribution.
73:
74: 3. The name of the author may not be used to endorse or promote products
75: derived from this software without specific prior written permission.
76:
77: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
78: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
79: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
80: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
81: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
82: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
83: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
84: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
85: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
86: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
87: */
|