/** The empty prefix is specifically allowed [for the default namespace]. */ public void testEmptyPrefix() { PrefixMapping pm = getMapping(); pm.setNsPrefix( "", crispURI ); assertEquals( crispURI, pm.getNsPrefixURI( "" ) ); }
public void testNoMapping() { String hURI = "http://test.prefixes/prefix#"; PrefixMapping A = getMapping(); assertTrue(A.hasNoMappings()) ; A.setNsPrefix( "hr", hURI ); assertFalse(A.hasNoMappings()) ; }
public void testLock() { PrefixMapping A = getMapping(); assertSame( A, A.lock() ); /* */ try { A.setNsPrefix( "crisp", crispURI ); fail( "mapping should be frozen" ); } catch (PrefixMapping.JenaLockedException e) { pass(); } /* */ try { A.setNsPrefixes( A ); fail( "mapping should be frozen" ); } catch (PrefixMapping.JenaLockedException e) { pass(); } /* */ try { A.setNsPrefixes( new HashMap<String, String>() ); fail( "mapping should be frozen" ); } catch (PrefixMapping.JenaLockedException e) { pass(); } /* */ try { A.removeNsPrefix( "toast" ); fail( "mapping should be frozen" ); } catch (PrefixMapping.JenaLockedException e) { pass(); } } }
public void testUseEasyPrefix() { testUseEasyPrefix( "prefix mapping impl", getMapping() ); testShortForm( "prefix mapping impl", getMapping() ); }
public void testEqualsBase( String S, String T, boolean expected ) { testEquals( S, T, expected, getMapping(), getMapping() ); testEquals( S, T, expected, PrefixMapping.Factory.create(), getMapping() ); }
public void testNullURITrapped() { try { getMapping().setNsPrefix( "xy", null ); fail( "should trap null URI in setNsPrefix" ); } catch (NullPointerException e) { pass(); } }
/** test that we can add the maplets from another PrefixMapping without losing our own. */ public void testAddOtherPrefixMapping() { PrefixMapping a = getMapping(); PrefixMapping b = getMapping(); assertFalse( "must have two diffferent maps", a == b ); a.setNsPrefix( "crisp", crispURI ); a.setNsPrefix( "rope", ropeURI ); b.setNsPrefix( "butter", butterURI ); assertEquals( null, b.getNsPrefixURI( "crisp") ); assertEquals( null, b.getNsPrefixURI( "rope") ); b.setNsPrefixes( a ); checkContainsMapping( b ); }
public void testAddDefaultMap() { PrefixMapping pm = getMapping(); PrefixMapping root = PrefixMapping.Factory.create(); pm.setNsPrefix( "a", "aPrefix:" ); pm.setNsPrefix( "b", "bPrefix:" ); root.setNsPrefix( "a", "pootle:" ); root.setNsPrefix( "z", "bPrefix:" ); root.setNsPrefix( "c", "cootle:" ); assertSame( pm, pm.withDefaultMappings( root ) ); assertEquals( "aPrefix:", pm.getNsPrefixURI( "a" ) ); assertEquals( null, pm.getNsPrefixURI( "z" ) ); assertEquals( "bPrefix:", pm.getNsPrefixURI( "b" ) ); assertEquals( "cootle:", pm.getNsPrefixURI( "c" ) ); }
/** test that a PrefixMapping maps names to URIs. The names and URIs are all fully distinct - overlapping names/uris are dealt with in other tests. */ public void testPrefixMappingMapping() { String toast = "ftp://ftp.nowhere.not/"; assertDiffer( "crisp and toast must differ", crispURI, toast ); /* */ PrefixMapping ns = getMapping(); assertEquals( "crisp should be unset", null, ns.getNsPrefixURI( "crisp" ) ); assertEquals( "toast should be unset", null, ns.getNsPrefixURI( "toast" ) ); assertEquals( "butter should be unset", null, ns.getNsPrefixURI( "butter" ) ); /* */ ns.setNsPrefix( "crisp", crispURI ); assertEquals( "crisp should be set", crispURI, ns.getNsPrefixURI( "crisp" ) ); assertEquals( "toast should still be unset", null, ns.getNsPrefixURI( "toast" ) ); assertEquals( "butter should still be unset", null, ns.getNsPrefixURI( "butter" ) ); /* */ ns.setNsPrefix( "toast", toast ); assertEquals( "crisp should be set", crispURI, ns.getNsPrefixURI( "crisp" ) ); assertEquals( "toast should be set", toast, ns.getNsPrefixURI( "toast" ) ); assertEquals( "butter should still be unset", null, ns.getNsPrefixURI( "butter" ) ); }
/** test that we can extract a proper Map from a PrefixMapping */ public void testPrefixMappingMap() { PrefixMapping ns = getCrispyRope(); Map<String, String> map = ns.getNsPrefixMap(); assertEquals( "map should have two elements", 2, map.size() ); assertEquals( crispURI, map.get( "crisp" ) ); assertEquals( "scheme:rope/string#", map.get( "rope" ) ); }
protected void testEquals( String S, String T, boolean expected, PrefixMapping A, PrefixMapping B ) { fill( A, S ); fill( B, T ); String title = "usual: '" + S + "', testing: '" + T + "', should be " + (expected ? "equal" : "different"); assertEquals( title, expected, A.samePrefixMappingAs( B ) ); assertEquals( title, expected, B.samePrefixMappingAs( A ) ); }
public void testReturnsSelf() { PrefixMapping A = getMapping(); assertSame( A, A.setNsPrefix( "crisp", crispURI ) ); assertSame( A, A.setNsPrefixes( A ) ); assertSame( A, A.setNsPrefixes( new HashMap<String, String>() ) ); assertSame( A, A.removeNsPrefix( "rhubarb" ) ); }
/** as for testAddOtherPrefixMapping, except that it's a plain Map we're adding. */ public void testAddMap() { PrefixMapping b = getMapping(); Map<String, String> map = new HashMap<>(); map.put( "crisp", crispURI ); map.put( "rope", ropeURI ); b.setNsPrefix( "butter", butterURI ); b.setNsPrefixes( map ); checkContainsMapping( b ); }
private void checkContainsMapping( PrefixMapping b ) { assertEquals( crispURI, b.getNsPrefixURI( "crisp") ); assertEquals( ropeURI, b.getNsPrefixURI( "rope") ); assertEquals( butterURI, b.getNsPrefixURI( "butter") ); }
public void testAllowNastyNamespace() { // we now allow namespaces to end with non-punctuational characters getMapping().setNsPrefix( "abc", "def" ); }
public void testNullURITrapped() { try { getMapping().setNsPrefix( "xy", null ); fail( "should trap null URI in setNsPrefix" ); } catch (NullPointerException e) { pass(); } }
/** test that we can add the maplets from another PrefixMapping without losing our own. */ public void testAddOtherPrefixMapping() { PrefixMapping a = getMapping(); PrefixMapping b = getMapping(); assertFalse( "must have two diffferent maps", a == b ); a.setNsPrefix( "crisp", crispURI ); a.setNsPrefix( "rope", ropeURI ); b.setNsPrefix( "butter", butterURI ); assertEquals( null, b.getNsPrefixURI( "crisp") ); assertEquals( null, b.getNsPrefixURI( "rope") ); b.setNsPrefixes( a ); checkContainsMapping( b ); }
public void testUseEasyPrefix() { testUseEasyPrefix( "prefix mapping impl", getMapping() ); testShortForm( "prefix mapping impl", getMapping() ); }
public void testAddDefaultMap() { PrefixMapping pm = getMapping(); PrefixMapping root = PrefixMapping.Factory.create(); pm.setNsPrefix( "a", "aPrefix:" ); pm.setNsPrefix( "b", "bPrefix:" ); root.setNsPrefix( "a", "pootle:" ); root.setNsPrefix( "z", "bPrefix:" ); root.setNsPrefix( "c", "cootle:" ); assertSame( pm, pm.withDefaultMappings( root ) ); assertEquals( "aPrefix:", pm.getNsPrefixURI( "a" ) ); assertEquals( null, pm.getNsPrefixURI( "z" ) ); assertEquals( "bPrefix:", pm.getNsPrefixURI( "b" ) ); assertEquals( "cootle:", pm.getNsPrefixURI( "c" ) ); }
/** test that a PrefixMapping maps names to URIs. The names and URIs are all fully distinct - overlapping names/uris are dealt with in other tests. */ public void testPrefixMappingMapping() { String toast = "ftp://ftp.nowhere.not/"; assertDiffer( "crisp and toast must differ", crispURI, toast ); /* */ PrefixMapping ns = getMapping(); assertEquals( "crisp should be unset", null, ns.getNsPrefixURI( "crisp" ) ); assertEquals( "toast should be unset", null, ns.getNsPrefixURI( "toast" ) ); assertEquals( "butter should be unset", null, ns.getNsPrefixURI( "butter" ) ); /* */ ns.setNsPrefix( "crisp", crispURI ); assertEquals( "crisp should be set", crispURI, ns.getNsPrefixURI( "crisp" ) ); assertEquals( "toast should still be unset", null, ns.getNsPrefixURI( "toast" ) ); assertEquals( "butter should still be unset", null, ns.getNsPrefixURI( "butter" ) ); /* */ ns.setNsPrefix( "toast", toast ); assertEquals( "crisp should be set", crispURI, ns.getNsPrefixURI( "crisp" ) ); assertEquals( "toast should be set", toast, ns.getNsPrefixURI( "toast" ) ); assertEquals( "butter should still be unset", null, ns.getNsPrefixURI( "butter" ) ); }