Search in sources :

Example 51 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class TestPrefixMappingUtils method prefixes3.

@Test
public void prefixes3() {
    // Some URIs without prefixes.
    String data = StrUtils.strjoinNL("@prefix : <http://example/> .", "", "<http://other/s1> :p :x1 .");
    Graph graph1 = create(data);
    PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMapping(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 52 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class TestPrefixMappingTDBExtra method persistent1.

// Persistent.
@Test
public void persistent1() {
    String dir = ConfigTest.getTestingDir();
    FileOps.clearAll(dir);
    DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(Location.create(dir));
    Txn.execute(dsg, () -> {
        PrefixMapping pmap1 = dsg.getDefaultGraph().getPrefixMapping();
        String x = pmap1.getNsPrefixURI("x");
        assertNull(x);
    });
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb2.ConfigTest)

Example 53 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class GraphContractTest method testGetPrefixMapping.

@ContractTest
public void testGetPrefixMapping() {
    Graph g = producer.newInstance();
    txnBegin(g);
    PrefixMapping pm = g.getPrefixMapping();
    assertNotNull("Must return prefix mapping", pm);
    assertSame("getPrefixMapping must always return the same object", pm, g.getPrefixMapping());
    txnRollback(g);
    pm.setNsPrefix("pfx1", "http://example.com/");
    pm.setNsPrefix("pfx2", "scheme:rope/string#");
    txnBegin(g);
    // assert same after adding to other mapl
    assertSame("getPrefixMapping must always return the same object", pm, g.getPrefixMapping());
    txnRollback(g);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) GraphHelper.memGraph(org.apache.jena.testing_framework.GraphHelper.memGraph) ContractTest(org.xenei.junit.contract.ContractTest)

Example 54 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class BuilderPrefixMapping method build.

public static PrefixMapping build(Item elt) {
    PrefixMapping pmap = new PrefixMappingImpl();
    build(pmap, elt);
    return pmap;
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl)

Example 55 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class TestFmtUtils method getPrefixMapping.

private PrefixMapping getPrefixMapping() {
    PrefixMapping pmap = new PrefixMappingImpl();
    pmap.setNsPrefix("zz", aUri);
    return pmap;
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl)

Aggregations

PrefixMapping (org.apache.jena.shared.PrefixMapping)149 Test (org.junit.Test)47 PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)29 Graph (org.apache.jena.graph.Graph)22 BaseTest (org.apache.jena.atlas.junit.BaseTest)11 Triple (org.apache.jena.graph.Triple)9 Resource (org.apache.jena.rdf.model.Resource)9 Path (org.apache.jena.sparql.path.Path)8 ConfigTest (org.apache.jena.tdb.ConfigTest)8 DatasetPrefixesTDB (org.apache.jena.tdb.store.DatasetPrefixesTDB)8 ContractTest (org.xenei.junit.contract.ContractTest)8 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)7 ArrayList (java.util.ArrayList)5 Node (org.apache.jena.graph.Node)5 Query (org.apache.jena.query.Query)5 Model (org.apache.jena.rdf.model.Model)5 PrefixMappingSDB (org.apache.jena.sdb.graph.PrefixMappingSDB)5 URI (java.net.URI)4 HashMap (java.util.HashMap)4 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)4