Search in sources :

Example 21 with LocationMapper

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

the class TestFileManager method testLocationMappingURLtoFileOpenNotFound.

@Test
public void testLocationMappingURLtoFileOpenNotFound() {
    LocationMapper locMap = new LocationMapper(TestLocationMapper.mapping);
    FileManager fileManager = FileManager.create(locMap);
    fileManager.addLocatorClassLoader(fileManager.getClass().getClassLoader());
    try {
        InputStream in = fileManager.open("http://example.org/file");
        closeInputStream(in);
        assertNull("Found nont-existant URL", null);
    } catch (NotFoundException ex) {
    }
}
Also used : InputStream(java.io.InputStream) NotFoundException(org.apache.jena.shared.NotFoundException) LocationMapper(org.apache.jena.util.LocationMapper) TestLocationMapper(org.apache.jena.riot.stream.TestLocationMapper) FileManager(org.apache.jena.util.FileManager) Test(org.junit.Test)

Example 22 with LocationMapper

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

the class TestGenericRules method testIncludeRedirect.

/**
 * Test that @include supports fileManger redirections
 */
public void testIncludeRedirect() {
    assertFalse(checkIncludeFound("file:testing/reasoners/importTest.rules"));
    LocationMapper lm = FileManager.getInternal().getLocationMapper();
    lm.addAltEntry("file:testing/reasoners/includeAlt.rules", "file:testing/reasoners/include.rules");
    assertTrue(checkIncludeFound("file:testing/reasoners/importTest.rules"));
    lm.removeAltEntry("file:testing/reasoners/includeAlt.rules");
}
Also used : LocationMapper(org.apache.jena.util.LocationMapper)

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