Search in sources :

Example 6 with LocationMapper

use of org.apache.jena.util.LocationMapper in project jena by apache.

the class TestFileManager method testLocationMappingURLtoFileOpen.

@Test
public void testLocationMappingURLtoFileOpen() {
    LocationMapper locMap = new LocationMapper(TestLocationMapper.mapping);
    FileManager fileManager = FileManager.create(locMap);
    fileManager.addLocatorFile();
    InputStream in = fileManager.open("http://example.org/file");
    assertNotNull(in);
    closeInputStream(in);
}
Also used : InputStream(java.io.InputStream) LocationMapper(org.apache.jena.util.LocationMapper) TestLocationMapper(org.apache.jena.riot.stream.TestLocationMapper) FileManager(org.apache.jena.util.FileManager) Test(org.junit.Test)

Example 7 with LocationMapper

use of org.apache.jena.util.LocationMapper in project jena by apache.

the class TestLocationMapper method testLocationMapperMiss.

@Test
public void testLocationMapperMiss() {
    LocationMapper locMap = new LocationMapper(mapping);
    String alt = locMap.altMapping(notFilename);
    assertNotNull(alt);
    assertEquals(notFilename, alt);
}
Also used : LocationMapper(org.apache.jena.util.LocationMapper) Test(org.junit.Test)

Example 8 with LocationMapper

use of org.apache.jena.util.LocationMapper in project jena by apache.

the class TestLocationMapper method testLocationMapperURLtoFile.

@Test
public void testLocationMapperURLtoFile() {
    LocationMapper locMap = new LocationMapper(mapping);
    String alt = locMap.altMapping("http://example.org/file");
    assertNotNull(alt);
    assertEquals("file:" + testingDir + "/location-mapping-test-file", alt);
}
Also used : LocationMapper(org.apache.jena.util.LocationMapper) Test(org.junit.Test)

Example 9 with LocationMapper

use of org.apache.jena.util.LocationMapper in project jena by apache.

the class TestLocationMapper method testLocationMapperToModel1.

@Test
public void testLocationMapperToModel1() {
    LocationMapper locMap1 = new LocationMapper(mapping);
    LocationMapper locMap2 = new LocationMapper(locMap1.toModel());
    assertEquals(locMap1, locMap2);
    assertEquals(locMap1.hashCode(), locMap2.hashCode());
}
Also used : LocationMapper(org.apache.jena.util.LocationMapper) Test(org.junit.Test)

Example 10 with LocationMapper

use of org.apache.jena.util.LocationMapper in project jena by apache.

the class TestLocationMapper method testLocationMapperClone1.

@Test
public void testLocationMapperClone1() {
    LocationMapper locMap1 = new LocationMapper(mapping);
    // See testLocationMapperURLtoFile
    // String alt = locMap.altMapping("http://example.org/file") ;
    // assertNotNull(alt) ;
    // assertEquals(alt, "file:"+testingDir+"/location-mapping-test-file") ;
    LocationMapper locMap2 = new LocationMapper(locMap1);
    // Remove from original
    locMap1.removeAltEntry("http://example.org/file");
    String alt = locMap2.altMapping("http://example.org/file");
    assertNotNull(alt);
    assertEquals("file:" + testingDir + "/location-mapping-test-file", alt);
}
Also used : LocationMapper(org.apache.jena.util.LocationMapper) Test(org.junit.Test)

Aggregations

LocationMapper (org.apache.jena.util.LocationMapper)22 Test (org.junit.Test)12 InputStream (java.io.InputStream)2 TestLocationMapper (org.apache.jena.riot.stream.TestLocationMapper)2 FileManager (org.apache.jena.util.FileManager)2 Model (org.apache.jena.rdf.model.Model)1 NotFoundException (org.apache.jena.shared.NotFoundException)1