use of org.apache.jena.shared.PrefixMapping in project jena by apache.
the class AbstractTestPrefixMapping method testAddOtherPrefixMapping.
/**
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);
}
use of org.apache.jena.shared.PrefixMapping in project jena by apache.
the class AbstractTestPrefixMapping method testSecondPrefixReplacesReverseMap.
public void testSecondPrefixReplacesReverseMap() {
PrefixMapping A = getMapping();
A.setNsPrefix("a", crispURI);
A.setNsPrefix("b", crispURI);
assertEquals("b", A.getNsURIPrefix(crispURI));
}
use of org.apache.jena.shared.PrefixMapping in project jena by apache.
the class AbstractTestPrefixMapping method testAddDefaultMap.
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"));
}
use of org.apache.jena.shared.PrefixMapping in project jena by apache.
the class AbstractTestPrefixMapping method testEasyQName.
public void testEasyQName() {
PrefixMapping ns = getMapping();
String alphaURI = "http://seasonal.song/preamble/";
ns.setNsPrefix("alpha", alphaURI);
assertEquals("alpha:rowboat", ns.qnameFor(alphaURI + "rowboat"));
}
use of org.apache.jena.shared.PrefixMapping in project jena by apache.
the class AbstractTestPrefixMapping method testReversePrefixMapping.
/**
Test that we can run the prefix mapping in reverse - from URIs to prefixes.
uriB is a prefix of uriA to try and ensure that the ordering of the map doesn't matter.
*/
public void testReversePrefixMapping() {
PrefixMapping ns = getMapping();
String uriA = "http://jena.hpl.hp.com/A#", uriB = "http://jena.hpl.hp.com/";
String uriC = "http://jena.hpl.hp.com/Csharp/";
String prefixA = "aa", prefixB = "bb";
ns.setNsPrefix(prefixA, uriA).setNsPrefix(prefixB, uriB);
assertEquals(null, ns.getNsURIPrefix(uriC));
assertEquals(prefixA, ns.getNsURIPrefix(uriA));
assertEquals(prefixB, ns.getNsURIPrefix(uriB));
}
Aggregations