public class JournalTransactionStoreUnitTest extends BaseTransactionUnitTest {
@Test
public void testAddAddRollBackCloseRecover() throws Exception {
final LocalTransactionId xid = new LocalTransactionId("test", 1);
final MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg1".getBytes(), xid, 0, 1), null);
this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg2".getBytes(), xid, 0, 2), null);
final Tx tx = this.transactionStore.getInflyTx(xid);
assertNotNull(tx);
final PutCommand[] commands = tx.getRequests();
assertNotNull(commands);
assertEquals(2, commands.length);
store.flush();
// ��û��д��
assertEquals(0, store.getSizeInBytes());
// rollback
this.transactionStore.rollback(xid);
assertNull(this.transactionStore.getInflyTx(xid));
store.flush();
// �ع�����Ȼû��д��
assertEquals(0, store.getSizeInBytes());
this.tearDown();
this.init(this.path);
assertTrue(this.journalStore.getCurrDataFile().getLength() > 0);
assertNull(this.transactionStore.getInflyTx(xid));