Search in sources :

Example 11 with FileManager

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

the class TestFileManager method testFileManagerFileLocatorWithDir.

public void testFileManagerFileLocatorWithDir() {
    FileManager fileManager = new FileManager();
    fileManager.addLocatorFile(testingDir);
    InputStream in = fileManager.open(filename);
    assertNotNull(in);
    closeInputStream(in);
}
Also used : InputStream(java.io.InputStream) FileManager(org.apache.jena.util.FileManager)

Example 12 with FileManager

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

the class TestFileManager method testFileManagerLocatorZip.

public void testFileManagerLocatorZip() {
    FileManager fileManager = new FileManager();
    try {
        fileManager.addLocatorZip(zipname);
    } catch (Exception ex) {
        fail("Failed to create a filemanager and add a zip locator");
    }
    InputStream in = fileManager.open(filename);
    assertNotNull(in);
    closeInputStream(in);
}
Also used : InputStream(java.io.InputStream) FileManager(org.apache.jena.util.FileManager) NotFoundException(org.apache.jena.shared.NotFoundException)

Example 13 with FileManager

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

the class TestFileManager method testFileManagerClone.

public void testFileManagerClone() {
    FileManager fileManager1 = new FileManager();
    FileManager fileManager2 = fileManager1.clone();
    // Should not affect fileManager2
    fileManager1.addLocatorFile();
    {
        InputStream in = fileManager1.open(testingDir + "/" + filename);
        assertNotNull(in);
        closeInputStream(in);
    }
    // Should not work.
    try {
        InputStream in = fileManager2.open(testingDir + "/" + filename);
        closeInputStream(in);
        assertNull("Found file via wrong FileManager", in);
    } catch (NotFoundException ex) {
    }
}
Also used : InputStream(java.io.InputStream) NotFoundException(org.apache.jena.shared.NotFoundException) FileManager(org.apache.jena.util.FileManager)

Example 14 with FileManager

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

the class TestFileManager method testFileManagerLocatorClassLoader.

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)

Example 15 with FileManager

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

the class TestFileManager method testFileManagerLocatorZipNonFound.

public void testFileManagerLocatorZipNonFound() {
    FileManager fileManager = new FileManager();
    try {
        fileManager.addLocatorZip(zipname);
    } catch (Exception ex) {
        fail("Failed to create a filemanager and add a zip locator");
    }
    try {
        InputStream in = fileManager.open(filenameNonExistent);
        closeInputStream(in);
        assertNull("Found non-existant zip file member", in);
    } catch (NotFoundException ex) {
    }
}
Also used : InputStream(java.io.InputStream) NotFoundException(org.apache.jena.shared.NotFoundException) FileManager(org.apache.jena.util.FileManager) NotFoundException(org.apache.jena.shared.NotFoundException)

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