//https://issues.jboss.org/browse/JBMESSAGING-1837
public void testCommitOnePhaseFailure() throws Throwable
{
doSetup2(true, true, true, 100);
TransactionRepository txRep = new TransactionRepository(pm, ms, 0);
txRep.start();
MessagingQueue queue = new MessagingQueue(1, "queue1", 1, ms, pm, true, -1, null, false);
queue.activate();
SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
assertTrue(queue.getLocalDistributor().add(r));
SimpleDeliveryObserver observer = new SimpleDeliveryObserver();
log.debug("sending a message");
Message[] messages = createMessages(1);
Message m1 = messages[0];
Transaction tx = txRep.createTransaction(new MockXid());
MessageReference ref1 = ms.reference(m1);
Delivery delivery = queue.handle(observer, ref1, null);
assertTrue(r.getMessages().size() == 1);
//simulating processing transaction
delivery.acknowledge(tx);
//poison pm
((FakeJDBCPersistenceManager)pm).poisonHandleCommit1PC();
//commit one phase
try
{
tx.commit();
}
catch (Exception e)
{
//ignore the exception.
}
//message received again.
assertEquals(2, r.getMessages().size());
//delivering count 1
assertTrue(queue.getDeliveringCount() == 1);
//restore
((FakeJDBCPersistenceManager)pm).restoreHandleCommit1PC();
//another tx
tx = txRep.createTransaction(new MockXid());
delivery.acknowledge(tx);
tx.commit();
//still received twice.
assertTrue(r.getMessages().size() == 2);