1 6 7 package com.hp.hpl.jena.graph.test; 8 9 import java.lang.reflect.Constructor ; 10 11 import com.hp.hpl.jena.graph.*; 12 import com.hp.hpl.jena.graph.impl.GraphBase; 13 import com.hp.hpl.jena.graph.impl.ReifierFragmentsMap; 14 import com.hp.hpl.jena.graph.impl.ReifierTripleMap; 15 import com.hp.hpl.jena.graph.impl.SimpleReifier; 16 import com.hp.hpl.jena.graph.impl.SimpleReifierFragmentsMap; 17 import com.hp.hpl.jena.graph.impl.SimpleReifierTripleMap; 18 import com.hp.hpl.jena.mem.*; 19 import com.hp.hpl.jena.shared.*; 20 import com.hp.hpl.jena.util.iterator.ExtendedIterator; 21 22 import junit.framework.*; 23 24 28 29 public class TestReifier extends AbstractTestReifier 30 { 31 public TestReifier( String name ) 32 { super( name ); graphClass = null; style = null; } 33 34 protected final Class graphClass; 35 protected final ReificationStyle style; 36 37 public TestReifier( Class graphClass, String name, ReificationStyle style ) 38 { 39 super( name ); 40 this.graphClass = graphClass; 41 this.style = style; 42 } 43 44 public static TestSuite suite() 45 { 46 TestSuite result = new TestSuite(); 47 result.addTest( MetaTestGraph.suite( TestReifier.class, GraphMem.class ) ); 48 return result; 49 } 50 51 public Graph getGraph( ReificationStyle style ) 52 { 53 try 54 { 55 Constructor cons = getConstructor( graphClass, new Class [] {ReificationStyle.class} ); 56 if (cons != null) return (Graph) cons.newInstance( new Object [] { style } ); 57 Constructor cons2 = getConstructor( graphClass, new Class [] {this.getClass(), ReificationStyle.class} ); 58 if (cons2 != null) return (Graph) cons2.newInstance( new Object [] { this, style } ); 59 throw new JenaException( "no suitable graph constructor found for " + graphClass ); 60 } 61 catch (RuntimeException e) 62 { throw e; } 63 catch (Exception e) 64 { throw new JenaException( e ); } 65 } 66 67 public void testExtendedConstructorExists() 68 { 69 GraphBase parent = new GraphBase() { 70 71 public ExtendedIterator graphBaseFind( TripleMatch m ) 72 { 73 return null; 75 }}; 76 ReifierTripleMap tm = new SimpleReifierTripleMap(); 77 ReifierFragmentsMap fm = new SimpleReifierFragmentsMap(); 78 SimpleReifier sr = new SimpleReifier( parent, tm, fm, ReificationStyle.Minimal ); 79 } 80 } 81 82 111 | Popular Tags |