Search in sources :

Example 1 with FSBlobSerializer

use of org.apache.jackrabbit.oak.plugins.blob.serializer.FSBlobSerializer in project jackrabbit-oak by apache.

the class FSBlobSerializerTest method blobs.

@Test
public void blobs() throws Exception {
    int maxInlineSize = 100;
    FSBlobSerializer serializer = new FSBlobSerializer(folder.getRoot(), maxInlineSize);
    String data = Strings.repeat("x", maxInlineSize * 10);
    Blob b = new ArrayBasedBlob(data.getBytes(UTF_8));
    String id = serializer.serialize(b);
    Blob b2 = serializer.deserialize(id);
    assertTrue(AbstractBlob.equal(b, b2));
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) AbstractBlob(org.apache.jackrabbit.oak.plugins.memory.AbstractBlob) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) FSBlobSerializer(org.apache.jackrabbit.oak.plugins.blob.serializer.FSBlobSerializer) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) Test(org.junit.Test)

Example 2 with FSBlobSerializer

use of org.apache.jackrabbit.oak.plugins.blob.serializer.FSBlobSerializer in project jackrabbit-oak by apache.

the class NodeStateSerializer method createBlobSerializer.

private BlobSerializer createBlobSerializer(File dir) {
    if (!serializeBlobContent) {
        return new BlobSerializer();
    }
    File blobs = new File(dir, blobDirName);
    blobSerializer = new FSBlobSerializer(blobs);
    return blobSerializer;
}
Also used : FSBlobSerializer(org.apache.jackrabbit.oak.plugins.blob.serializer.FSBlobSerializer) BlobSerializer(org.apache.jackrabbit.oak.json.BlobSerializer) Base64BlobSerializer(org.apache.jackrabbit.oak.json.Base64BlobSerializer) FSBlobSerializer(org.apache.jackrabbit.oak.plugins.blob.serializer.FSBlobSerializer) File(java.io.File)

Example 3 with FSBlobSerializer

use of org.apache.jackrabbit.oak.plugins.blob.serializer.FSBlobSerializer in project jackrabbit-oak by apache.

the class FSBlobSerializerTest method errorBlob.

@Test
public void errorBlob() throws Exception {
    FSBlobSerializer serializer = new FSBlobSerializer(folder.getRoot(), 1);
    String blobValue = serializer.serialize(new BadBlob());
    try {
        Blob b = serializer.deserialize(blobValue);
        assertEquals("foo", b.getContentIdentity());
        b.getNewStream();
        fail();
    } catch (RuntimeException ignore) {
    }
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) AbstractBlob(org.apache.jackrabbit.oak.plugins.memory.AbstractBlob) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) FSBlobSerializer(org.apache.jackrabbit.oak.plugins.blob.serializer.FSBlobSerializer) Test(org.junit.Test)

Aggregations

FSBlobSerializer (org.apache.jackrabbit.oak.plugins.blob.serializer.FSBlobSerializer)3 Blob (org.apache.jackrabbit.oak.api.Blob)2 AbstractBlob (org.apache.jackrabbit.oak.plugins.memory.AbstractBlob)2 ArrayBasedBlob (org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob)2 Test (org.junit.Test)2 File (java.io.File)1 Base64BlobSerializer (org.apache.jackrabbit.oak.json.Base64BlobSerializer)1 BlobSerializer (org.apache.jackrabbit.oak.json.BlobSerializer)1