Search in sources :

Example 1 with PreExtractedTextProvider

use of org.apache.jackrabbit.oak.plugins.index.fulltext.PreExtractedTextProvider 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);
}
Also used : PreExtractedTextProvider(org.apache.jackrabbit.oak.plugins.index.fulltext.PreExtractedTextProvider) Blob(org.apache.jackrabbit.oak.api.Blob) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) Matchers.anyString(org.mockito.Matchers.anyString) ExtractedText(org.apache.jackrabbit.oak.plugins.index.fulltext.ExtractedText) Test(org.junit.Test)

Example 2 with PreExtractedTextProvider

use of org.apache.jackrabbit.oak.plugins.index.fulltext.PreExtractedTextProvider in project jackrabbit-oak by apache.

the class ExtractedTextCacheTest method preExtractionNoReindex.

@Test
public void preExtractionNoReindex() throws Exception {
    ExtractedTextCache cache = new ExtractedTextCache(10 * FileUtils.ONE_MB, 100);
    PreExtractedTextProvider provider = mock(PreExtractedTextProvider.class);
    cache.setExtractedTextProvider(provider);
    Blob b = new IdBlob("hello", "a");
    String text = cache.get("/a", "foo", b, false);
    assertNull(text);
    verifyZeroInteractions(provider);
}
Also used : PreExtractedTextProvider(org.apache.jackrabbit.oak.plugins.index.fulltext.PreExtractedTextProvider) Blob(org.apache.jackrabbit.oak.api.Blob) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 3 with PreExtractedTextProvider

use of org.apache.jackrabbit.oak.plugins.index.fulltext.PreExtractedTextProvider in project jackrabbit-oak by apache.

the class DataStoreTextWriterTest method inMemoryRecord.

@Test
public void inMemoryRecord() throws Exception {
    File fdsDir = temporaryFolder.newFolder();
    FileDataStore fds = DataStoreUtils.createFDS(fdsDir, 10000);
    DataStoreBlobStore dbs = new DataStoreBlobStore(fds);
    ByteArrayInputStream is = new ByteArrayInputStream("".getBytes());
    String blobId = dbs.writeBlob(is);
    File writerDir = temporaryFolder.newFolder();
    PreExtractedTextProvider textProvider = new DataStoreTextWriter(writerDir, true);
    assertNull(textProvider.getText("/content", new BlobStoreBlob(dbs, blobId)));
}
Also used : PreExtractedTextProvider(org.apache.jackrabbit.oak.plugins.index.fulltext.PreExtractedTextProvider) BlobStoreBlob(org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob) ByteArrayInputStream(java.io.ByteArrayInputStream) File(java.io.File) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Test(org.junit.Test)

Example 4 with PreExtractedTextProvider

use of org.apache.jackrabbit.oak.plugins.index.fulltext.PreExtractedTextProvider in project jackrabbit-oak by apache.

the class ExtractedTextCacheTest method preExtractionAlwaysUse.

@Test
public void preExtractionAlwaysUse() throws Exception {
    ExtractedTextCache cache = new ExtractedTextCache(10 * FileUtils.ONE_MB, 100, true, null);
    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, false);
    assertEquals("bar", text);
}
Also used : PreExtractedTextProvider(org.apache.jackrabbit.oak.plugins.index.fulltext.PreExtractedTextProvider) Blob(org.apache.jackrabbit.oak.api.Blob) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) Matchers.anyString(org.mockito.Matchers.anyString) ExtractedText(org.apache.jackrabbit.oak.plugins.index.fulltext.ExtractedText) Test(org.junit.Test)

Aggregations

PreExtractedTextProvider (org.apache.jackrabbit.oak.plugins.index.fulltext.PreExtractedTextProvider)4 Test (org.junit.Test)4 Blob (org.apache.jackrabbit.oak.api.Blob)3 ArrayBasedBlob (org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob)3 Matchers.anyString (org.mockito.Matchers.anyString)3 ExtractedText (org.apache.jackrabbit.oak.plugins.index.fulltext.ExtractedText)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)1 BlobStoreBlob (org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob)1 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)1