use of org.apache.jena.dboe.transaction.txn.TransactionCoordinator in project jena by apache.
the class TestRecovery method recoverBlobFile_1.
// Fake journal recovery.
@Test
public void recoverBlobFile_1() throws Exception {
String str = "Hello Journal";
ComponentId cid = ComponentId.allocLocal();
// ComponentIdRegistry registry = new ComponentIdRegistry();
// registry.register(cid, "Blob", 1);
// Write out a journal.
{
Journal journal = Journal.create(Location.create(dir.getRoot().getAbsolutePath()));
journal.write(JournalEntryType.REDO, cid, IO.stringToByteBuffer(str));
journal.writeJournal(JournalEntry.COMMIT);
journal.close();
}
TransactionCoordinator coord = new TransactionCoordinator(Location.create(dir.getRoot().getAbsolutePath()));
BufferChannel chan = BufferChannelFile.create(data);
TransBlob tBlob = new TransBlob(cid, chan);
coord.add(tBlob);
coord.start();
ByteBuffer blob = tBlob.getBlob();
assertNotNull(blob);
String s = IO.byteBufferToString(blob);
assertEquals(str, s);
coord.shutdown();
}
Aggregations