1 6 7 package com.hp.hpl.jena.graph.compose.test; 8 9 import junit.framework.TestSuite; 10 11 import com.hp.hpl.jena.graph.*; 12 import com.hp.hpl.jena.graph.compose.*; 13 import com.hp.hpl.jena.shared.PrefixMapping; 14 import com.hp.hpl.jena.shared.test.AbstractTestPrefixMapping; 15 16 17 public class TestPolyadicPrefixMapping extends AbstractTestPrefixMapping 18 { 19 public TestPolyadicPrefixMapping( String name ) 20 { super( name ); } 21 22 public static TestSuite suite() 23 { return new TestSuite( TestPolyadicPrefixMapping.class ); } 24 25 Graph gBase; 26 Graph g1, g2; 27 Polyadic poly; 28 29 protected static final String alpha = "something:alpha#"; 30 protected static final String beta = "something:beta#"; 31 32 public void setUp() 33 { 34 gBase = Factory.createDefaultGraph(); 35 g1 = Factory.createDefaultGraph(); 36 g2 = Factory.createDefaultGraph(); 37 poly = new MultiUnion( new Graph[] {gBase, g1, g2} ); 38 poly.setBaseGraph( gBase ); 39 } 40 41 protected PrefixMapping getMapping() 42 { 43 Graph gBase = Factory.createDefaultGraph(); 44 Graph g1 = Factory.createDefaultGraph(); 45 Graph g2 = Factory.createDefaultGraph(); 46 Polyadic poly = new MultiUnion( new Graph[] {gBase, g1, g2} ); 47 return new PolyadicPrefixMappingImpl( poly ); 48 } 49 50 56 57 public void testOnlyBaseMutated() 58 { 59 poly.getPrefixMapping().setNsPrefix( "a", alpha ); 60 assertEquals( null, g1.getPrefixMapping().getNsPrefixURI( "a" ) ); 61 assertEquals( null, g2.getPrefixMapping().getNsPrefixURI( "a" ) ); 62 assertEquals( alpha, gBase.getPrefixMapping().getNsPrefixURI( "a" ) ); 63 } 64 65 public void testUpdatesVisible() 66 { 67 g1.getPrefixMapping().setNsPrefix( "a", alpha ); 68 g2.getPrefixMapping().setNsPrefix( "b", beta ); 69 assertEquals( alpha, poly.getPrefixMapping().getNsPrefixURI( "a" ) ); 70 assertEquals( beta, poly.getPrefixMapping().getNsPrefixURI( "b" ) ); 71 } 72 73 public void testUpdatesOverridden() 74 { 75 g1.getPrefixMapping().setNsPrefix( "x", alpha ); 76 poly.getPrefixMapping().setNsPrefix( "x", beta ); 77 assertEquals( beta, poly.getPrefixMapping().getNsPrefixURI( "x" ) ); 78 } 79 80 public void testQNameComponents() 81 { 82 g1.getPrefixMapping().setNsPrefix( "x", alpha ); 83 g2.getPrefixMapping().setNsPrefix( "y", beta ); 84 assertEquals( "x:hoop", poly.getPrefixMapping().qnameFor( alpha + "hoop" ) ); 85 assertEquals( "y:lens", poly.getPrefixMapping().qnameFor( beta + "lens" ) ); 86 } 87 88 } 89 90 | Popular Tags |