}
@Test
public void testBeginPutPrepareRollbackCloseRecover() throws Exception {
final SessionContext context = new SessionContextImpl("test", this.conn);
final TransactionId xid = XIDGenerator.createXID(100);
assertNull(context.getTransactions().get(xid));
this.processor.beginTransaction(context, xid, 0);
final Transaction tx = this.processor.getTransaction(context, xid);
assertNotNull(tx);
assertSame(xid, tx.getTransactionId());
this.replay();
this.processor.processPutCommand(new PutCommand("topic1", 2, "hello".getBytes(), xid, 0, 1), context, null);
MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
store.flush();
assertEquals(0, store.getSizeInBytes());
// prepare
this.processor.prepareTransaction(context, xid);
assertSame(tx, this.processor.getTransaction(context, xid));
// rollback
this.processor.rollbackTransaction(context, xid);
store.flush();
assertEquals(Transaction.FINISHED_STATE, tx.getState());
assertNull(context.getTransactions().get(xid));
assertEquals(0, store.getSizeInBytes());
// close and reopen it
this.tearDown();