Search in sources :

Example 16 with FileDataStore

use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.

the class DataStoreServiceTest method configFileDataStore.

/**
     *
     * Test to verify @FileDataStore is returned if cacheSize is not configured.
     */
@Test
public void configFileDataStore() throws Exception {
    String nasPath = folder.getRoot().getAbsolutePath() + "/NASPath";
    String cachePath = folder.getRoot().getAbsolutePath() + "/cachePath";
    Map<String, Object> config = new HashMap<String, Object>();
    config.put("repository.home", folder.getRoot().getAbsolutePath());
    config.put(FileDataStoreService.PATH, nasPath);
    config.put(FileDataStoreService.CACHE_PATH, cachePath);
    FileDataStoreService fdsSvc = new FileDataStoreService();
    DataStore ds = fdsSvc.createDataStore(context.componentContext(), config);
    PropertiesUtil.populate(ds, config, false);
    ds.init(folder.getRoot().getAbsolutePath());
    assertTrue("not instance of FileDataStore", ds instanceof FileDataStore);
    FileDataStore fds = (FileDataStore) ds;
    assertEquals("path not equal", nasPath, fds.getPath());
}
Also used : HashMap(java.util.HashMap) DataStore(org.apache.jackrabbit.core.data.DataStore) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) Test(org.junit.Test)

Example 17 with FileDataStore

use of org.apache.jackrabbit.core.data.FileDataStore 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"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DataRecord(org.apache.jackrabbit.core.data.DataRecord) File(java.io.File) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) ExtractedText(org.apache.jackrabbit.oak.plugins.index.fulltext.ExtractedText) Test(org.junit.Test)

Example 18 with FileDataStore

use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.

the class DataStoreTextWriterTest method basicOperation.

@Test
public void basicOperation() 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();
    TextWriter writer = new DataStoreTextWriter(writerDir, false);
    writer.write(dr.getIdentifier().toString(), "hello");
    FileDataStore fds2 = DataStoreUtils.createFDS(writerDir, 0);
    DataRecord dr2 = fds2.getRecordIfStored(dr.getIdentifier());
    is.reset();
    assertTrue(IOUtils.contentEquals(is, dr2.getStream()));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TextWriter(org.apache.jackrabbit.oak.plugins.blob.datastore.TextWriter) DataRecord(org.apache.jackrabbit.core.data.DataRecord) File(java.io.File) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) Test(org.junit.Test)

Aggregations

FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)18 Test (org.junit.Test)11 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)10 File (java.io.File)9 ByteArrayInputStream (java.io.ByteArrayInputStream)7 DataRecord (org.apache.jackrabbit.core.data.DataRecord)5 Random (java.util.Random)3 DataStore (org.apache.jackrabbit.core.data.DataStore)3 Blob (org.apache.jackrabbit.oak.api.Blob)3 AbstractBlob (org.apache.jackrabbit.oak.plugins.memory.AbstractBlob)3 FileBlob (org.apache.jackrabbit.oak.segment.file.FileBlob)3 Closer (com.google.common.io.Closer)2 InputStream (java.io.InputStream)2 Properties (java.util.Properties)2 DataIdentifier (org.apache.jackrabbit.core.data.DataIdentifier)2 BlobStore (org.apache.jackrabbit.oak.spi.blob.BlobStore)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 Function (com.google.common.base.Function)1 Closeable (java.io.Closeable)1 HashMap (java.util.HashMap)1