Search in sources :

Example 6 with NotFoundException

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

the class TestFileManager method testFileManagerClone.

@Test
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) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 7 with NotFoundException

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

the class ModResultsIn method getResultSet.

public ResultSet getResultSet() {
    if (resultSet != null)
        return resultSet;
    if (resultsFilename == null) {
        System.err.println("No result file name");
        throw new TerminationException(1);
    }
    try {
        if (resultsFilename.equals("-"))
            return ResultSetFactory.load(System.in, inputFormat);
        ResultSet rs = ResultSetFactory.load(resultsFilename, inputFormat);
        if (rs == null) {
            System.err.println("Failed to read the result set");
            throw new TerminationException(9);
        }
        resultSet = rs;
        return resultSet;
    } catch (NotFoundException ex) {
        System.err.println("File not found: " + resultsFilename);
        throw new TerminationException(9);
    } catch (ARQInternalErrorException intEx) {
        System.err.println(intEx.getMessage());
        if (intEx.getCause() != null) {
            System.err.println("Cause:");
            intEx.getCause().printStackTrace(System.err);
            System.err.println();
        }
        intEx.printStackTrace(System.err);
        throw new TerminationException(99);
    }
}
Also used : TerminationException(jena.cmd.TerminationException) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException) ResultSet(org.apache.jena.query.ResultSet) NotFoundException(org.apache.jena.shared.NotFoundException)

Example 8 with NotFoundException

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

the class TestFileManager method testLocationMappingURLtoFileOpenNotFound.

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) FileManager(org.apache.jena.util.FileManager)

Example 9 with NotFoundException

use of org.apache.jena.shared.NotFoundException 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 10 with NotFoundException

use of org.apache.jena.shared.NotFoundException 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

NotFoundException (org.apache.jena.shared.NotFoundException)15 InputStream (java.io.InputStream)12 FileManager (org.apache.jena.util.FileManager)10 BaseTest (org.apache.jena.atlas.junit.BaseTest)5 Test (org.junit.Test)5 TerminationException (jena.cmd.TerminationException)2 LocationMapper (org.apache.jena.util.LocationMapper)2 ResultSet (org.apache.jena.query.ResultSet)1 Model (org.apache.jena.rdf.model.Model)1 TestLocationMapper (org.apache.jena.riot.stream.TestLocationMapper)1 SDBException (org.apache.jena.sdb.SDBException)1 ARQException (org.apache.jena.sparql.ARQException)1 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)1