Search in sources :

Example 31 with PrefixMappingImpl

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");
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) BeforeClass(org.junit.BeforeClass)

Example 32 with PrefixMappingImpl

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));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) Test(org.junit.Test)

Example 33 with PrefixMappingImpl

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));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) Test(org.junit.Test)

Example 34 with PrefixMappingImpl

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);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) Test(org.junit.Test)

Example 35 with PrefixMappingImpl

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);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Graph(org.apache.jena.graph.Graph) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) Test(org.junit.Test)

Aggregations

PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)39 PrefixMapping (org.apache.jena.shared.PrefixMapping)34 Test (org.junit.Test)13 Path (org.apache.jena.sparql.path.Path)11 Graph (org.apache.jena.graph.Graph)8 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)4 TriplePath (org.apache.jena.sparql.core.TriplePath)4 ElementPathBlock (org.apache.jena.sparql.syntax.ElementPathBlock)4 BeforeClass (org.junit.BeforeClass)4 ElementOptional (org.apache.jena.sparql.syntax.ElementOptional)3 ContractTest (org.xenei.junit.contract.ContractTest)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Triple (org.apache.jena.graph.Triple)2 Dataset (org.apache.jena.query.Dataset)2 Date (java.util.Date)1 Trie (org.apache.jena.atlas.lib.Trie)1 SecuredPrefixMapping (org.apache.jena.permissions.graph.SecuredPrefixMapping)1 Query (org.apache.jena.query.Query)1 UpdateDeniedException (org.apache.jena.shared.UpdateDeniedException)1