KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > graph > compose > test > TestDelta


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: TestDelta.java,v 1.5 2005/02/21 11:52:06 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.graph.compose.test;
8
9 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         
21     public TestDelta( String JavaDoc name )
22         { super( name ); }
23         
24     public static TestSuite suite()
25         { return new TestSuite( TestDelta.class ); }
26         
27     public void testDelta()
28         {
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, "x R y; p S q; I like cheese; pins pop balloons" );
38         assertContainsAll( "Delta", base, "x R y; p S q; I like cheese; pins pop balloons" );
39     /* */
40         delta.add( triple( "pigs fly winglessly" ) );
41         delta.delete( triple( "I like cheese" ) );
42     /* */
43         assertContainsAll( "changed Delta", delta, "x R y; p S q; pins pop balloons; pigs fly winglessly" );
44         assertOmits( "changed delta", delta, "I like cheese" );
45         assertContains( "delta additions", "pigs fly winglessly", delta.getAdditions() );
46         assertOmits( "delta additions", delta.getAdditions(), "I like cheese" );
47         assertContains( "delta deletions", "I like cheese", delta.getDeletions() );
48         assertOmits( "delta deletions", delta.getDeletions(), "pigs fly winglessly" );
49         }
50     }
51
52 /*
53     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
54     All rights reserved.
55
56     Redistribution and use in source and binary forms, with or without
57     modification, are permitted provided that the following conditions
58     are met:
59
60     1. Redistributions of source code must retain the above copyright
61        notice, this list of conditions and the following disclaimer.
62
63     2. Redistributions in binary form must reproduce the above copyright
64        notice, this list of conditions and the following disclaimer in the
65        documentation and/or other materials provided with the distribution.
66
67     3. The name of the author may not be used to endorse or promote products
68        derived from this software without specific prior written permission.
69
70     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
71     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
72     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
73     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
74     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
75     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
76     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
77     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
79     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
80 */

81
Popular Tags