use of org.apache.tika.batch.ParallelFileProcessingResult in project tika by apache.
the class OutputStreamFactoryTest method testSkip.
@Test
public void testSkip() throws Exception {
Path outputDir = getNewOutputDir("os-factory-skip-");
Map<String, String> args = getDefaultArgs("basic", outputDir);
args.put("handleExisting", "skip");
BatchProcess runner = getNewBatchRunner("/tika-batch-config-test.xml", args);
ParallelFileProcessingResult result = run(runner);
assertEquals(1, countChildren(outputDir));
runner = getNewBatchRunner("/tika-batch-config-test.xml", args);
result = run(runner);
assertEquals(1, countChildren(outputDir));
}
use of org.apache.tika.batch.ParallelFileProcessingResult in project tika by apache.
the class OutputStreamFactoryTest method testIllegalState.
@Test
public void testIllegalState() throws Exception {
Path outputDir = getNewOutputDir("os-factory-illegal-state-");
Map<String, String> args = getDefaultArgs("basic", outputDir);
BatchProcess runner = getNewBatchRunner("/tika-batch-config-test.xml", args);
run(runner);
assertEquals(1, countChildren(outputDir));
boolean illegalState = false;
try {
ParallelFileProcessingResult result = run(runner);
} catch (ExecutionException e) {
if (e.getCause() instanceof IllegalStateException) {
illegalState = true;
}
}
assertTrue("Should have been an illegal state exception", illegalState);
}
use of org.apache.tika.batch.ParallelFileProcessingResult in project tika by apache.
the class FSBatchTestBase method run.
protected ParallelFileProcessingResult run(BatchProcess process) throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<ParallelFileProcessingResult> futureResult = executor.submit(process);
return futureResult.get(10, TimeUnit.SECONDS);
}
use of org.apache.tika.batch.ParallelFileProcessingResult in project tika by apache.
the class HandlerBuilderTest method testXML.
@Test
public void testXML() throws Exception {
Path outputDir = getNewOutputDir("handler-xml-");
Map<String, String> args = getDefaultArgs("basic", outputDir);
args.put("basicHandlerType", "xml");
BatchProcess runner = getNewBatchRunner("/tika-batch-config-test.xml", args);
ParallelFileProcessingResult result = run(runner);
Path outputFile = outputDir.resolve("test0.xml.xml");
String resultString = readFileToString(outputFile, UTF_8);
assertTrue(resultString.contains("<html xmlns=\"http://www.w3.org/1999/xhtml\">"));
assertTrue(resultString.contains("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
assertTrue(resultString.contains("This is tika-batch's first test file"));
}
use of org.apache.tika.batch.ParallelFileProcessingResult in project tika by apache.
the class HandlerBuilderTest method testRecursiveParserWrapper.
@Test
public void testRecursiveParserWrapper() throws Exception {
Path outputDir = getNewOutputDir("handler-recursive-parser");
Map<String, String> args = getDefaultArgs("basic", outputDir);
args.put("basicHandlerType", "txt");
args.put("recursiveParserWrapper", "true");
BatchProcess runner = getNewBatchRunner("/tika-batch-config-test.xml", args);
ParallelFileProcessingResult result = run(runner);
Path outputFile = outputDir.resolve("test0.xml.json");
String resultString = readFileToString(outputFile, UTF_8);
assertTrue(resultString.contains("\"author\":\"Nikolai Lobachevsky\""));
assertTrue(resultString.contains("tika-batch\\u0027s first test file"));
}
Aggregations