public void testCommitTransactionHeuristicallyRecoverHeuristicTransactions() 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);
final 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));
// �ֹ��ύ
this.processor.commitTransactionHeuristically(xid.getTransactionKey(), false);
Map<TransactionId, XATransaction> heuristicTxMap = this.processor.getXAHeuristicTransactions();
assertFalse(heuristicTxMap.isEmpty());
assertTrue(heuristicTxMap.containsKey(xid));
assertSame(tx, heuristicTxMap.get(xid));
assertEquals(Transaction.HEURISTIC_COMMIT_STATE, heuristicTxMap.get(xid).getState());
// �رգ����´�recover
this.processor.dispose();
this.newProcessor();
this.processor.recoverHeuristicTransactions();
// ȷ����ȷrecover
heuristicTxMap = this.processor.getXAHeuristicTransactions();
assertFalse(heuristicTxMap.isEmpty());
assertTrue(heuristicTxMap.containsKey(xid));
assertEquals(tx.getTransactionId(), heuristicTxMap.get(xid).getTransactionId());
assertEquals(Transaction.HEURISTIC_COMMIT_STATE, heuristicTxMap.get(xid).getState());
}