Search in sources :

Example 16 with PrefixMapping

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

Example 17 with PrefixMapping

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

Example 18 with PrefixMapping

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

Example 19 with PrefixMapping

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

Example 20 with PrefixMapping

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

Aggregations

PrefixMapping (org.apache.jena.shared.PrefixMapping)154 Test (org.junit.Test)47 PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)34 Graph (org.apache.jena.graph.Graph)22 Path (org.apache.jena.sparql.path.Path)12 BaseTest (org.apache.jena.atlas.junit.BaseTest)11 Triple (org.apache.jena.graph.Triple)9 Resource (org.apache.jena.rdf.model.Resource)9 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 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 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)4 Dataset (org.apache.jena.query.Dataset)4