use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestSSE_Forms method beforeClass.
@BeforeClass
public static void beforeClass() {
original = SSE.getPrefixMapRead();
PrefixMapping pmaptest = new PrefixMappingImpl().setNsPrefixes(original).removeNsPrefix("").removeNsPrefix("ex");
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestPrefixMappingUtils method prefixesTTL4.
@Test
public void prefixesTTL4() {
// No prefixes.
String data = StrUtils.strjoinNL("<http://other/s1> <http://example/p> 123 .");
Graph graph1 = create(data);
PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMappingTTL(graph1);
Assert.assertEquals(0, size(pmap));
PrefixMapping pmapExpected = new PrefixMappingImpl();
Assert.assertTrue(sameMapping(pmapExpected, pmap));
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestPrefixMappingUtils method prefixesTTL3.
@Test
public void prefixesTTL3() {
// Some URIs without prefixes.
String data = StrUtils.strjoinNL("@prefix : <http://example/> .", "", "<http://other/s1> :p :x1 .");
Graph graph1 = create(data);
PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMappingTTL(graph1);
PrefixMapping pmapExpected = new PrefixMappingImpl();
pmapExpected.setNsPrefix("", "http://example/");
Assert.assertTrue(sameMapping(pmapExpected, pmap));
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestPrefixMappingUtils method prefixesTTL.
// No <<>> parser in jena-core.
@Test
public void prefixesTTL() {
// All combinations.
// No "@prefix xsd: <"+XSD.getURI()+"> ." so not in output.
String data = StrUtils.strjoinNL("@prefix : <http://example/> .", "@prefix ex: <http://example/ex#> .", "@prefix notinuse: <http://example/whatever/> .", "@prefix indirect: <urn:foo:> .", "@prefix indirectx: <urn:x:> .", "@prefix ns: <http://host/ns> .", "@prefix ns1: <http://host/ns1> .", "@prefix ns2: <http://host/nspace> .", "", ":s1 :p :x1 .", ":s1 ex:p :x1 .", "<urn:foo:bar> :p 1 . ", "<urn:x:a:b> :p 2 . ", "<urn:verybad#.> :p 1 . ", "ns:x ns1:p 'ns1' . ", "<http://examp/abberev> indirect:p 'foo' . ");
Graph graph = create(data);
PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMappingTTL(graph);
PrefixMapping pmapExpected = new PrefixMappingImpl();
pmapExpected.setNsPrefix("", "http://example/");
pmapExpected.setNsPrefix("ex", "http://example/ex#");
pmapExpected.setNsPrefix("indirect", "urn:foo:");
// No : not a / or # split :: pmapExpected.setNsPrefix("ns", "http://host/ns") ;
// No : not a / or # split :: pmapExpected.setNsPrefix("ns1", "http://host/ns1") ;
// No : not a match: split is wrong :: pmapExpected.setNsPrefix("indirectx", "urn:x:") ;
// print("Expected:", pmapExpected) ;
// print("Got:", pmap) ;
Assert.assertTrue(sameMapping(pmapExpected, pmap));
Assert.assertTrue(pmap.getNsPrefixURI("notinuse") == null);
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestPrefixMappingUtils method prefixes2.
@Test
public void prefixes2() {
// Some prefixes used
String data2 = StrUtils.strjoinNL("@prefix : <http://example/> .", "@prefix ex: <http://example/ex#> .", "@prefix notinuse: <http://example/whatever/> .", "", ":s1 :p :x1 .", ":s1 ex:p :x1 .");
Graph graph1 = create(data2);
PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMapping(graph1);
PrefixMapping pmapExpected = new PrefixMappingImpl();
pmapExpected.setNsPrefix("", "http://example/");
pmapExpected.setNsPrefix("ex", "http://example/ex#");
Assert.assertEquals(2, size(pmap));
Assert.assertTrue(sameMapping(pmapExpected, pmap));
Assert.assertTrue(pmap.getNsPrefixURI("notinuse") == null);
}
Aggregations