@Test
public void testAddAddCommit_CloseReplayAppend_CloseRecover() throws Exception {
final LocalTransactionId xid = new LocalTransactionId("test", 1);
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);
assertNotNull(this.transactionStore.getInflyTx(xid));
// commit
this.transactionStore.commit(xid, false);
store.flush();
final long sizeInBytes = store.getSizeInBytes();
assertTrue(sizeInBytes > 0);
this.assertMessages(store);
this.tearDown();
// delete data
System.out.println("ɾ��Ŀ¼:" + this.path + File.separator + store.getDescription());
FileUtils.deleteDirectory(new File(this.path + File.separator + store.getDescription()));
this.init(this.path);
// Ӧ���طŲ���������,ȷ��������ȷ
store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
store.flush();
assertTrue(store.getSizeInBytes() > 0);
assertEquals(sizeInBytes, store.getSizeInBytes());
this.assertMessages(store);
assertNull(this.transactionStore.getInflyTx(xid));
// �ٴιرմ�״̬��ȷ
this.tearDown();
this.init(this.path);
store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
assertTrue(store.getSizeInBytes() > 0);
assertEquals(sizeInBytes, store.getSizeInBytes());
this.assertMessages(store);
assertNull(this.transactionStore.getInflyTx(xid));
}