1 6 7 package com.hp.hpl.jena.graph.compose.test; 8 9 import com.hp.hpl.jena.util.iterator.*; 10 import com.hp.hpl.jena.graph.*; 11 import com.hp.hpl.jena.graph.compose.Dyadic; 12 import com.hp.hpl.jena.graph.test.*; 13 import com.hp.hpl.jena.mem.GraphMem; 14 15 16 import java.util.*; 17 import junit.framework.*; 18 19 22 public class TestDyadic extends GraphTestBase 23 { 24 public TestDyadic( String name ) 25 { super( name ); } 26 27 public static TestSuite suite() 28 { return new TestSuite( TestDyadic.class ); } 29 30 static private ExtendedIterator things( final String x ) 31 { 32 return new NiceIterator() 33 { 34 private StringTokenizer tokens = new StringTokenizer( x ); 35 public boolean hasNext() { return tokens.hasMoreTokens(); } 36 public Object next() { return tokens.nextToken(); } 37 }; 38 } 39 40 public void testDyadic() 41 { 42 ExtendedIterator it1 = things( "now is the time" ); 43 ExtendedIterator it2 = things( "now is the time" ); 44 ExtendedIterator mt1 = things( "" ); 45 ExtendedIterator mt2 = things( "" ); 46 assertEquals( "mt1.hasNext()", false, mt1.hasNext() ); 47 assertEquals( "mt2.hasNext()", false, mt2.hasNext() ); 48 assertEquals( "andThen(mt1,mt2).hasNext()", false, mt1.andThen( mt2 ).hasNext() ); 49 assertEquals( "butNot(it1,it2).hasNext()", false, Dyadic.butNot( it1, it2 ).hasNext() ); 50 assertEquals( "x y z @butNot z", true, Dyadic.butNot( things( "x y z" ), things( "z" ) ).hasNext() ); 51 assertEquals( "x y z @butNot a", true, Dyadic.butNot( things( "x y z" ), things( "z" ) ).hasNext() ); 52 } 53 54 public void testDyadicOperands() 55 { 56 Graph g = new GraphMem(), h = new GraphMem(); 57 Dyadic d = new Dyadic( g, h ) 58 { 59 public ExtendedIterator graphBaseFind( TripleMatch m ) { return null; } 60 }; 61 assertSame( g, d.getL() ); 62 assertSame( h, d.getR() ); 63 } 64 } 65 66 95 | Popular Tags |