### Question:
FulltextProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { final Message in = exchange.getIn(); String fedoraUri = (String) in.getHeader(FCREPO_URI); String binaryPath = (String) in.getHeader(CdrBinaryPath); String binaryId = PIDs.get(fedoraUri).getId(); String binarySubPath = idToPath(binaryId, HASHED_PATH_DEPTH, HASHED_PATH_SIZE); String text; try { text = extractText(binaryPath); } catch (TikaException e) { log.error("Failed to extract text for {} due to parsing error", fedoraUri, e); return; } Path derivativePath = Paths.get(derivativeBasePath, binarySubPath, binaryId + ".txt"); File derivative = derivativePath.toFile(); File parentDir = derivative.getParentFile(); if (parentDir != null) { try { Files.createDirectories(parentDir.toPath()); } catch (IOException e) { throw new IOException("Failed to create parent directories for " + derivativePath + ".", e); } FileUtils.write(derivative, text, UTF_8); } } FulltextProcessor(String derivativeBasePath); @Override void process(Exchange exchange);  }### Answer:
@Test public void extractFulltextTest() throws Exception { originalFile = tmpDir.newFile(originalFileName); FileUtils.write(originalFile, testText, "UTF-8"); when(message.getHeader(eq(CdrBinaryPath))) .thenReturn(originalFile.toPath().toString()); processor.process(exchange); assertTrue(finalDerivativeFile.exists()); assertEquals(testText, FileUtils.readFileToString(finalDerivativeFile, UTF_8).trim()); }
@Test public void extractFromInvalidPdfTest() throws Exception { originalFile = tmpDir.newFile("invalid.pdf"); Files.copy(new File("src/test/resources/datastreams/invalid.pdf"), originalFile); when(message.getHeader(eq(CdrBinaryPath))) .thenReturn(originalFile.toPath().toString()); processor.process(exchange); assertFalse(finalDerivativeFile.exists()); }