@Test
public void testAddAddCloseRecover() throws Exception {
final LocalTransactionId xid1 = new LocalTransactionId("test", 1);
MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg1".getBytes(), xid1, 0, 1), null);
this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg2".getBytes(), xid1, 0, 2), null);
final LocalTransactionId xid2 = new LocalTransactionId("test", 2);
store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg1".getBytes(), xid2, 0, 1), null);
this.tearDown();
this.init(this.path);
assertTrue(this.journalStore.getCurrDataFile().getLength() > 0);
store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
// ȷ����Ϣû��д��
assertEquals(0, store.getSizeInBytes());
// ȷ��TX������
final Tx tx1 = this.transactionStore.getInflyTx(xid1);
assertNotNull(tx1);
PutCommand[] commands = tx1.getRequests();
assertNotNull(commands);
assertEquals(2, commands.length);
final Tx tx2 = this.transactionStore.getInflyTx(xid2);
assertNotNull(tx2);
commands = tx2.getRequests();
assertNotNull(commands);
assertEquals(1, commands.length);
// recover���ع���
this.transactionStore.recover(null);
assertNull(this.transactionStore.getInflyTx(xid1));
assertNull(this.transactionStore.getInflyTx(xid2));
// ȷ����Ϣ����û��д��
assertEquals(0, store.getSizeInBytes());
}