Search in sources :

Example 1 with TextWriter

use of org.apache.jackrabbit.oak.plugins.blob.datastore.TextWriter 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()));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TextWriter(org.apache.jackrabbit.oak.plugins.blob.datastore.TextWriter) DataRecord(org.apache.jackrabbit.core.data.DataRecord) File(java.io.File) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 DataRecord (org.apache.jackrabbit.core.data.DataRecord)1 FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)1 TextWriter (org.apache.jackrabbit.oak.plugins.blob.datastore.TextWriter)1 Test (org.junit.Test)1