Search in sources :

Example 26 with ArrayBasedBlob

use of org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob in project jackrabbit-oak by apache.

the class BlobIdRecordTest method shortReferencesShouldHaveBlobIdType.

@Test
public void shortReferencesShouldHaveBlobIdType() throws Exception {
    try (FileStore ss = newFileStore(new ShortIdMappingBlobStore())) {
        SegmentWriter sw = defaultSegmentWriterBuilder("test").build(ss);
        byte[] content = new byte[Segment.MEDIUM_LIMIT + 1];
        SegmentBlob sb = new SegmentBlob(ss.getBlobStore(), sw.writeBlob(new ArrayBasedBlob(content)));
        assertRecordTypeEquals(sb, RecordType.BLOB_ID);
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) Test(org.junit.Test)

Example 27 with ArrayBasedBlob

use of org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob 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));
}
Also used : BlobStoreBlob(org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob) Blob(org.apache.jackrabbit.oak.api.Blob) AbstractBlob(org.apache.jackrabbit.oak.plugins.memory.AbstractBlob) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) BlobStoreBlob(org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) Test(org.junit.Test)

Aggregations

ArrayBasedBlob (org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob)27 Test (org.junit.Test)24 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)12 Blob (org.apache.jackrabbit.oak.api.Blob)9 Directory (org.apache.lucene.store.Directory)9 ArrayList (java.util.ArrayList)8 IndexInput (org.apache.lucene.store.IndexInput)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 InputStream (java.io.InputStream)6 NullInputStream (org.apache.commons.io.input.NullInputStream)5 BlobStoreBlob (org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob)5 IndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)4 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)3 File (java.io.File)3 IOException (java.io.IOException)3 Random (java.util.Random)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Iterables (com.google.common.collect.Iterables)2