Search in sources :

Example 76 with PrefixMapping

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

the class AbstractTestPrefixMapping method testQnameFromEmail.

/**
        The tests implied by the email where Chris suggested adding qnameFor;
        shortForm generates illegal qnames but qnameFor does not.
    */
public void testQnameFromEmail() {
    String uri = "http://some.long.uri/for/a/namespace#";
    PrefixMapping ns = getMapping();
    ns.setNsPrefix("x", uri);
    assertEquals(null, ns.qnameFor(uri));
    assertEquals(null, ns.qnameFor(uri + "non/fiction"));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 77 with PrefixMapping

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

the class AbstractTestPrefixMapping method testPrefixMappingMapping.

/**
        test that a PrefixMapping maps names to URIs. The names and URIs are
        all fully distinct - overlapping names/uris are dealt with in other tests.
    */
public void testPrefixMappingMapping() {
    String toast = "ftp://ftp.nowhere.not/";
    assertDiffer("crisp and toast must differ", crispURI, toast);
    /* */
    PrefixMapping ns = getMapping();
    assertEquals("crisp should be unset", null, ns.getNsPrefixURI("crisp"));
    assertEquals("toast should be unset", null, ns.getNsPrefixURI("toast"));
    assertEquals("butter should be unset", null, ns.getNsPrefixURI("butter"));
    /* */
    ns.setNsPrefix("crisp", crispURI);
    assertEquals("crisp should be set", crispURI, ns.getNsPrefixURI("crisp"));
    assertEquals("toast should still be unset", null, ns.getNsPrefixURI("toast"));
    assertEquals("butter should still be unset", null, ns.getNsPrefixURI("butter"));
    /* */
    ns.setNsPrefix("toast", toast);
    assertEquals("crisp should be set", crispURI, ns.getNsPrefixURI("crisp"));
    assertEquals("toast should be set", toast, ns.getNsPrefixURI("toast"));
    assertEquals("butter should still be unset", null, ns.getNsPrefixURI("butter"));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 78 with PrefixMapping

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

the class AbstractTestPrefixMapping method testPrefixMappingMap.

/**
       test that we can extract a proper Map from a PrefixMapping
    */
public void testPrefixMappingMap() {
    PrefixMapping ns = getCrispyRope();
    Map<String, String> map = ns.getNsPrefixMap();
    assertEquals("map should have two elements", 2, map.size());
    assertEquals(crispURI, map.get("crisp"));
    assertEquals("scheme:rope/string#", map.get("rope"));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 79 with PrefixMapping

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

the class AbstractTestPrefixMapping method testEmptyPrefix.

/**
        The empty prefix is specifically allowed [for the default namespace].
    */
public void testEmptyPrefix() {
    PrefixMapping pm = getMapping();
    pm.setNsPrefix("", crispURI);
    assertEquals(crispURI, pm.getNsPrefixURI(""));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

Example 80 with PrefixMapping

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

the class AbstractTestPrefixMapping method testNoMapping.

public void testNoMapping() {
    String hURI = "http://test.prefixes/prefix#";
    PrefixMapping A = getMapping();
    assertTrue(A.hasNoMappings());
    A.setNsPrefix("hr", hURI);
    assertFalse(A.hasNoMappings());
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping)

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