KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: TestUnion.java,v 1.5 2005/02/21 11:52:08 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.Union;
11 import com.hp.hpl.jena.graph.test.*;
12
13
14 import junit.framework.*;
15
16 /**
17     @author kers.
18 */

19
20 public class TestUnion extends GraphTestBase
21     {
22     public TestUnion( String JavaDoc name )
23         { super( name ); }
24             
25     public static TestSuite suite()
26         { return new TestSuite( TestUnion.class ); }
27         
28     public void testUnion()
29         {
30         Graph g1 = graphWith( "x R y; p R q" );
31         Graph g2 = graphWith( "r A s; x R y" );
32         Union u = new Union( g1, g2 );
33         assertContains( "Union", "x R y", u );
34         assertContains( "Union", "p R q", u );
35         assertContains( "Union", "r A s", u );
36         if (u.size() != 3)
37             fail( "oops: size of union is not 3" );
38         u.add( triple( "cats eat cheese" ) );
39         assertContains( "Union", "cats eat cheese", u );
40         if
41             (
42             contains( g1, "cats eat cheese" ) == false
43             && contains( g2, "cats eat cheese" ) == false
44             )
45             fail( "oops: neither g1 nor g2 contains `cats eat cheese`" );
46         }
47     }
48
49 /*
50     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
51     All rights reserved.
52
53     Redistribution and use in source and binary forms, with or without
54     modification, are permitted provided that the following conditions
55     are met:
56
57     1. Redistributions of source code must retain the above copyright
58        notice, this list of conditions and the following disclaimer.
59
60     2. Redistributions in binary form must reproduce the above copyright
61        notice, this list of conditions and the following disclaimer in the
62        documentation and/or other materials provided with the distribution.
63
64     3. The name of the author may not be used to endorse or promote products
65        derived from this software without specific prior written permission.
66
67     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
68     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
69     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
70     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
71     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
72     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
73     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
74     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
75     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
76     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77 */

78
Popular Tags