use of org.apache.jackrabbit.oak.plugins.index.fulltext.ExtractedText in project jackrabbit-oak by apache.
the class ExtractedTextCacheTest method preExtractionReindex.
@Test
public void preExtractionReindex() throws Exception {
ExtractedTextCache cache = new ExtractedTextCache(10 * FileUtils.ONE_MB, 100);
PreExtractedTextProvider provider = mock(PreExtractedTextProvider.class);
cache.setExtractedTextProvider(provider);
when(provider.getText(anyString(), any(Blob.class))).thenReturn(new ExtractedText(ExtractionResult.SUCCESS, "bar"));
Blob b = new IdBlob("hello", "a");
String text = cache.get("/a", "foo", b, true);
assertEquals("bar", text);
}
use of org.apache.jackrabbit.oak.plugins.index.fulltext.ExtractedText in project jackrabbit-oak by apache.
the class ExtractedTextCacheTest method cacheEnabled.
@Test
public void cacheEnabled() throws Exception {
ExtractedTextCache cache = new ExtractedTextCache(10 * FileUtils.ONE_MB, 100);
assertNotNull(cache.getCacheStats());
Blob b = new IdBlob("hello", "a");
String text = cache.get("/a", "foo", b, false);
assertNull(text);
cache.put(b, new ExtractedText(ExtractionResult.SUCCESS, "test hello"));
text = cache.get("/a", "foo", b, false);
assertEquals("test hello", text);
}
use of org.apache.jackrabbit.oak.plugins.index.fulltext.ExtractedText in project jackrabbit-oak by apache.
the class ExtractedTextCacheTest method cacheEnabledErrorInTextExtraction.
@Test
public void cacheEnabledErrorInTextExtraction() throws Exception {
ExtractedTextCache cache = new ExtractedTextCache(10 * FileUtils.ONE_MB, 100);
Blob b = new IdBlob("hello", "a");
String text = cache.get("/a", "foo", b, false);
assertNull(text);
cache.put(b, new ExtractedText(ExtractionResult.ERROR, "test hello"));
text = cache.get("/a", "foo", b, false);
assertEquals(LuceneIndexEditor.TEXT_EXTRACTION_ERROR, text);
}
use of org.apache.jackrabbit.oak.plugins.index.fulltext.ExtractedText in project jackrabbit-oak by apache.
the class ExtractedTextCacheTest method cacheEnabledNonIdBlob.
@Test
public void cacheEnabledNonIdBlob() throws Exception {
ExtractedTextCache cache = new ExtractedTextCache(10 * FileUtils.ONE_MB, 100);
Blob b = new ArrayBasedBlob("hello".getBytes());
String text = cache.get("/a", "foo", b, false);
assertNull(text);
cache.put(b, new ExtractedText(ExtractionResult.SUCCESS, "test hello"));
text = cache.get("/a", "foo", b, false);
assertNull(text);
}
use of org.apache.jackrabbit.oak.plugins.index.fulltext.ExtractedText in project jackrabbit-oak by apache.
the class DataStoreTextWriterTest method nonExistingEntry.
@Test
public void nonExistingEntry() throws Exception {
File fdsDir = temporaryFolder.newFolder();
FileDataStore fds = DataStoreUtils.createFDS(fdsDir, 0);
ByteArrayInputStream is = new ByteArrayInputStream("hello".getBytes());
DataRecord dr = fds.addRecord(is);
File writerDir = temporaryFolder.newFolder();
DataStoreTextWriter w = new DataStoreTextWriter(writerDir, false);
String id = dr.getIdentifier().toString();
assertFalse(w.isProcessed(id));
assertNull(w.getText("/a", new IdBlob("foo", id)));
w.write(id, "foo");
assertTrue(w.isProcessed(id));
ExtractedText et = w.getText("/a", new IdBlob("foo", id));
assertEquals("foo", et.getExtractedText());
assertEquals(ExtractionResult.SUCCESS, et.getExtractionResult());
w.markEmpty("a");
assertTrue(w.isProcessed("a"));
}
Aggregations