use of org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob in project jackrabbit-oak by apache.
the class OakDirectoryTestBase method markAllBlobsFromBlobStoreAsDeleted.
// OAK-7066
@Test
public void markAllBlobsFromBlobStoreAsDeleted() throws Exception {
IndexDefinition def = new IndexDefinition(root, builder.getNodeState(), "/foo");
final Set<String> deletedFiles = newHashSet();
MemoryBlobStore bs = new MemoryBlobStore();
bs.setBlockSizeMin(48);
BlobFactory factory = in -> new BlobStoreBlob(bs, bs.writeBlob(in));
OakDirectory dir = getOakDirectoryBuilder(builder, def).setReadOnly(false).with(factory).with(new ActiveDeletedBlobCollectorFactory.BlobDeletionCallback() {
@Override
public void deleted(String blobId, Iterable<String> ids) {
deletedFiles.add(Iterables.getLast(ids));
}
@Override
public void commitProgress(IndexProgress indexProgress) {
}
@Override
public boolean isMarkingForActiveDeletionUnsafe() {
return false;
}
}).build();
writeFile(dir, "file1", 25);
writeFile(dir, "file2", 50);
dir.deleteFile("file1");
dir.deleteFile("file2");
dir.close();
assertTrue("file1 must be reported as deleted", deletedFiles.contains("file1"));
assertTrue("file2 must be reported as deleted", deletedFiles.contains("file2"));
}
use of org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob 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)));
}
use of org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob in project jackrabbit-oak by apache.
the class BlobIdSerializerTest method blobStoreBlob.
@Test
public void blobStoreBlob() throws Exception {
Blob b = new ArrayBasedBlob("hello world".getBytes());
String value = blobStore.writeBlob(b.getNewStream());
String serValue = serializer.serialize(new BlobStoreBlob(blobStore, value));
Blob b2 = serializer.deserialize(serValue);
assertTrue(AbstractBlob.equal(b, b2));
}
Aggregations