use of org.apache.jackrabbit.oak.json.BlobSerializer in project jackrabbit-oak by apache.
the class BlobTest method testBlobSerialization.
@Test
public void testBlobSerialization() throws Exception {
TestBlobStore blobStore = new TestBlobStore();
DocumentMK mk = builderProvider.newBuilder().setBlobStore(blobStore).open();
BlobSerializer blobSerializer = mk.getNodeStore().getBlobSerializer();
Blob blob = new BlobStoreBlob(blobStore, "foo");
assertEquals("foo", blobSerializer.serialize(blob));
assertEquals(0, blobStore.writeCount);
blob = new ArrayBasedBlob("foo".getBytes());
blobSerializer.serialize(blob);
assertEquals(1, blobStore.writeCount);
byte[] bytes = "foo".getBytes();
String blobId = blobStore.writeBlob(new ByteArrayInputStream(bytes));
String reference = blobStore.getReference(blobId);
blob = new ReferencedBlob("foo".getBytes(), reference);
blobStore.writeCount = 0;
blobSerializer.serialize(blob);
// Using reference so no reference should be written
assertEquals(0, blobStore.writeCount);
}
use of org.apache.jackrabbit.oak.json.BlobSerializer in project jackrabbit-oak by apache.
the class JsonDeserializationTest method serialize.
private String serialize(NodeState nodeState) {
JsopBuilder json = new JsopBuilder();
new JsonSerializer(json, "{\"properties\":[\"*\", \"-:*\"]}", new BlobSerializer()).serialize(nodeState);
return json.toString();
}
use of org.apache.jackrabbit.oak.json.BlobSerializer 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;
}
Aggregations