@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor;
@@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor;
import java.lang.reflect.Method ;
import junit.framework. TestCase ;
import org. junit.Test;
import org.springframework.dao.OptimisticLockingFailureException ;
import org.springframework.tests.sample.beans.ITestBean ;
@ -33,6 +33,7 @@ import org.springframework.transaction.TransactionSystemException;
@@ -33,6 +33,7 @@ import org.springframework.transaction.TransactionSystemException;
import org.springframework.transaction.UnexpectedRollbackException ;
import org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo ;
import static org.junit.Assert.* ;
import static org.mockito.BDDMockito.* ;
/ * *
@ -47,7 +48,7 @@ import static org.mockito.BDDMockito.*;
@@ -47,7 +48,7 @@ import static org.mockito.BDDMockito.*;
* @author Rod Johnson
* @since 16 . 03 . 2003
* /
public abstract class AbstractTransactionAspectTests extends TestCase {
public abstract class AbstractTransactionAspectTests {
protected Method exceptionalMethod ;
@ -69,7 +70,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -69,7 +70,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
}
public void testNoTransaction ( ) throws Exception {
@Test
public void noTransaction ( ) throws Exception {
PlatformTransactionManager ptm = mock ( PlatformTransactionManager . class ) ;
TestBean tb = new TestBean ( ) ;
@ -91,7 +93,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -91,7 +93,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
/ * *
* Check that a transaction is created and committed .
* /
public void testTransactionShouldSucceed ( ) throws Exception {
@Test
public void transactionShouldSucceed ( ) throws Exception {
TransactionAttribute txatt = new DefaultTransactionAttribute ( ) ;
MapTransactionAttributeSource tas = new MapTransactionAttributeSource ( ) ;
@ -116,7 +119,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -116,7 +119,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
* Check that a transaction is created and committed using
* CallbackPreferringPlatformTransactionManager .
* /
public void testTransactionShouldSucceedWithCallbackPreference ( ) throws Exception {
@Test
public void transactionShouldSucceedWithCallbackPreference ( ) throws Exception {
TransactionAttribute txatt = new DefaultTransactionAttribute ( ) ;
MapTransactionAttributeSource tas = new MapTransactionAttributeSource ( ) ;
@ -135,7 +139,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -135,7 +139,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
assertFalse ( ptm . getStatus ( ) . isRollbackOnly ( ) ) ;
}
public void testTransactionExceptionPropagatedWithCallbackPreference ( ) throws Throwable {
@Test
public void transactionExceptionPropagatedWithCallbackPreference ( ) throws Throwable {
TransactionAttribute txatt = new DefaultTransactionAttribute ( ) ;
MapTransactionAttributeSource tas = new MapTransactionAttributeSource ( ) ;
@ -163,7 +168,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -163,7 +168,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
/ * *
* Check that two transactions are created and committed .
* /
public void testTwoTransactionsShouldSucceed ( ) throws Exception {
@Test
public void twoTransactionsShouldSucceed ( ) throws Exception {
TransactionAttribute txatt = new DefaultTransactionAttribute ( ) ;
MapTransactionAttributeSource tas1 = new MapTransactionAttributeSource ( ) ;
@ -191,7 +197,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -191,7 +197,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
/ * *
* Check that a transaction is created and committed .
* /
public void testTransactionShouldSucceedWithNotNew ( ) throws Exception {
@Test
public void transactionShouldSucceedWithNotNew ( ) throws Exception {
TransactionAttribute txatt = new DefaultTransactionAttribute ( ) ;
MapTransactionAttributeSource tas = new MapTransactionAttributeSource ( ) ;
@ -213,7 +220,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -213,7 +220,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
verify ( ptm ) . commit ( status ) ;
}
public void testEnclosingTransactionWithNonTransactionMethodOnAdvisedInside ( ) throws Throwable {
@Test
public void enclosingTransactionWithNonTransactionMethodOnAdvisedInside ( ) throws Throwable {
TransactionAttribute txatt = new DefaultTransactionAttribute ( ) ;
MapTransactionAttributeSource tas = new MapTransactionAttributeSource ( ) ;
@ -258,7 +266,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -258,7 +266,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
verify ( ptm ) . commit ( status ) ;
}
public void testEnclosingTransactionWithNestedTransactionOnAdvisedInside ( ) throws Throwable {
@Test
public void enclosingTransactionWithNestedTransactionOnAdvisedInside ( ) throws Throwable {
final TransactionAttribute outerTxatt = new DefaultTransactionAttribute ( ) ;
final TransactionAttribute innerTxatt = new DefaultTransactionAttribute ( TransactionDefinition . PROPAGATION_NESTED ) ;
@ -314,35 +323,43 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -314,35 +323,43 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
verify ( ptm ) . commit ( outerStatus ) ;
}
public void testRollbackOnCheckedException ( ) throws Throwable {
@Test
public void rollbackOnCheckedException ( ) throws Throwable {
doTestRollbackOnException ( new Exception ( ) , true , false ) ;
}
public void testNoRollbackOnCheckedException ( ) throws Throwable {
@Test
public void noRollbackOnCheckedException ( ) throws Throwable {
doTestRollbackOnException ( new Exception ( ) , false , false ) ;
}
public void testRollbackOnUncheckedException ( ) throws Throwable {
@Test
public void rollbackOnUncheckedException ( ) throws Throwable {
doTestRollbackOnException ( new RuntimeException ( ) , true , false ) ;
}
public void testNoRollbackOnUncheckedException ( ) throws Throwable {
@Test
public void noRollbackOnUncheckedException ( ) throws Throwable {
doTestRollbackOnException ( new RuntimeException ( ) , false , false ) ;
}
public void testRollbackOnCheckedExceptionWithRollbackException ( ) throws Throwable {
@Test
public void rollbackOnCheckedExceptionWithRollbackException ( ) throws Throwable {
doTestRollbackOnException ( new Exception ( ) , true , true ) ;
}
public void testNoRollbackOnCheckedExceptionWithRollbackException ( ) throws Throwable {
@Test
public void noRollbackOnCheckedExceptionWithRollbackException ( ) throws Throwable {
doTestRollbackOnException ( new Exception ( ) , false , true ) ;
}
public void testRollbackOnUncheckedExceptionWithRollbackException ( ) throws Throwable {
@Test
public void rollbackOnUncheckedExceptionWithRollbackException ( ) throws Throwable {
doTestRollbackOnException ( new RuntimeException ( ) , true , true ) ;
}
public void testNoRollbackOnUncheckedExceptionWithRollbackException ( ) throws Throwable {
@Test
public void noRollbackOnUncheckedExceptionWithRollbackException ( ) throws Throwable {
doTestRollbackOnException ( new RuntimeException ( ) , false , true ) ;
}
@ -413,7 +430,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -413,7 +430,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
/ * *
* Test that TransactionStatus . setRollbackOnly works .
* /
public void testProgrammaticRollback ( ) throws Exception {
@Test
public void programmaticRollback ( ) throws Exception {
TransactionAttribute txatt = new DefaultTransactionAttribute ( ) ;
Method m = getNameMethod ;
@ -447,7 +465,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -447,7 +465,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
* Simulate a transaction infrastructure failure .
* Shouldn ' t invoke target method .
* /
public void testCannotCreateTransaction ( ) throws Exception {
@Test
public void cannotCreateTransaction ( ) throws Exception {
TransactionAttribute txatt = new DefaultTransactionAttribute ( ) ;
Method m = getNameMethod ;
@ -482,7 +501,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
@@ -482,7 +501,8 @@ public abstract class AbstractTransactionAspectTests extends TestCase {
* Check that the target method was invoked , but that the transaction
* infrastructure exception was thrown to the client
* /
public void testCannotCommitTransaction ( ) throws Exception {
@Test
public void cannotCommitTransaction ( ) throws Exception {
TransactionAttribute txatt = new DefaultTransactionAttribute ( ) ;
Method m = setNameMethod ;