AbstractBinaryStore implements BinaryStore { @Override public final String getText( BinaryValue binary ) throws BinaryStoreException { if (binary instanceof StoredBinaryValue) { String extractedText = getExtractedText(binary); if (extractedText != null) { return extractedText; } } if (extractors == null || !extractors.extractionEnabled()) { return null; } if (binary instanceof InMemoryBinaryValue) { return extractors.extract((InMemoryBinaryValue)binary, new TextExtractorContext(detector())); } try { CountDownLatch latch = extractors.getWorkerLatch(binary.getKey(), false); if (latch == null) { latch = extractors.extract(this, binary, new TextExtractorContext(detector())); } if (latch != null && latch.await(DEFAULT_LATCH_WAIT_IN_SECONDS, TimeUnit.SECONDS)) { return getExtractedText(binary); } return null; } catch (InterruptedException e) { throw new BinaryStoreException(e); } }  static int bestBufferSize( long fileSize ); @Override long getMinimumBinarySizeInBytes(); @Override void setMinimumBinarySizeInBytes( long minSizeInBytes ); @Override void setTextExtractors( TextExtractors textExtractors ); @Override void setMimeTypeDetector( MimeTypeDetector mimeTypeDetector ); @Override final String getText( BinaryValue binary ); @Override String getMimeType( BinaryValue binary,
                               String name ); @Override boolean hasBinary( BinaryKey key ); abstract void storeExtractedText( BinaryValue source,
                                             String extractedText ); abstract String getExtractedText( BinaryValue source ); @Override BinaryValue storeValue( InputStream stream, String hint, boolean markAsUnused ); @Override void start(); @Override void shutdown();  }
@Test(expected = BinaryStoreException.class) public void shouldFailWhenGettingTheTextOfBinaryWhichIsntStored() throws RepositoryException { getBinaryStore().getText(new StoredBinaryValue(getBinaryStore(), invalidBinaryKey(), 0)); }