use of org.apache.jena.util.FileManager in project jena by apache.
the class TestFileManager method testFileManagerNoFile.
@Test
public void testFileManagerNoFile() {
FileManager fileManager = FileManager.create();
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) {
}
}
use of org.apache.jena.util.FileManager in project jena by apache.
the class TestFileManager method testFileManagerLocatorZipNonFound.
@Test
public void testFileManagerLocatorZipNonFound() {
FileManager fileManager = FileManager.create();
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) {
}
}
use of org.apache.jena.util.FileManager in project jena by apache.
the class TestFileManager method testLocationMappingURLtoFileOpen.
@Test
public void testLocationMappingURLtoFileOpen() {
LocationMapper locMap = new LocationMapper(TestLocationMapper.mapping);
FileManager fileManager = FileManager.create(locMap);
fileManager.addLocatorFile();
InputStream in = fileManager.open("http://example.org/file");
assertNotNull(in);
closeInputStream(in);
}
use of org.apache.jena.util.FileManager in project jena by apache.
the class TestFileManager method testCache3.
@Test
public void testCache3() {
FileManager fileManager = FileManager.getInternal();
fileManager.addLocatorFile(testingDir);
fileManager.setModelCaching(true);
Model m1 = fileManager.loadModelInternal(fileModel);
Model m2 = fileManager.loadModelInternal(fileModel);
assertSame(m1, m2);
fileManager.removeCacheModel(fileModel);
Model m3 = fileManager.loadModelInternal(fileModel);
assertNotSame(m1, m3);
fileManager.resetCache();
Model m4 = fileManager.loadModelInternal(fileModel);
Model m5 = fileManager.loadModelInternal(fileModel);
assertSame(m4, m5);
assertNotSame(m1, m4);
assertNotSame(m3, m4);
}
use of org.apache.jena.util.FileManager in project jena by apache.
the class TestFileManager method testFileManagerNoFile3.
@Test(expected = NotFoundException.class)
public void testFileManagerNoFile3() {
FileManager fileManager = new AdapterFileManager(new StreamManager(), new org.apache.jena.riot.system.stream.LocationMapper());
fileManager.addLocatorFile();
fileManager.readModelInternal(ModelFactory.createDefaultModel(), filenameNonExistent);
}
Aggregations