Search in sources :

Example 11 with PrefixMapping

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

the class AbstractTestPrefixMapping method testPrefixMappingSecret.

/**
       test that the Map returned by getNsPrefixMap does not alias (parts of)
       the secret internal map of the PrefixMapping
    */
public void testPrefixMappingSecret() {
    PrefixMapping ns = getCrispyRope();
    Map<String, String> map = ns.getNsPrefixMap();
    /* */
    map.put("crisp", "with/onions");
    map.put("sandwich", "with/cheese");
    assertEquals(crispURI, ns.getNsPrefixURI("crisp"));
    assertEquals(ropeURI, ns.getNsPrefixURI("rope"));
    assertEquals(null, ns.getNsPrefixURI("sandwich"));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 12 with PrefixMapping

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

the class AbstractTestPrefixMapping method testSecondPrefixDeletedUncoversPreviousMap.

public void testSecondPrefixDeletedUncoversPreviousMap() {
    PrefixMapping A = getMapping();
    A.setNsPrefix("x", crispURI);
    A.setNsPrefix("y", crispURI);
    A.removeNsPrefix("y");
    assertEquals("x", A.getNsURIPrefix(crispURI));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 13 with PrefixMapping

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

the class AbstractTestPrefixMapping method testNoQNameBadLocal.

public void testNoQNameBadLocal() {
    PrefixMapping ns = getMapping();
    String alphaURI = "http://seasonal.song/preamble/";
    ns.setNsPrefix("alpha", alphaURI);
    assertEquals(null, ns.qnameFor(alphaURI + "12345"));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 14 with PrefixMapping

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

the class AbstractTestPrefixMapping method testCheckNames.

/**
        Test that various illegal names are trapped.
    */
public void testCheckNames() {
    PrefixMapping ns = getMapping();
    for (String bad : badNames) {
        try {
            ns.setNsPrefix(bad, crispURI);
            fail("'" + bad + "' is an illegal prefix and should be trapped");
        } catch (PrefixMapping.IllegalPrefixException e) {
            pass();
        }
    }
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 15 with PrefixMapping

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

the class AbstractTestPrefixMapping method testReturnsSelf.

public void testReturnsSelf() {
    PrefixMapping A = getMapping();
    assertSame(A, A.setNsPrefix("crisp", crispURI));
    assertSame(A, A.setNsPrefixes(A));
    assertSame(A, A.setNsPrefixes(new HashMap<String, String>()));
    assertSame(A, A.removeNsPrefix("rhubarb"));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) HashMap(java.util.HashMap)

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