Search in sources :

Example 21 with FileManager

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

the class TestFileManager method testCache2.

@Test
public void testCache2() {
    FileManager.setGlobalFileManager(AdapterFileManager.get());
    FileManager fileManager = FileManager.get();
    fileManager.addLocatorFile(testingDir);
    fileManager.setModelCaching(true);
    Model m1 = fileManager.loadModel(fileModel);
    Model m2 = fileManager.loadModel(fileModel);
    assertSame(m1, m2);
}
Also used : OntModel(org.apache.jena.ontology.OntModel) Model(org.apache.jena.rdf.model.Model) FileManager(org.apache.jena.util.FileManager) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 22 with FileManager

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

the class TestFileManager method testFileManagerLocatorClassLoader.

@Test
public void testFileManagerLocatorClassLoader() {
    FileManager fileManager = new FileManager();
    fileManager.addLocatorClassLoader(fileManager.getClass().getClassLoader());
    InputStream in = fileManager.open("java/lang/String.class");
    assertNotNull(in);
    closeInputStream(in);
}
Also used : InputStream(java.io.InputStream) FileManager(org.apache.jena.util.FileManager) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 23 with FileManager

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

the class TestFileManager method testLocationMappingURLtoFileOpenNotFound.

@Test
public void testLocationMappingURLtoFileOpenNotFound() {
    LocationMapper locMap = new LocationMapper(TestLocationMapper.mapping);
    FileManager fileManager = new FileManager(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) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 24 with FileManager

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

the class TestDocumentManagerAssembler method testUsesFileManager.

public void testUsesFileManager() {
    Resource root = resourceInModel("x rdf:type ja:DocumentManager; x ja:fileManager f");
    Assembler a = new DocumentManagerAssembler();
    FileManager fm = new FileManager();
    Assembler mock = new NamedObjectAssembler(resource("f"), fm);
    Object x = a.open(mock, root);
    assertInstanceOf(OntDocumentManager.class, x);
    assertSame(fm, ((OntDocumentManager) x).getFileManager());
}
Also used : DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) FileManager(org.apache.jena.util.FileManager)

Example 25 with FileManager

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

the class TestImportManager method testFollowOwlImports.

public void testFollowOwlImports() {
    final Model modelToLoad = model("this hasMarker B5");
    Model m = model("x ja:reasoner y; _x owl:imports eh:/loadMe");
    FileManager fm = new FixedFileManager().add("eh:/loadMe", modelToLoad);
    Model m2 = new ImportManager().withImports(fm, m);
    assertInstanceOf(MultiUnion.class, m2.getGraph());
    assertIsoModels(modelToLoad.union(m), m2);
}
Also used : Model(org.apache.jena.rdf.model.Model) FileManager(org.apache.jena.util.FileManager)

Aggregations

FileManager (org.apache.jena.util.FileManager)35 InputStream (java.io.InputStream)21 BaseTest (org.apache.jena.atlas.junit.BaseTest)13 Test (org.junit.Test)13 Model (org.apache.jena.rdf.model.Model)12 NotFoundException (org.apache.jena.shared.NotFoundException)12 LocationMapper (org.apache.jena.util.LocationMapper)4 OntModel (org.apache.jena.ontology.OntModel)3 TestLocationMapper (org.apache.jena.riot.stream.TestLocationMapper)2 File (java.io.File)1 DocumentManagerAssembler (org.apache.jena.assembler.assemblers.DocumentManagerAssembler)1 JenaException (org.apache.jena.shared.JenaException)1