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());
}
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"));
}
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()));
}
Aggregations