1 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 19 20 public class TestUnion extends GraphTestBase 21 { 22 public TestUnion( String 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 78 | Popular Tags |