public void testNoQNameNoPrefix() { PrefixMapping ns = getMapping(); String alphaURI = "http://seasonal.song/preamble/"; ns.setNsPrefix( "alpha", alphaURI ); assertEquals( null, ns.qnameFor( "eg:rowboat" ) ); }
public void testNoMapping() { String hURI = "http://test.prefixes/prefix#"; PrefixMapping A = getMapping(); assertTrue(A.hasNoMappings()) ; A.setNsPrefix( "hr", hURI ); assertFalse(A.hasNoMappings()) ; }
public void testSecondPrefixRetainsExistingMap() { PrefixMapping A = getMapping(); A.setNsPrefix( "a", crispURI ); A.setNsPrefix( "b", crispURI ); assertEquals( crispURI, A.getNsPrefixURI( "a" ) ); assertEquals( crispURI, A.getNsPrefixURI( "b" ) ); }
public void testSecondPrefixReplacesReverseMap() { PrefixMapping A = getMapping(); A.setNsPrefix( "a", crispURI ); A.setNsPrefix( "b", crispURI ); assertEquals( "b", A.getNsURIPrefix( crispURI ) ); }
public static void testShortForm( String title, PrefixMapping ns ) { ns.setNsPrefix( "crisp", crispURI ); ns.setNsPrefix( "butter", butterURI ); assertEquals( title, "", ns.shortForm( "" ) ); assertEquals( title, ropeURI, ns.shortForm( ropeURI ) ); assertEquals( title, "crisp:tail", ns.shortForm( crispURI + "tail" ) ); assertEquals( title, "butter:here:we:are", ns.shortForm( butterURI + "here:we:are" ) ); }
public void testNumPrefixes() { String hURI = "http://test.prefixes/prefix#"; PrefixMapping A = getMapping(); assertEquals(0, A.numPrefixes()) ; A.setNsPrefix( "hr", hURI ); assertEquals(1, A.numPrefixes()) ; }
public void testNullURITrapped() { try { getMapping().setNsPrefix( "xy", null ); fail( "should trap null URI in setNsPrefix" ); } catch (NullPointerException e) { pass(); } }
private PrefixMapping getCrispyRope() { PrefixMapping ns = getMapping(); ns.setNsPrefix( "crisp", crispURI); ns.setNsPrefix( "rope", ropeURI ); return ns; }
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 testRemovePrefix() { String hURI = "http://test.remove.prefixes/prefix#"; String bURI = "http://other.test.remove.prefixes/prefix#"; PrefixMapping A = getMapping(); A.setNsPrefix( "hr", hURI ); A.setNsPrefix( "br", bURI ); A.removeNsPrefix( "hr" ); assertEquals( null, A.getNsPrefixURI( "hr" ) ); assertEquals( bURI, A.getNsPrefixURI( "br" ) ); }
public void testSecondPrefixDeletedUncoversPreviousMap() { PrefixMapping A = getMapping(); A.setNsPrefix( "x", crispURI ); A.setNsPrefix( "y", crispURI ); A.removeNsPrefix( "y" ); assertEquals( "x", A.getNsURIPrefix( crispURI ) ); }
/** The tests implied by the email where Chris suggested adding qnameFor; shortForm generates illegal qnames but qnameFor does not. */ public void testQnameFromEmail() { String uri = "http://some.long.uri/for/a/namespace#"; PrefixMapping ns = getMapping(); ns.setNsPrefix( "x", uri ); assertEquals( null, ns.qnameFor( uri ) ); assertEquals( null, ns.qnameFor( uri + "non/fiction" ) ); }
public static void testShortForm( String title, PrefixMapping ns ) { ns.setNsPrefix( "crisp", crispURI ); ns.setNsPrefix( "butter", butterURI ); assertEquals( title, "", ns.shortForm( "" ) ); assertEquals( title, ropeURI, ns.shortForm( ropeURI ) ); assertEquals( title, "crisp:tail", ns.shortForm( crispURI + "tail" ) ); assertEquals( title, "butter:here:we:are", ns.shortForm( butterURI + "here:we:are" ) ); }
public void testNullURITrapped() { try { getMapping().setNsPrefix( "xy", null ); fail( "should trap null URI in setNsPrefix" ); } catch (NullPointerException e) { pass(); } }
private PrefixMapping getCrispyRope() { PrefixMapping ns = getMapping(); ns.setNsPrefix( "crisp", crispURI); ns.setNsPrefix( "rope", ropeURI ); return ns; }
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 ) ); }
/** 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 testNoQNameBadLocal() { PrefixMapping ns = getMapping(); String alphaURI = "http://seasonal.song/preamble/"; ns.setNsPrefix( "alpha", alphaURI ); assertEquals( null, ns.qnameFor( alphaURI + "12345" ) ); }
public void testRemovePrefix() { String hURI = "http://test.remove.prefixes/prefix#"; String bURI = "http://other.test.remove.prefixes/prefix#"; PrefixMapping A = getMapping(); A.setNsPrefix( "hr", hURI ); A.setNsPrefix( "br", bURI ); A.removeNsPrefix( "hr" ); assertEquals( null, A.getNsPrefixURI( "hr" ) ); assertEquals( bURI, A.getNsPrefixURI( "br" ) ); }
/** Test that the empty prefix does not wipe an existing prefix for the same URI. */ public void testEmptyDoesNotWipeURI() { PrefixMapping pm = getMapping(); pm.setNsPrefix( "frodo", ropeURI ); pm.setNsPrefix( "", ropeURI ); assertEquals( ropeURI, pm.getNsPrefixURI( "frodo" ) ); }