Skip to content
Permalink
Browse files
Transaction.rollback method also calls beforeCompletion - GERONIMO-44…
…49, pull from branch 2.1

git-svn-id: https://svn.apache.org/repos/asf/geronimo/components/txmanager/trunk@725403 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Lin Sun committed Dec 10, 2008
1 parent 3e51acd commit 9ddd49a51ed86a5c23d571d6b90c670281399470
Showing 3 changed files with 16 additions and 8 deletions.
@@ -470,7 +470,6 @@ public void rollback() throws IllegalStateException, SystemException {
rms = resourceManagers;
}

beforeCompletion();
endResources();
try {
rollbackResources(rms);
@@ -18,7 +18,6 @@
package org.apache.geronimo.transaction.manager;

import javax.transaction.Status;
import javax.transaction.InvalidTransactionException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.xa.XAResource;
@@ -78,20 +78,25 @@ private void checkInterposedSyncCalled() {
assertTrue("interposedSync afterCompletion was not called", interposedSync.getAfterCount() != -1);
}

private void checkInterposedSyncCalledOnRollback() {
assertTrue("interposedSync afterCompletion was not called", interposedSync.getAfterCount() != -1);
}

public void testInterposedSynchIsCalledOnRollback() throws Exception {
setUpInterposedSync();
tm.rollback();
checkInterposedSyncCalled();
checkInterposedSyncCalledOnRollback();
}

/*public void testNormalSynchIsNotCalledOnRollback() throws Exception {
// check normal synch before completion is not called on rollback
public void testNormalSynchBeforeCompletion() throws Exception {
normalSync = new CountingSync();
tm.begin();
tm.getTransaction().registerSynchronization(normalSync);
tm.rollback();
assertFalse(normalSync.beforeCompletionCalled());
assertTrue(normalSync.afterCompletionCalled());
}*/
}

public void testInterposedSynchIsCalledOnMarkRollback() throws Exception {
setUpInterposedSync();
@@ -126,11 +131,16 @@ private void checkSyncCallOrder() {
assertTrue("interposedSync beforeCompletion was not called after normalSync beforeCompletion", interposedSync.getBeforeCount() > normalSync.getBeforeCount());
assertTrue("interposedSync afterCompletion was not called before normalSync beforeCompletion", interposedSync.getAfterCount() < normalSync.getAfterCount());
}

private void checkSyncCallOrderOnRollback() {
checkInterposedSyncCalledOnRollback();
assertTrue("interposedSync afterCompletion was not called before normalSync beforeCompletion", interposedSync.getAfterCount() < normalSync.getAfterCount());
}

public void testSynchCallOrderOnRollback() throws Exception {
setUpSyncs();
tm.rollback();
checkSyncCallOrder();
checkSyncCallOrderOnRollback();
}

public void testSynchCallOrderOnMarkRollback() throws Exception {
@@ -163,12 +173,12 @@ private class CountingSync implements Synchronization {
private boolean afterCalled = false;

public void beforeCompletion() {
beforeCalled = true;
beforeCalled = true;
beforeCount = beforeCounter++;
}

public void afterCompletion(int i) {
afterCalled = true;
afterCalled = true;
afterCount = afterCounter++;
}

0 comments on commit 9ddd49a

Please sign in to comment.