use of org.apache.stanbol.entityhub.indexing.core.source.ResourceLoader in project stanbol by apache.
the class ResourceLoaderTest method isFailedOnError.
private boolean isFailedOnError(boolean failOnError) {
String folder = rootDir + TEST_FOLDER_NAME;
boolean failed = false;
DummyResourceImporter importer = new DummyResourceImporter(Arrays.asList(folder + "errorFileInFolder.txt"));
ResourceLoader loader = new ResourceLoader(importer, false, failOnError);
loader.addResource(new File(folder, "errorFileInFolder.txt"));
try {
loader.loadResources();
} catch (IllegalStateException ex) {
failed = true;
}
return failed;
}
use of org.apache.stanbol.entityhub.indexing.core.source.ResourceLoader in project stanbol by apache.
the class ResourceLoaderTest method testFolderWithProcessingArchives.
@Test
public void testFolderWithProcessingArchives() {
String folder = rootDir + TEST_FOLDER_NAME;
Collection<String> expectedResources = new HashSet<String>(Arrays.asList(folder + "archiveInFolder.zip", folder + "archiveWithIgnore.zip", folder + "archiveWithError.zip", folder + "errorFileInFolder.txt", folder + "fileInFolder.txt", folder + "ignoreFileInFolder.txt", folder + "otherFileInFolder.txt"));
//the resourceNames send to the importer are now different because the
//archives are processed and the entries are sent to the ResourceImporter
Collection<String> expectedResourceNames = Arrays.asList(//part of archiveInFolder.zip
"fileInArchive.txt", //part of archiveInFolder.zip
"otherFileInArchive.txt", //part of archiveWithIgnore.zip
"ignoreFileInArchive.txt", //part of archiveWithError.zip
"errorFileInArchive.txt", "errorFileInFolder.txt", "fileInFolder.txt", "ignoreFileInFolder.txt", "otherFileInFolder.txt");
DummyResourceImporter importer = new DummyResourceImporter(expectedResourceNames);
ResourceLoader loader = new ResourceLoader(importer, true, false);
loader.addResource(new File(rootDir, TEST_FOLDER_NAME));
assertEquals(expectedResources, loader.getResources(ResourceState.REGISTERED));
assertTrue(loader.getResources(ResourceState.ERROR).isEmpty());
assertTrue(loader.getResources(ResourceState.LOADED).isEmpty());
assertTrue(loader.getResources(ResourceState.IGNORED).isEmpty());
loader.loadResources();
assertEquals(new HashSet<String>(Arrays.asList(folder + "archiveInFolder.zip", //ignored files in archives are OK
folder + "archiveWithIgnore.zip", folder + "fileInFolder.txt", folder + "otherFileInFolder.txt")), loader.getResources(ResourceState.LOADED));
assertTrue(loader.getResources(ResourceState.REGISTERED).isEmpty());
assertEquals(new HashSet<String>(Arrays.asList(folder + "errorFileInFolder.txt", //archive with errors MUST be ERROR
folder + "archiveWithError.zip")), loader.getResources(ResourceState.ERROR));
assertEquals(new HashSet<String>(Arrays.asList(folder + "ignoreFileInFolder.txt")), loader.getResources(ResourceState.IGNORED));
}
Aggregations