@Test
public void testRollback() throws Exception {
// put an item and commit
putEvents(channel, "rollback", 1, 50);
Transaction transaction;
// put an item we will rollback
transaction = channel.getTransaction();
transaction.begin();
channel.put(EventBuilder.withBody("this is going to be rolledback".getBytes(Charsets.UTF_8)));
transaction.rollback();
transaction.close();
// simulate crash
channel.stop();
channel = createFileChannel();
// get the item which was not rolled back
transaction = channel.getTransaction();
transaction.begin();
Event event = channel.take();
transaction.commit();
transaction.close();
Assert.assertNotNull(event);
Assert.assertEquals("rollback-0-0", new String(event.getBody(), Charsets.UTF_8));
}