use of org.apache.jena.shared.NotFoundException in project jena by apache.
the class SSE method readFile.
/** Read a file and obtain an SSE item expression */
public static Item readFile(String filename, PrefixMapping pmap) {
FileInputStream in = null;
try {
in = new FileInputStream(filename);
long len = in.getChannel().size();
if (len == 0)
return Item.nil;
return parse(in, pmap);
} catch (FileNotFoundException ex) {
throw new NotFoundException("Not found: " + filename);
} catch (IOException ex) {
throw new ARQException("IOExeption: " + filename, ex);
} finally {
IO.close(in);
}
}
use of org.apache.jena.shared.NotFoundException in project jena by apache.
the class TestFileManager method testFileManagerLocatorClassLoaderNotFound.
@Test
public void testFileManagerLocatorClassLoaderNotFound() {
FileManager fileManager = new FileManager();
fileManager.addLocatorClassLoader(fileManager.getClass().getClassLoader());
try {
InputStream in = fileManager.open("not/java/lang/String.class");
closeInputStream(in);
assertNull("Found non-existant class", in);
} catch (NotFoundException ex) {
}
}
use of org.apache.jena.shared.NotFoundException 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) {
}
}
use of org.apache.jena.shared.NotFoundException in project jena by apache.
the class TestFileManager method testFileManagerLocatorClassLoaderNotFound.
public void testFileManagerLocatorClassLoaderNotFound() {
FileManager fileManager = new FileManager();
fileManager.addLocatorClassLoader(fileManager.getClass().getClassLoader());
try {
InputStream in = fileManager.open("not/java/lang/String.class");
closeInputStream(in);
assertNull("Found non-existant class", in);
} catch (NotFoundException ex) {
}
}
use of org.apache.jena.shared.NotFoundException in project jena by apache.
the class TestFileManager method testFileManagerNoFile.
public void testFileManagerNoFile() {
FileManager fileManager = new FileManager();
fileManager.addLocatorFile();
try {
// Tests either way round - exception or a null return.
InputStream in = fileManager.open(filenameNonExistent);
closeInputStream(in);
assertNull("Found non-existant file: " + filenameNonExistent, in);
} catch (NotFoundException ex) {
}
}
Aggregations