Polish
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,11 +41,11 @@ import static org.assertj.core.api.Assertions.assertThatRuntimeException;
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class PersistenceExceptionTranslationAdvisorTests {
|
||||
class PersistenceExceptionTranslationAdvisorTests {
|
||||
|
||||
private RuntimeException doNotTranslate = new RuntimeException();
|
||||
private final RuntimeException doNotTranslate = new RuntimeException();
|
||||
|
||||
private PersistenceException persistenceException1 = new PersistenceException();
|
||||
private final PersistenceException persistenceException1 = new PersistenceException();
|
||||
|
||||
protected RepositoryInterface createProxy(RepositoryInterfaceImpl target) {
|
||||
MapPersistenceExceptionTranslator mpet = new MapPersistenceExceptionTranslator();
|
||||
@@ -61,7 +61,7 @@ public class PersistenceExceptionTranslationAdvisorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noTranslationNeeded() {
|
||||
void noTranslationNeeded() {
|
||||
RepositoryInterfaceImpl target = new RepositoryInterfaceImpl();
|
||||
RepositoryInterface ri = createProxy(target);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class PersistenceExceptionTranslationAdvisorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void translationNotNeededForTheseExceptions() {
|
||||
void translationNotNeededForTheseExceptions() {
|
||||
RepositoryInterfaceImpl target = new StereotypedRepositoryInterfaceImpl();
|
||||
RepositoryInterface ri = createProxy(target);
|
||||
|
||||
@@ -95,27 +95,27 @@ public class PersistenceExceptionTranslationAdvisorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void translationNeededForTheseExceptions() {
|
||||
void translationNeededForTheseExceptions() {
|
||||
doTestTranslationNeededForTheseExceptions(new StereotypedRepositoryInterfaceImpl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void translationNeededForTheseExceptionsOnSuperclass() {
|
||||
void translationNeededForTheseExceptionsOnSuperclass() {
|
||||
doTestTranslationNeededForTheseExceptions(new MyStereotypedRepositoryInterfaceImpl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void translationNeededForTheseExceptionsWithCustomStereotype() {
|
||||
void translationNeededForTheseExceptionsWithCustomStereotype() {
|
||||
doTestTranslationNeededForTheseExceptions(new CustomStereotypedRepositoryInterfaceImpl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void translationNeededForTheseExceptionsOnInterface() {
|
||||
void translationNeededForTheseExceptionsOnInterface() {
|
||||
doTestTranslationNeededForTheseExceptions(new MyInterfaceStereotypedRepositoryInterfaceImpl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void translationNeededForTheseExceptionsOnInheritedInterface() {
|
||||
void translationNeededForTheseExceptionsOnInheritedInterface() {
|
||||
doTestTranslationNeededForTheseExceptions(new MyInterfaceInheritedStereotypedRepositoryInterfaceImpl());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Juergen Hoeller
|
||||
* @author Tadaya Tsuyukubo
|
||||
*/
|
||||
public class PersistenceExceptionTranslationInterceptorTests extends PersistenceExceptionTranslationAdvisorTests {
|
||||
class PersistenceExceptionTranslationInterceptorTests extends PersistenceExceptionTranslationAdvisorTests {
|
||||
|
||||
@Override
|
||||
protected void addPersistenceExceptionTranslation(ProxyFactory pf, PersistenceExceptionTranslator pet) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,10 +43,9 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class PersistenceExceptionTranslationPostProcessorTests {
|
||||
class PersistenceExceptionTranslationPostProcessorTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void proxiesCorrectly() {
|
||||
GenericApplicationContext gac = new GenericApplicationContext();
|
||||
gac.registerBeanDefinition("translator",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,33 +27,33 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link LocalConnectionFactoryBean} class.
|
||||
* Tests for {@link LocalConnectionFactoryBean}.
|
||||
*
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class LocalConnectionFactoryBeanTests {
|
||||
class LocalConnectionFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
public void testManagedConnectionFactoryIsRequired() throws Exception {
|
||||
void testManagedConnectionFactoryIsRequired() {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
new LocalConnectionFactoryBean()::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSingleton() throws Exception {
|
||||
void testIsSingleton() {
|
||||
LocalConnectionFactoryBean factory = new LocalConnectionFactoryBean();
|
||||
assertThat(factory.isSingleton()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectTypeIsNullIfConnectionFactoryHasNotBeenConfigured() throws Exception {
|
||||
void testGetObjectTypeIsNullIfConnectionFactoryHasNotBeenConfigured() {
|
||||
LocalConnectionFactoryBean factory = new LocalConnectionFactoryBean();
|
||||
assertThat(factory.getObjectType()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreatesVanillaConnectionFactoryIfNoConnectionManagerHasBeenConfigured() throws Exception {
|
||||
void testCreatesVanillaConnectionFactoryIfNoConnectionManagerHasBeenConfigured() throws Exception {
|
||||
final Object CONNECTION_FACTORY = new Object();
|
||||
ManagedConnectionFactory managedConnectionFactory = mock();
|
||||
given(managedConnectionFactory.createConnectionFactory()).willReturn(CONNECTION_FACTORY);
|
||||
@@ -64,7 +64,7 @@ public class LocalConnectionFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreatesManagedConnectionFactoryIfAConnectionManagerHasBeenConfigured() throws Exception {
|
||||
void testCreatesManagedConnectionFactoryIfAConnectionManagerHasBeenConfigured() throws Exception {
|
||||
ManagedConnectionFactory managedConnectionFactory = mock();
|
||||
ConnectionManager connectionManager = mock();
|
||||
LocalConnectionFactoryBean factory = new LocalConnectionFactoryBean();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,25 +38,25 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Juergen Hoeller
|
||||
* @since 05.08.2005
|
||||
*/
|
||||
public class JndiJtaTransactionManagerTests {
|
||||
class JndiJtaTransactionManagerTests {
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithDefaultJndiLookups1() throws Exception {
|
||||
void jtaTransactionManagerWithDefaultJndiLookups1() throws Exception {
|
||||
doTestJtaTransactionManagerWithDefaultJndiLookups("java:comp/TransactionManager", true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithDefaultJndiLookups2() throws Exception {
|
||||
void jtaTransactionManagerWithDefaultJndiLookups2() throws Exception {
|
||||
doTestJtaTransactionManagerWithDefaultJndiLookups("java:/TransactionManager", true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithDefaultJndiLookupsAndNoTmFound() throws Exception {
|
||||
void jtaTransactionManagerWithDefaultJndiLookupsAndNoTmFound() throws Exception {
|
||||
doTestJtaTransactionManagerWithDefaultJndiLookups("java:/tm", false, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithDefaultJndiLookupsAndNoUtFound() throws Exception {
|
||||
void jtaTransactionManagerWithDefaultJndiLookupsAndNoUtFound() throws Exception {
|
||||
doTestJtaTransactionManagerWithDefaultJndiLookups("java:/TransactionManager", true, false);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class JndiJtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithCustomJndiLookups() throws Exception {
|
||||
void jtaTransactionManagerWithCustomJndiLookups() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -166,7 +166,7 @@ public class JndiJtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithNotCacheUserTransaction() throws Exception {
|
||||
void jtaTransactionManagerWithNotCacheUserTransaction() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -218,7 +218,7 @@ public class JndiJtaTransactionManagerTests {
|
||||
* affect subsequent tests when all tests are run in the same JVM, as with Eclipse.
|
||||
*/
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty();
|
||||
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
|
||||
assertThat(TransactionSynchronizationManager.getCurrentTransactionName()).isNull();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,6 +35,7 @@ import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
import org.springframework.transaction.testfixture.TestTransactionExecutionListener;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
@@ -51,10 +52,10 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Juergen Hoeller
|
||||
* @since 12.05.2003
|
||||
*/
|
||||
public class JtaTransactionManagerTests {
|
||||
class JtaTransactionManagerTests {
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithCommit() throws Exception {
|
||||
void jtaTransactionManagerWithCommit() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -98,7 +99,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithCommitAndSynchronizationOnActual() throws Exception {
|
||||
void jtaTransactionManagerWithCommitAndSynchronizationOnActual() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -134,7 +135,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithCommitAndSynchronizationNever() throws Exception {
|
||||
void jtaTransactionManagerWithCommitAndSynchronizationNever() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(
|
||||
Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
@@ -165,7 +166,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithRollback() throws Exception {
|
||||
void jtaTransactionManagerWithRollback() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE);
|
||||
final TransactionSynchronization synch = mock();
|
||||
@@ -207,7 +208,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithRollbackAndSynchronizationOnActual() throws Exception {
|
||||
void jtaTransactionManagerWithRollbackAndSynchronizationOnActual() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE);
|
||||
final TransactionSynchronization synch = mock();
|
||||
@@ -242,7 +243,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithRollbackAndSynchronizationNever() throws Exception {
|
||||
void jtaTransactionManagerWithRollbackAndSynchronizationNever() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -277,7 +278,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithExistingTransactionAndRollbackOnly() throws Exception {
|
||||
void jtaTransactionManagerWithExistingTransactionAndRollbackOnly() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -302,7 +303,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithExistingTransactionAndException() throws Exception {
|
||||
void jtaTransactionManagerWithExistingTransactionAndException() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -328,7 +329,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithExistingTransactionAndCommitException() throws Exception {
|
||||
void jtaTransactionManagerWithExistingTransactionAndCommitException() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -354,7 +355,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithExistingTransactionAndRollbackOnlyAndNoGlobalRollback() throws Exception {
|
||||
void jtaTransactionManagerWithExistingTransactionAndRollbackOnlyAndNoGlobalRollback() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -380,7 +381,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithExistingTransactionAndExceptionAndNoGlobalRollback() throws Exception {
|
||||
void jtaTransactionManagerWithExistingTransactionAndExceptionAndNoGlobalRollback() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
final TransactionSynchronization synch = mock();
|
||||
@@ -405,7 +406,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithExistingTransactionAndJtaSynchronization() throws Exception {
|
||||
void jtaTransactionManagerWithExistingTransactionAndJtaSynchronization() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
TransactionManager tm = mock();
|
||||
MockJtaTransaction tx = new MockJtaTransaction();
|
||||
@@ -437,7 +438,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithExistingTransactionAndSynchronizationOnActual() throws Exception {
|
||||
void jtaTransactionManagerWithExistingTransactionAndSynchronizationOnActual() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -463,7 +464,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithExistingTransactionAndSynchronizationNever() throws Exception {
|
||||
void jtaTransactionManagerWithExistingTransactionAndSynchronizationNever() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -486,7 +487,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithExistingAndPropagationSupports() throws Exception {
|
||||
void jtaTransactionManagerWithExistingAndPropagationSupports() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -512,7 +513,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationSupports() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationSupports() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION);
|
||||
|
||||
@@ -537,7 +538,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationSupportsAndSynchronizationOnActual() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationSupportsAndSynchronizationOnActual() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION);
|
||||
|
||||
@@ -559,7 +560,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationSupportsAndSynchronizationNever() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationSupportsAndSynchronizationNever() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION);
|
||||
|
||||
@@ -581,7 +582,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationNotSupported() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationNotSupported() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
TransactionManager tm = mock();
|
||||
Transaction tx = mock();
|
||||
@@ -605,7 +606,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationRequiresNew() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationRequiresNew() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
TransactionManager tm = mock();
|
||||
Transaction tx = mock();
|
||||
@@ -653,7 +654,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationRequiresNewWithinSupports() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationRequiresNewWithinSupports() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION,
|
||||
Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
@@ -693,7 +694,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationRequiresNewAndExisting() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationRequiresNewAndExisting() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
TransactionManager tm = mock();
|
||||
Transaction tx = mock();
|
||||
@@ -718,7 +719,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationRequiresNewAndExistingWithSuspendException() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationRequiresNewAndExistingWithSuspendException() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
TransactionManager tm = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
@@ -739,7 +740,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationRequiresNewAndExistingWithBeginException() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationRequiresNewAndExistingWithBeginException() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
TransactionManager tm = mock();
|
||||
Transaction tx = mock();
|
||||
@@ -763,7 +764,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationRequiresNewAndAdapter() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationRequiresNewAndAdapter() throws Exception {
|
||||
TransactionManager tm = mock();
|
||||
Transaction tx = mock();
|
||||
given(tm.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
@@ -787,7 +788,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithPropagationRequiresNewAndSuspensionNotSupported() throws Exception {
|
||||
void jtaTransactionManagerWithPropagationRequiresNewAndSuspensionNotSupported() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -805,7 +806,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithIsolationLevel() throws Exception {
|
||||
void jtaTransactionManagerWithIsolationLevel() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION);
|
||||
|
||||
@@ -823,7 +824,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithSystemExceptionOnIsExisting() throws Exception {
|
||||
void jtaTransactionManagerWithSystemExceptionOnIsExisting() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willThrow(new SystemException("system exception"));
|
||||
|
||||
@@ -840,7 +841,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithNestedBegin() throws Exception {
|
||||
void jtaTransactionManagerWithNestedBegin() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -866,7 +867,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithNotSupportedExceptionOnNestedBegin() throws Exception {
|
||||
void jtaTransactionManagerWithNotSupportedExceptionOnNestedBegin() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
willThrow(new NotSupportedException("not supported")).given(ut).begin();
|
||||
@@ -885,7 +886,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithUnsupportedOperationExceptionOnNestedBegin() throws Exception {
|
||||
void jtaTransactionManagerWithUnsupportedOperationExceptionOnNestedBegin() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
willThrow(new UnsupportedOperationException("not supported")).given(ut).begin();
|
||||
@@ -904,7 +905,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithSystemExceptionOnBegin() throws Exception {
|
||||
void jtaTransactionManagerWithSystemExceptionOnBegin() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION);
|
||||
willThrow(new SystemException("system exception")).given(ut).begin();
|
||||
@@ -935,7 +936,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithRollbackExceptionOnCommit() throws Exception {
|
||||
void jtaTransactionManagerWithRollbackExceptionOnCommit() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION,
|
||||
Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
@@ -976,12 +977,12 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithNoExceptionOnGlobalRollbackOnly() throws Exception {
|
||||
void jtaTransactionManagerWithNoExceptionOnGlobalRollbackOnly() throws Exception {
|
||||
doTestJtaTransactionManagerWithNoExceptionOnGlobalRollbackOnly(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithNoExceptionOnGlobalRollbackOnlyAndFailEarly() throws Exception {
|
||||
void jtaTransactionManagerWithNoExceptionOnGlobalRollbackOnlyAndFailEarly() throws Exception {
|
||||
doTestJtaTransactionManagerWithNoExceptionOnGlobalRollbackOnly(true);
|
||||
}
|
||||
|
||||
@@ -1039,7 +1040,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithHeuristicMixedExceptionOnCommit() throws Exception {
|
||||
void jtaTransactionManagerWithHeuristicMixedExceptionOnCommit() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION,
|
||||
Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
@@ -1066,7 +1067,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithHeuristicRollbackExceptionOnCommit() throws Exception {
|
||||
void jtaTransactionManagerWithHeuristicRollbackExceptionOnCommit() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION,
|
||||
Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
@@ -1093,7 +1094,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithSystemExceptionOnCommit() throws Exception {
|
||||
void jtaTransactionManagerWithSystemExceptionOnCommit() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION,
|
||||
Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
@@ -1134,7 +1135,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithSystemExceptionOnRollback() throws Exception {
|
||||
void jtaTransactionManagerWithSystemExceptionOnRollback() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE);
|
||||
willThrow(new SystemException("system exception")).given(ut).rollback();
|
||||
@@ -1174,7 +1175,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithIllegalStateExceptionOnRollbackOnly() throws Exception {
|
||||
void jtaTransactionManagerWithIllegalStateExceptionOnRollbackOnly() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
willThrow(new IllegalStateException("no existing transaction")).given(ut).setRollbackOnly();
|
||||
@@ -1192,7 +1193,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithSystemExceptionOnRollbackOnly() throws Exception {
|
||||
void jtaTransactionManagerWithSystemExceptionOnRollbackOnly() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
|
||||
willThrow(new SystemException("system exception")).given(ut).setRollbackOnly();
|
||||
@@ -1217,7 +1218,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithDoubleCommit() throws Exception {
|
||||
void jtaTransactionManagerWithDoubleCommit() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION,
|
||||
Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);
|
||||
@@ -1237,7 +1238,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithDoubleRollback() throws Exception {
|
||||
void jtaTransactionManagerWithDoubleRollback() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -1257,7 +1258,7 @@ public class JtaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jtaTransactionManagerWithRollbackAndCommit() throws Exception {
|
||||
void jtaTransactionManagerWithRollbackAndCommit() throws Exception {
|
||||
UserTransaction ut = mock();
|
||||
given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE);
|
||||
|
||||
@@ -1295,7 +1296,7 @@ public class JtaTransactionManagerTests {
|
||||
* affect subsequent tests when all tests are run in the same JVM, as with Eclipse.
|
||||
*/
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty();
|
||||
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
|
||||
assertThat(TransactionSynchronizationManager.getCurrentTransactionName()).isNull();
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.transaction;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.support.CallbackPreferringPlatformTransactionManager;
|
||||
import org.springframework.transaction.support.SimpleTransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class MockCallbackPreferringTransactionManager implements CallbackPreferringPlatformTransactionManager {
|
||||
|
||||
private TransactionDefinition definition;
|
||||
|
||||
private TransactionStatus status;
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T execute(TransactionDefinition definition, TransactionCallback<T> callback) throws TransactionException {
|
||||
this.definition = definition;
|
||||
this.status = new SimpleTransactionStatus();
|
||||
return callback.doInTransaction(this.status);
|
||||
}
|
||||
|
||||
public TransactionDefinition getDefinition() {
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
public TransactionStatus getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TransactionStatus getTransaction(@Nullable TransactionDefinition definition) throws TransactionException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit(TransactionStatus status) throws TransactionException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(TransactionStatus status) throws TransactionException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ import jakarta.transaction.Synchronization;
|
||||
* @author Juergen Hoeller
|
||||
* @since 31.08.2004
|
||||
*/
|
||||
public class MockJtaTransaction implements jakarta.transaction.Transaction {
|
||||
class MockJtaTransaction implements jakarta.transaction.Transaction {
|
||||
|
||||
private Synchronization synchronization;
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.transaction;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @since 6.1
|
||||
*/
|
||||
public class TestTransactionExecutionListener implements TransactionExecutionListener {
|
||||
|
||||
public boolean beforeBeginCalled;
|
||||
|
||||
public boolean afterBeginCalled;
|
||||
|
||||
@Nullable
|
||||
public Throwable beginFailure;
|
||||
|
||||
public boolean beforeCommitCalled;
|
||||
|
||||
public boolean afterCommitCalled;
|
||||
|
||||
@Nullable
|
||||
public Throwable commitFailure;
|
||||
|
||||
public boolean beforeRollbackCalled;
|
||||
|
||||
public boolean afterRollbackCalled;
|
||||
|
||||
@Nullable
|
||||
public Throwable rollbackFailure;
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeBegin(TransactionExecution transactionState) {
|
||||
this.beforeBeginCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterBegin(TransactionExecution transactionState, @Nullable Throwable beginFailure) {
|
||||
this.afterBeginCalled = true;
|
||||
this.beginFailure = beginFailure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCommit(TransactionExecution transactionState) {
|
||||
this.beforeCommitCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCommit(TransactionExecution transactionState, @Nullable Throwable commitFailure) {
|
||||
this.afterCommitCalled = true;
|
||||
this.commitFailure = commitFailure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRollback(TransactionExecution transactionState) {
|
||||
this.beforeRollbackCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterRollback(TransactionExecution transactionState, @Nullable Throwable rollbackFailure) {
|
||||
this.afterRollbackCalled = true;
|
||||
this.rollbackFailure = rollbackFailure;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,22 +33,22 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Torsten Juergeleit
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class TxNamespaceHandlerEventTests {
|
||||
class TxNamespaceHandlerEventTests {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
private CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
|
||||
private final CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
void setUp() {
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
reader.setEventListener(this.eventListener);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("txNamespaceHandlerTests.xml", getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void componentEventReceived() {
|
||||
void componentEventReceived() {
|
||||
ComponentDefinition component = this.eventListener.getComponentDefinition("txAdvice");
|
||||
assertThat(component).isInstanceOf(BeanComponentDefinition.class);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Rob Harrop
|
||||
* @author Adrian Colyer
|
||||
*/
|
||||
public class TxNamespaceHandlerTests {
|
||||
class TxNamespaceHandlerTests {
|
||||
|
||||
private ApplicationContext context;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TxNamespaceHandlerTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() throws Exception {
|
||||
this.context = new ClassPathXmlApplicationContext("txNamespaceHandlerTests.xml", getClass());
|
||||
this.getAgeMethod = ITestBean.class.getMethod("getAge");
|
||||
this.setAgeMethod = ITestBean.class.getMethod("setAge", int.class);
|
||||
@@ -55,13 +55,13 @@ public class TxNamespaceHandlerTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void isProxy() {
|
||||
void isProxy() {
|
||||
ITestBean bean = getTestBean();
|
||||
assertThat(AopUtils.isAopProxy(bean)).as("testBean is not a proxy").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokeTransactional() {
|
||||
void invokeTransactional() {
|
||||
ITestBean testBean = getTestBean();
|
||||
CallCountingTransactionManager ptm = (CallCountingTransactionManager) context.getBean("transactionManager");
|
||||
|
||||
@@ -85,7 +85,7 @@ public class TxNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackRules() {
|
||||
void rollbackRules() {
|
||||
TransactionInterceptor txInterceptor = (TransactionInterceptor) context.getBean("txRollbackAdvice");
|
||||
TransactionAttributeSource txAttrSource = txInterceptor.getTransactionAttributeSource();
|
||||
TransactionAttribute txAttr = txAttrSource.getTransactionAttribute(getAgeMethod,ITestBean.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,10 +48,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Sam Brannen
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class AnnotationTransactionAttributeSourceTests {
|
||||
class AnnotationTransactionAttributeSourceTests {
|
||||
|
||||
@Test
|
||||
public void serializable() throws Exception {
|
||||
void serializable() throws Exception {
|
||||
TestBean1 tb = new TestBean1();
|
||||
CallCountingTransactionManager ptm = new CallCountingTransactionManager();
|
||||
AnnotationTransactionAttributeSource tas = new AnnotationTransactionAttributeSource();
|
||||
@@ -75,7 +75,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullOrEmpty() throws Exception {
|
||||
void nullOrEmpty() throws Exception {
|
||||
Method method = Empty.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -90,7 +90,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
* but the attribute is defined on the target class.
|
||||
*/
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnClassMethod() throws Exception {
|
||||
void transactionAttributeDeclaredOnClassMethod() throws Exception {
|
||||
Method classMethod = ITestBean1.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -106,7 +106,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
* but the attribute is defined on the target class.
|
||||
*/
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnCglibClassMethod() throws Exception {
|
||||
void transactionAttributeDeclaredOnCglibClassMethod() throws Exception {
|
||||
Method classMethod = ITestBean1.class.getMethod("getAge");
|
||||
TestBean1 tb = new TestBean1();
|
||||
ProxyFactory pf = new ProxyFactory(tb);
|
||||
@@ -125,7 +125,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
* Test case where attribute is on the interface method.
|
||||
*/
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnInterfaceMethodOnly() throws Exception {
|
||||
void transactionAttributeDeclaredOnInterfaceMethodOnly() throws Exception {
|
||||
Method interfaceMethod = ITestBean2.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -139,7 +139,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
* Test that when an attribute exists on both class and interface, class takes precedence.
|
||||
*/
|
||||
@Test
|
||||
public void transactionAttributeOnTargetClassMethodOverridesAttributeOnInterfaceMethod() throws Exception {
|
||||
void transactionAttributeOnTargetClassMethodOverridesAttributeOnInterfaceMethod() throws Exception {
|
||||
Method interfaceMethod = ITestBean3.class.getMethod("getAge");
|
||||
Method interfaceMethod2 = ITestBean3.class.getMethod("setAge", int.class);
|
||||
Method interfaceMethod3 = ITestBean3.class.getMethod("getName");
|
||||
@@ -169,7 +169,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackRulesAreApplied() throws Exception {
|
||||
void rollbackRulesAreApplied() throws Exception {
|
||||
Method method = TestBean3.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -195,7 +195,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void labelsAreApplied() throws Exception {
|
||||
void labelsAreApplied() throws Exception {
|
||||
Method method = TestBean11.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -214,7 +214,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
* if not specified on method.
|
||||
*/
|
||||
@Test
|
||||
public void defaultsToClassTransactionAttribute() throws Exception {
|
||||
void defaultsToClassTransactionAttribute() throws Exception {
|
||||
Method method = TestBean4.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -227,7 +227,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customClassAttributeDetected() throws Exception {
|
||||
void customClassAttributeDetected() throws Exception {
|
||||
Method method = TestBean5.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -240,7 +240,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMethodAttributeDetected() throws Exception {
|
||||
void customMethodAttributeDetected() throws Exception {
|
||||
Method method = TestBean6.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -253,7 +253,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customClassAttributeWithReadOnlyOverrideDetected() throws Exception {
|
||||
void customClassAttributeWithReadOnlyOverrideDetected() throws Exception {
|
||||
Method method = TestBean7.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -268,7 +268,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMethodAttributeWithReadOnlyOverrideDetected() throws Exception {
|
||||
void customMethodAttributeWithReadOnlyOverrideDetected() throws Exception {
|
||||
Method method = TestBean8.class.getMethod("getAge");
|
||||
|
||||
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
|
||||
@@ -283,7 +283,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customClassAttributeWithReadOnlyOverrideOnInterface() throws Exception {
|
||||
void customClassAttributeWithReadOnlyOverrideOnInterface() throws Exception {
|
||||
Method method = TestInterface9.class.getMethod("getAge");
|
||||
|
||||
Transactional annotation = AnnotationUtils.findAnnotation(method, Transactional.class);
|
||||
@@ -304,7 +304,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMethodAttributeWithReadOnlyOverrideOnInterface() throws Exception {
|
||||
void customMethodAttributeWithReadOnlyOverrideOnInterface() throws Exception {
|
||||
Method method = TestInterface10.class.getMethod("getAge");
|
||||
|
||||
Transactional annotation = AnnotationUtils.findAnnotation(method, Transactional.class);
|
||||
@@ -325,7 +325,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnClassMethodWithEjb3() throws Exception {
|
||||
void transactionAttributeDeclaredOnClassMethodWithEjb3() throws Exception {
|
||||
Method getAgeMethod = ITestBean1.class.getMethod("getAge");
|
||||
Method getNameMethod = ITestBean1.class.getMethod("getName");
|
||||
|
||||
@@ -337,7 +337,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnClassWithEjb3() throws Exception {
|
||||
void transactionAttributeDeclaredOnClassWithEjb3() throws Exception {
|
||||
Method getAgeMethod = ITestBean1.class.getMethod("getAge");
|
||||
Method getNameMethod = ITestBean1.class.getMethod("getName");
|
||||
|
||||
@@ -349,7 +349,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnInterfaceWithEjb3() throws Exception {
|
||||
void transactionAttributeDeclaredOnInterfaceWithEjb3() throws Exception {
|
||||
Method getAgeMethod = ITestEjb.class.getMethod("getAge");
|
||||
Method getNameMethod = ITestEjb.class.getMethod("getName");
|
||||
|
||||
@@ -361,7 +361,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnClassMethodWithJta() throws Exception {
|
||||
void transactionAttributeDeclaredOnClassMethodWithJta() throws Exception {
|
||||
Method getAgeMethod = ITestBean1.class.getMethod("getAge");
|
||||
Method getNameMethod = ITestBean1.class.getMethod("getName");
|
||||
|
||||
@@ -373,7 +373,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnClassWithJta() throws Exception {
|
||||
void transactionAttributeDeclaredOnClassWithJta() throws Exception {
|
||||
Method getAgeMethod = ITestBean1.class.getMethod("getAge");
|
||||
Method getNameMethod = ITestBean1.class.getMethod("getName");
|
||||
|
||||
@@ -385,7 +385,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnInterfaceWithJta() throws Exception {
|
||||
void transactionAttributeDeclaredOnInterfaceWithJta() throws Exception {
|
||||
Method getAgeMethod = ITestEjb.class.getMethod("getAge");
|
||||
Method getNameMethod = ITestEjb.class.getMethod("getName");
|
||||
|
||||
@@ -397,7 +397,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionAttributeDeclaredOnGroovyClass() throws Exception {
|
||||
void transactionAttributeDeclaredOnGroovyClass() throws Exception {
|
||||
Method getAgeMethod = ITestBean1.class.getMethod("getAge");
|
||||
Method getNameMethod = ITestBean1.class.getMethod("getName");
|
||||
Method getMetaClassMethod = GroovyObject.class.getMethod("getMetaClass");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,18 +44,18 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class AnnotationTransactionNamespaceHandlerTests {
|
||||
class AnnotationTransactionNamespaceHandlerTests {
|
||||
|
||||
private final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml");
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
this.context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isProxy() throws Exception {
|
||||
void isProxy() {
|
||||
TransactionalTestBean bean = getTestBean();
|
||||
assertThat(AopUtils.isAopProxy(bean)).as("testBean is not a proxy").isTrue();
|
||||
Map<String, Object> services = this.context.getBeansWithAnnotation(Service.class);
|
||||
@@ -63,7 +63,7 @@ public class AnnotationTransactionNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokeTransactional() throws Exception {
|
||||
void invokeTransactional() {
|
||||
TransactionalTestBean testBean = getTestBean();
|
||||
CallCountingTransactionManager ptm = (CallCountingTransactionManager) context.getBean("transactionManager");
|
||||
|
||||
@@ -87,7 +87,7 @@ public class AnnotationTransactionNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonPublicMethodsNotAdvised() {
|
||||
void nonPublicMethodsNotAdvised() {
|
||||
TransactionalTestBean testBean = getTestBean();
|
||||
CallCountingTransactionManager ptm = (CallCountingTransactionManager) context.getBean("transactionManager");
|
||||
|
||||
@@ -97,14 +97,14 @@ public class AnnotationTransactionNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mBeanExportAlsoWorks() throws Exception {
|
||||
void mBeanExportAlsoWorks() throws Exception {
|
||||
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
|
||||
Object actual = server.invoke(ObjectName.getInstance("test:type=TestBean"), "doSomething", new Object[0], new String[0]);
|
||||
assertThat(actual).isEqualTo("done");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionalEventListenerRegisteredProperly() {
|
||||
void transactionalEventListenerRegisteredProperly() {
|
||||
assertThat(this.context.containsBean(TransactionManagementConfigUtils
|
||||
.TRANSACTIONAL_EVENT_LISTENER_FACTORY_BEAN_NAME)).isTrue();
|
||||
assertThat(this.context.getBeansOfType(TransactionalEventListenerFactory.class)).hasSize(1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,10 +56,10 @@ import static org.assertj.core.api.Assertions.assertThatException;
|
||||
* @author Sam Brannen
|
||||
* @since 3.1
|
||||
*/
|
||||
public class EnableTransactionManagementTests {
|
||||
class EnableTransactionManagementTests {
|
||||
|
||||
@Test
|
||||
public void transactionProxyIsCreated() {
|
||||
void transactionProxyIsCreated() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
|
||||
EnableTxConfig.class, TxManagerConfig.class);
|
||||
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
|
||||
@@ -89,7 +89,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionProxyIsCreatedWithEnableOnSuperclass() {
|
||||
void transactionProxyIsCreatedWithEnableOnSuperclass() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
|
||||
InheritedEnableTxConfig.class, TxManagerConfig.class);
|
||||
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
|
||||
@@ -100,7 +100,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionProxyIsCreatedWithEnableOnExcludedSuperclass() {
|
||||
void transactionProxyIsCreatedWithEnableOnExcludedSuperclass() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
|
||||
ParentEnableTxConfig.class, ChildEnableTxConfig.class, TxManagerConfig.class);
|
||||
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
|
||||
@@ -111,7 +111,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void txManagerIsResolvedOnInvocationOfTransactionalMethod() {
|
||||
void txManagerIsResolvedOnInvocationOfTransactionalMethod() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
|
||||
EnableTxConfig.class, TxManagerConfig.class);
|
||||
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
|
||||
@@ -130,7 +130,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void txManagerIsResolvedCorrectlyWhenMultipleManagersArePresent() {
|
||||
void txManagerIsResolvedCorrectlyWhenMultipleManagersArePresent() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
|
||||
EnableTxConfig.class, MultiTxManagerConfig.class);
|
||||
assertThat(ctx.getBeansOfType(TransactionManager.class)).hasSize(2);
|
||||
@@ -151,7 +151,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void txManagerIsResolvedCorrectlyWhenMultipleManagersArePresentAndOneIsPrimary() {
|
||||
void txManagerIsResolvedCorrectlyWhenMultipleManagersArePresentAndOneIsPrimary() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
|
||||
EnableTxConfig.class, PrimaryMultiTxManagerConfig.class);
|
||||
assertThat(ctx.getBeansOfType(TransactionManager.class)).hasSize(2);
|
||||
@@ -173,7 +173,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void txManagerIsResolvedCorrectlyWithTxMgmtConfigurerAndPrimaryPresent() {
|
||||
void txManagerIsResolvedCorrectlyWithTxMgmtConfigurerAndPrimaryPresent() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
|
||||
EnableTxConfig.class, PrimaryTxManagerAndTxMgmtConfigurerConfig.class);
|
||||
assertThat(ctx.getBeansOfType(TransactionManager.class)).hasSize(2);
|
||||
@@ -195,7 +195,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void txManagerIsResolvedCorrectlyWithSingleTxManagerBeanAndTxMgmtConfigurer() {
|
||||
void txManagerIsResolvedCorrectlyWithSingleTxManagerBeanAndTxMgmtConfigurer() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
|
||||
EnableTxConfig.class, SingleTxManagerBeanAndTxMgmtConfigurerConfig.class);
|
||||
assertThat(ctx.getBeansOfType(TransactionManager.class)).hasSize(1);
|
||||
@@ -222,7 +222,6 @@ public class EnableTransactionManagementTests {
|
||||
* get loaded -- or in this case, attempted to be loaded at which point the test fails.
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void proxyTypeAspectJCausesRegistrationOfAnnotationTransactionAspect() {
|
||||
// should throw CNFE when trying to load AnnotationTransactionAspect.
|
||||
// Do you actually have org.springframework.aspects on the classpath?
|
||||
@@ -232,7 +231,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionalEventListenerRegisteredProperly() {
|
||||
void transactionalEventListenerRegisteredProperly() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(EnableTxConfig.class);
|
||||
assertThat(ctx.containsBean(TransactionManagementConfigUtils.TRANSACTIONAL_EVENT_LISTENER_FACTORY_BEAN_NAME)).isTrue();
|
||||
assertThat(ctx.getBeansOfType(TransactionalEventListenerFactory.class)).hasSize(1);
|
||||
@@ -240,7 +239,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void spr11915TransactionManagerAsManualSingleton() {
|
||||
void spr11915TransactionManagerAsManualSingleton() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr11915Config.class);
|
||||
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
|
||||
CallCountingTransactionManager txManager = ctx.getBean("qualifiedTransactionManager", CallCountingTransactionManager.class);
|
||||
@@ -259,7 +258,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void spr14322FindsOnInterfaceWithInterfaceProxy() {
|
||||
void spr14322FindsOnInterfaceWithInterfaceProxy() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14322ConfigA.class);
|
||||
TransactionalTestInterface bean = ctx.getBean(TransactionalTestInterface.class);
|
||||
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
|
||||
@@ -274,7 +273,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void spr14322FindsOnInterfaceWithCglibProxy() {
|
||||
void spr14322FindsOnInterfaceWithCglibProxy() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14322ConfigB.class);
|
||||
TransactionalTestInterface bean = ctx.getBean(TransactionalTestInterface.class);
|
||||
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
|
||||
@@ -289,7 +288,7 @@ public class EnableTransactionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gh24502AppliesTransactionOnlyOnAnnotatedInterface() {
|
||||
void gh24502AppliesTransactionOnlyOnAnnotatedInterface() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Gh24502ConfigA.class);
|
||||
Object bean = ctx.getBean("testBean");
|
||||
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ import static org.mockito.Mockito.mock;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class TransactionBeanRegistrationAotProcessorTests {
|
||||
class TransactionBeanRegistrationAotProcessorTests {
|
||||
|
||||
private final TransactionBeanRegistrationAotProcessor processor = new TransactionBeanRegistrationAotProcessor();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,23 +37,23 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class AnnotationDrivenTests {
|
||||
class AnnotationDrivenTests {
|
||||
|
||||
@Test
|
||||
public void withProxyTargetClass() throws Exception {
|
||||
void withProxyTargetClass() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass());
|
||||
doTestWithMultipleTransactionManagers(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withConfigurationClass() throws Exception {
|
||||
void withConfigurationClass() {
|
||||
ApplicationContext parent = new AnnotationConfigApplicationContext(TransactionManagerConfiguration.class);
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"annotationDrivenConfigurationClassTests.xml"}, getClass(), parent);
|
||||
doTestWithMultipleTransactionManagers(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withAnnotatedTransactionManagers() throws Exception {
|
||||
void withAnnotatedTransactionManagers() {
|
||||
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
|
||||
parent.registerBeanDefinition("transactionManager1", new RootBeanDefinition(SynchTransactionManager.class));
|
||||
parent.registerBeanDefinition("transactionManager2", new RootBeanDefinition(NoSynchTransactionManager.class));
|
||||
@@ -82,7 +82,6 @@ public class AnnotationDrivenTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void serializableWithPreviousUsage() throws Exception {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass());
|
||||
TransactionalService service = context.getBean("service", TransactionalService.class);
|
||||
@@ -92,7 +91,6 @@ public class AnnotationDrivenTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void serializableWithoutPreviousUsage() throws Exception {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass());
|
||||
TransactionalService service = context.getBean("service", TransactionalService.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,7 +63,7 @@ import static org.springframework.transaction.event.TransactionPhase.BEFORE_COMM
|
||||
* @author Juergen Hoeller
|
||||
* @since 6.1
|
||||
*/
|
||||
public class ReactiveTransactionalEventListenerTests {
|
||||
class ReactiveTransactionalEventListenerTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
|
||||
|
||||
@AfterEach
|
||||
public void closeContext() {
|
||||
void closeContext() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void immediately() {
|
||||
void immediately() {
|
||||
load(ImmediateTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("test").then(Mono.fromRunnable(() -> {
|
||||
getEventCollector().assertEvents(EventCollector.IMMEDIATELY, "test");
|
||||
@@ -92,7 +92,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void immediatelyImpactsCurrentTransaction() {
|
||||
void immediatelyImpactsCurrentTransaction() {
|
||||
load(ImmediateTestListener.class, BeforeCommitTestListener.class);
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.transactionalOperator.execute(status -> publishEvent("FAIL").then(Mono.fromRunnable(() -> {
|
||||
@@ -106,7 +106,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCompletionCommit() {
|
||||
void afterCompletionCommit() {
|
||||
load(AfterCompletionTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("test")
|
||||
.then(Mono.fromRunnable(() -> getEventCollector().assertNoEventReceived()))).blockFirst();
|
||||
@@ -115,7 +115,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCompletionRollback() {
|
||||
void afterCompletionRollback() {
|
||||
load(AfterCompletionTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("test").then(Mono.fromRunnable(() -> {
|
||||
getEventCollector().assertNoEventReceived();
|
||||
@@ -126,7 +126,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCommit() {
|
||||
void afterCommit() {
|
||||
load(AfterCompletionExplicitTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("test")
|
||||
.then(Mono.fromRunnable(() -> getEventCollector().assertNoEventReceived()))).blockFirst();
|
||||
@@ -135,7 +135,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCommitWithTransactionalComponentListenerProxiedViaDynamicProxy() {
|
||||
void afterCommitWithTransactionalComponentListenerProxiedViaDynamicProxy() {
|
||||
load(TransactionalComponentTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("SKIP")
|
||||
.then(Mono.fromRunnable(() -> getEventCollector().assertNoEventReceived()))).blockFirst();
|
||||
@@ -143,7 +143,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterRollback() {
|
||||
void afterRollback() {
|
||||
load(AfterCompletionExplicitTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("test").then(Mono.fromRunnable(() -> {
|
||||
getEventCollector().assertNoEventReceived();
|
||||
@@ -154,7 +154,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beforeCommit() {
|
||||
void beforeCommit() {
|
||||
load(BeforeCommitTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("test")
|
||||
.then(Mono.fromRunnable(() -> getEventCollector().assertNoEventReceived()))).blockFirst();
|
||||
@@ -163,7 +163,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noTransaction() {
|
||||
void noTransaction() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class,
|
||||
AfterCompletionExplicitTestListener.class);
|
||||
publishEvent("test");
|
||||
@@ -171,21 +171,21 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionDemarcationWithNotSupportedPropagation() {
|
||||
void transactionDemarcationWithNotSupportedPropagation() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class);
|
||||
getContext().getBean(TestBean.class).notSupported().block();
|
||||
getEventCollector().assertTotalEventsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionDemarcationWithSupportsPropagationAndNoTransaction() {
|
||||
void transactionDemarcationWithSupportsPropagationAndNoTransaction() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class);
|
||||
getContext().getBean(TestBean.class).supports().block();
|
||||
getEventCollector().assertTotalEventsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionDemarcationWithSupportsPropagationAndExistingTransaction() {
|
||||
void transactionDemarcationWithSupportsPropagationAndExistingTransaction() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class);
|
||||
this.transactionalOperator.execute(status -> getContext().getBean(TestBean.class).supports()
|
||||
.then(Mono.fromRunnable(() -> getEventCollector().assertNoEventReceived()))).blockFirst();
|
||||
@@ -193,14 +193,14 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionDemarcationWithRequiredPropagation() {
|
||||
void transactionDemarcationWithRequiredPropagation() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class);
|
||||
getContext().getBean(TestBean.class).required().block();
|
||||
getEventCollector().assertTotalEventsCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noTransactionWithFallbackExecution() {
|
||||
void noTransactionWithFallbackExecution() {
|
||||
load(FallbackExecutionTestListener.class);
|
||||
getContext().publishEvent("test");
|
||||
this.eventCollector.assertEvents(EventCollector.BEFORE_COMMIT, "test");
|
||||
@@ -211,7 +211,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conditionFoundOnTransactionalEventListener() {
|
||||
void conditionFoundOnTransactionalEventListener() {
|
||||
load(ImmediateTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("SKIP")
|
||||
.then(Mono.fromRunnable(() -> getEventCollector().assertNoEventReceived()))).blockFirst();
|
||||
@@ -219,7 +219,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCommitMetaAnnotation() {
|
||||
void afterCommitMetaAnnotation() {
|
||||
load(AfterCommitMetaAnnotationTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("test")
|
||||
.then(Mono.fromRunnable(() -> getEventCollector().assertNoEventReceived()))).blockFirst();
|
||||
@@ -228,7 +228,7 @@ public class ReactiveTransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conditionFoundOnMetaAnnotation() {
|
||||
void conditionFoundOnMetaAnnotation() {
|
||||
load(AfterCommitMetaAnnotationTestListener.class);
|
||||
this.transactionalOperator.execute(status -> publishEvent("SKIP")
|
||||
.then(Mono.fromRunnable(() -> getEventCollector().assertNoEventReceived()))).blockFirst();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThatRuntimeException;
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class TransactionalApplicationListenerAdapterTests {
|
||||
class TransactionalApplicationListenerAdapterTests {
|
||||
|
||||
@Test
|
||||
public void invokesCompletionCallbackOnSuccess() {
|
||||
void invokesCompletionCallbackOnSuccess() {
|
||||
CapturingSynchronizationCallback callback = new CapturingSynchronizationCallback();
|
||||
PayloadApplicationEvent<Object> event = new PayloadApplicationEvent<>(this, new Object());
|
||||
|
||||
@@ -48,7 +48,7 @@ public class TransactionalApplicationListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokesExceptionHandlerOnException() {
|
||||
void invokesExceptionHandlerOnException() {
|
||||
CapturingSynchronizationCallback callback = new CapturingSynchronizationCallback();
|
||||
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "event");
|
||||
RuntimeException ex = new RuntimeException("event");
|
||||
@@ -70,7 +70,7 @@ public class TransactionalApplicationListenerAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void useSpecifiedIdentifier() {
|
||||
void useSpecifiedIdentifier() {
|
||||
CapturingSynchronizationCallback callback = new CapturingSynchronizationCallback();
|
||||
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "event");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,22 +43,22 @@ import static org.assertj.core.api.Assertions.assertThatRuntimeException;
|
||||
* @author Juergen Hoeller
|
||||
* @author Oliver Drotbohm
|
||||
*/
|
||||
public class TransactionalApplicationListenerMethodAdapterTests {
|
||||
class TransactionalApplicationListenerMethodAdapterTests {
|
||||
|
||||
@Test
|
||||
public void defaultPhase() {
|
||||
void defaultPhase() {
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "defaultPhase", String.class);
|
||||
assertPhase(m, TransactionPhase.AFTER_COMMIT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void phaseSet() {
|
||||
void phaseSet() {
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "phaseSet", String.class);
|
||||
assertPhase(m, TransactionPhase.AFTER_ROLLBACK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void phaseAndClassesSet() {
|
||||
void phaseAndClassesSet() {
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "phaseAndClassesSet");
|
||||
assertPhase(m, TransactionPhase.AFTER_COMPLETION);
|
||||
supportsEventType(true, m, createGenericEventType(String.class));
|
||||
@@ -67,7 +67,7 @@ public class TransactionalApplicationListenerMethodAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valueSet() {
|
||||
void valueSet() {
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "valueSet");
|
||||
assertPhase(m, TransactionPhase.AFTER_COMMIT);
|
||||
supportsEventType(true, m, createGenericEventType(String.class));
|
||||
@@ -75,7 +75,7 @@ public class TransactionalApplicationListenerMethodAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokesCompletionCallbackOnSuccess() {
|
||||
void invokesCompletionCallbackOnSuccess() {
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "defaultPhase", String.class);
|
||||
CapturingSynchronizationCallback callback = new CapturingSynchronizationCallback();
|
||||
PayloadApplicationEvent<Object> event = new PayloadApplicationEvent<>(this, new Object());
|
||||
@@ -92,7 +92,7 @@ public class TransactionalApplicationListenerMethodAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokesExceptionHandlerOnException() {
|
||||
void invokesExceptionHandlerOnException() {
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "throwing", String.class);
|
||||
CapturingSynchronizationCallback callback = new CapturingSynchronizationCallback();
|
||||
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "event");
|
||||
@@ -113,7 +113,7 @@ public class TransactionalApplicationListenerMethodAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usesAnnotatedIdentifier() {
|
||||
void usesAnnotatedIdentifier() {
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "identified", String.class);
|
||||
CapturingSynchronizationCallback callback = new CapturingSynchronizationCallback();
|
||||
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "event");
|
||||
@@ -130,28 +130,28 @@ public class TransactionalApplicationListenerMethodAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withTransactionalAnnotation() {
|
||||
void withTransactionalAnnotation() {
|
||||
RestrictedTransactionalEventListenerFactory factory = new RestrictedTransactionalEventListenerFactory();
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "withTransactionalAnnotation", String.class);
|
||||
assertThatIllegalStateException().isThrownBy(() -> factory.createApplicationListener("test", SampleEvents.class, m));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withTransactionalRequiresNewAnnotation() {
|
||||
void withTransactionalRequiresNewAnnotation() {
|
||||
RestrictedTransactionalEventListenerFactory factory = new RestrictedTransactionalEventListenerFactory();
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "withTransactionalRequiresNewAnnotation", String.class);
|
||||
assertThatNoException().isThrownBy(() -> factory.createApplicationListener("test", SampleEvents.class, m));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withTransactionalNotSupportedAnnotation() {
|
||||
void withTransactionalNotSupportedAnnotation() {
|
||||
RestrictedTransactionalEventListenerFactory factory = new RestrictedTransactionalEventListenerFactory();
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "withTransactionalNotSupportedAnnotation", String.class);
|
||||
assertThatNoException().isThrownBy(() -> factory.createApplicationListener("test", SampleEvents.class, m));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withAsyncTransactionalAnnotation() {
|
||||
void withAsyncTransactionalAnnotation() {
|
||||
RestrictedTransactionalEventListenerFactory factory = new RestrictedTransactionalEventListenerFactory();
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class, "withAsyncTransactionalAnnotation", String.class);
|
||||
assertThatNoException().isThrownBy(() -> factory.createApplicationListener("test", SampleEvents.class, m));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ import static org.springframework.transaction.event.TransactionPhase.BEFORE_COMM
|
||||
* @author Sam Brannen
|
||||
* @since 4.2
|
||||
*/
|
||||
public class TransactionalEventListenerTests {
|
||||
class TransactionalEventListenerTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class TransactionalEventListenerTests {
|
||||
|
||||
|
||||
@AfterEach
|
||||
public void closeContext() {
|
||||
void closeContext() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class TransactionalEventListenerTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void immediately() {
|
||||
void immediately() {
|
||||
load(ImmediateTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("test");
|
||||
@@ -96,7 +96,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void immediatelyImpactsCurrentTransaction() {
|
||||
void immediatelyImpactsCurrentTransaction() {
|
||||
load(ImmediateTestListener.class, BeforeCommitTestListener.class);
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.transactionTemplate.execute(status -> {
|
||||
@@ -111,7 +111,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCompletionCommit() {
|
||||
void afterCompletionCommit() {
|
||||
load(AfterCompletionTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("test");
|
||||
@@ -123,7 +123,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCompletionRollback() {
|
||||
void afterCompletionRollback() {
|
||||
load(AfterCompletionTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("test");
|
||||
@@ -136,7 +136,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCommit() {
|
||||
void afterCommit() {
|
||||
load(AfterCompletionExplicitTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("test");
|
||||
@@ -148,7 +148,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCommitWithTransactionalComponentListenerProxiedViaDynamicProxy() {
|
||||
void afterCommitWithTransactionalComponentListenerProxiedViaDynamicProxy() {
|
||||
load(TransactionalComponentTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("SKIP");
|
||||
@@ -159,7 +159,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCommitWithTransactionalComponentListenerWithInterfaceProxy() {
|
||||
void afterCommitWithTransactionalComponentListenerWithInterfaceProxy() {
|
||||
load(TransactionalComponentTestListenerWithInterface.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("SKIP");
|
||||
@@ -170,7 +170,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterRollback() {
|
||||
void afterRollback() {
|
||||
load(AfterCompletionExplicitTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("test");
|
||||
@@ -183,7 +183,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterRollbackWithCustomExecutor() {
|
||||
void afterRollbackWithCustomExecutor() {
|
||||
load(AfterCompletionExplicitTestListener.class, MulticasterWithCustomExecutor.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("test");
|
||||
@@ -196,7 +196,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beforeCommit() {
|
||||
void beforeCommit() {
|
||||
load(BeforeCommitTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
TransactionSynchronizationManager.registerSynchronization(new EventTransactionSynchronization(10) {
|
||||
@@ -222,7 +222,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beforeCommitWithException() { // Validates the custom synchronization is invoked
|
||||
void beforeCommitWithException() { // Validates the custom synchronization is invoked
|
||||
load(BeforeCommitTestListener.class);
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.transactionTemplate.execute(status -> {
|
||||
@@ -241,7 +241,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regularTransaction() {
|
||||
void regularTransaction() {
|
||||
load(ImmediateTestListener.class, BeforeCommitTestListener.class, AfterCompletionExplicitTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
TransactionSynchronizationManager.registerSynchronization(new EventTransactionSynchronization(10) {
|
||||
@@ -268,7 +268,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noTransaction() {
|
||||
void noTransaction() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class,
|
||||
AfterCompletionExplicitTestListener.class);
|
||||
this.context.publishEvent("test");
|
||||
@@ -276,21 +276,21 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionDemarcationWithNotSupportedPropagation() {
|
||||
void transactionDemarcationWithNotSupportedPropagation() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class);
|
||||
getContext().getBean(TestBean.class).notSupported();
|
||||
getEventCollector().assertTotalEventsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionDemarcationWithSupportsPropagationAndNoTransaction() {
|
||||
void transactionDemarcationWithSupportsPropagationAndNoTransaction() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class);
|
||||
getContext().getBean(TestBean.class).supports();
|
||||
getEventCollector().assertTotalEventsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionDemarcationWithSupportsPropagationAndExistingTransaction() {
|
||||
void transactionDemarcationWithSupportsPropagationAndExistingTransaction() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().getBean(TestBean.class).supports();
|
||||
@@ -301,14 +301,14 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionDemarcationWithRequiredPropagation() {
|
||||
void transactionDemarcationWithRequiredPropagation() {
|
||||
load(BeforeCommitTestListener.class, AfterCompletionTestListener.class);
|
||||
getContext().getBean(TestBean.class).required();
|
||||
getEventCollector().assertTotalEventsCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noTransactionWithFallbackExecution() {
|
||||
void noTransactionWithFallbackExecution() {
|
||||
load(FallbackExecutionTestListener.class);
|
||||
this.context.publishEvent("test");
|
||||
this.eventCollector.assertEvents(EventCollector.BEFORE_COMMIT, "test");
|
||||
@@ -319,7 +319,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conditionFoundOnTransactionalEventListener() {
|
||||
void conditionFoundOnTransactionalEventListener() {
|
||||
load(ImmediateTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("SKIP");
|
||||
@@ -330,7 +330,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterCommitMetaAnnotation() {
|
||||
void afterCommitMetaAnnotation() {
|
||||
load(AfterCommitMetaAnnotationTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("test");
|
||||
@@ -342,7 +342,7 @@ public class TransactionalEventListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conditionFoundOnMetaAnnotation() {
|
||||
void conditionFoundOnMetaAnnotation() {
|
||||
load(AfterCommitMetaAnnotationTestListener.class);
|
||||
this.transactionTemplate.execute(status -> {
|
||||
getContext().publishEvent("SKIP");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,7 +55,7 @@ public abstract class AbstractReactiveTransactionAspectTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() throws Exception {
|
||||
getNameMethod = TestBean.class.getMethod("getName");
|
||||
setNameMethod = TestBean.class.getMethod("setName", String.class);
|
||||
exceptionalMethod = TestBean.class.getMethod("exceptional", Throwable.class);
|
||||
@@ -63,7 +63,7 @@ public abstract class AbstractReactiveTransactionAspectTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void noTransaction() throws Exception {
|
||||
void noTransaction() throws Exception {
|
||||
ReactiveTransactionManager rtm = mock();
|
||||
|
||||
DefaultTestBean tb = new DefaultTestBean();
|
||||
@@ -86,7 +86,7 @@ public abstract class AbstractReactiveTransactionAspectTests {
|
||||
* Check that a transaction is created and committed.
|
||||
*/
|
||||
@Test
|
||||
public void transactionShouldSucceed() throws Exception {
|
||||
void transactionShouldSucceed() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
|
||||
@@ -112,7 +112,7 @@ public abstract class AbstractReactiveTransactionAspectTests {
|
||||
* Check that two transactions are created and committed.
|
||||
*/
|
||||
@Test
|
||||
public void twoTransactionsShouldSucceed() throws Exception {
|
||||
void twoTransactionsShouldSucceed() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
MapTransactionAttributeSource tas1 = new MapTransactionAttributeSource();
|
||||
@@ -144,7 +144,7 @@ public abstract class AbstractReactiveTransactionAspectTests {
|
||||
* Check that a transaction is created and committed.
|
||||
*/
|
||||
@Test
|
||||
public void transactionShouldSucceedWithNotNew() throws Exception {
|
||||
void transactionShouldSucceedWithNotNew() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
|
||||
@@ -168,42 +168,42 @@ public abstract class AbstractReactiveTransactionAspectTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void rollbackOnCheckedException() throws Throwable {
|
||||
void rollbackOnCheckedException() throws Throwable {
|
||||
doTestRollbackOnException(new Exception(), true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noRollbackOnCheckedException() throws Throwable {
|
||||
void noRollbackOnCheckedException() throws Throwable {
|
||||
doTestRollbackOnException(new Exception(), false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackOnUncheckedException() throws Throwable {
|
||||
void rollbackOnUncheckedException() throws Throwable {
|
||||
doTestRollbackOnException(new RuntimeException(), true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noRollbackOnUncheckedException() throws Throwable {
|
||||
void noRollbackOnUncheckedException() throws Throwable {
|
||||
doTestRollbackOnException(new RuntimeException(), false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackOnCheckedExceptionWithRollbackException() throws Throwable {
|
||||
void rollbackOnCheckedExceptionWithRollbackException() throws Throwable {
|
||||
doTestRollbackOnException(new Exception(), true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noRollbackOnCheckedExceptionWithRollbackException() throws Throwable {
|
||||
void noRollbackOnCheckedExceptionWithRollbackException() throws Throwable {
|
||||
doTestRollbackOnException(new Exception(), false, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackOnUncheckedExceptionWithRollbackException() throws Throwable {
|
||||
void rollbackOnUncheckedExceptionWithRollbackException() throws Throwable {
|
||||
doTestRollbackOnException(new RuntimeException(), true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noRollbackOnUncheckedExceptionWithRollbackException() throws Throwable {
|
||||
void noRollbackOnUncheckedExceptionWithRollbackException() throws Throwable {
|
||||
doTestRollbackOnException(new RuntimeException(), false, true);
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ public abstract class AbstractReactiveTransactionAspectTests {
|
||||
* Shouldn't invoke target method.
|
||||
*/
|
||||
@Test
|
||||
public void cannotCreateTransaction() throws Exception {
|
||||
void cannotCreateTransaction() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
Method m = getNameMethod;
|
||||
@@ -311,7 +311,7 @@ public abstract class AbstractReactiveTransactionAspectTests {
|
||||
* infrastructure exception was thrown to the client
|
||||
*/
|
||||
@Test
|
||||
public void cannotCommitTransaction() throws Exception {
|
||||
void cannotCommitTransaction() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
Method m = setNameMethod;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,6 @@ import org.springframework.beans.testfixture.beans.ITestBean;
|
||||
import org.springframework.beans.testfixture.beans.TestBean;
|
||||
import org.springframework.dao.OptimisticLockingFailureException;
|
||||
import org.springframework.transaction.CannotCreateTransactionException;
|
||||
import org.springframework.transaction.MockCallbackPreferringTransactionManager;
|
||||
import org.springframework.transaction.NoTransactionException;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
@@ -33,6 +32,7 @@ import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
import org.springframework.transaction.UnexpectedRollbackException;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo;
|
||||
import org.springframework.transaction.testfixture.MockCallbackPreferringTransactionManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
@@ -66,7 +66,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() throws Exception {
|
||||
getNameMethod = ITestBean.class.getMethod("getName");
|
||||
setNameMethod = ITestBean.class.getMethod("setName", String.class);
|
||||
exceptionalMethod = ITestBean.class.getMethod("exceptional", Throwable.class);
|
||||
@@ -74,7 +74,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void noTransaction() throws Exception {
|
||||
void noTransaction() throws Exception {
|
||||
PlatformTransactionManager ptm = mock();
|
||||
|
||||
TestBean tb = new TestBean();
|
||||
@@ -97,7 +97,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
* Check that a transaction is created and committed.
|
||||
*/
|
||||
@Test
|
||||
public void transactionShouldSucceed() throws Exception {
|
||||
void transactionShouldSucceed() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
|
||||
@@ -123,7 +123,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
* CallbackPreferringPlatformTransactionManager.
|
||||
*/
|
||||
@Test
|
||||
public void transactionShouldSucceedWithCallbackPreference() throws Exception {
|
||||
void transactionShouldSucceedWithCallbackPreference() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
|
||||
@@ -143,7 +143,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionExceptionPropagatedWithCallbackPreference() throws Throwable {
|
||||
void transactionExceptionPropagatedWithCallbackPreference() throws Throwable {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
|
||||
@@ -167,7 +167,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
* Check that two transactions are created and committed.
|
||||
*/
|
||||
@Test
|
||||
public void twoTransactionsShouldSucceed() throws Exception {
|
||||
void twoTransactionsShouldSucceed() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
MapTransactionAttributeSource tas1 = new MapTransactionAttributeSource();
|
||||
@@ -196,7 +196,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
* Check that a transaction is created and committed.
|
||||
*/
|
||||
@Test
|
||||
public void transactionShouldSucceedWithNotNew() throws Exception {
|
||||
void transactionShouldSucceedWithNotNew() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
|
||||
@@ -219,7 +219,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enclosingTransactionWithNonTransactionMethodOnAdvisedInside() throws Throwable {
|
||||
void enclosingTransactionWithNonTransactionMethodOnAdvisedInside() throws Throwable {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
|
||||
@@ -234,7 +234,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
|
||||
TestBean outer = new TestBean() {
|
||||
@Override
|
||||
public void exceptional(Throwable t) throws Throwable {
|
||||
public void exceptional(Throwable t) {
|
||||
TransactionInfo ti = TransactionAspectSupport.currentTransactionInfo();
|
||||
assertThat(ti.hasTransaction()).isTrue();
|
||||
assertThat(getSpouse().getName()).isEqualTo(spouseName);
|
||||
@@ -265,7 +265,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enclosingTransactionWithNestedTransactionOnAdvisedInside() throws Throwable {
|
||||
void enclosingTransactionWithNestedTransactionOnAdvisedInside() throws Throwable {
|
||||
final TransactionAttribute outerTxatt = new DefaultTransactionAttribute();
|
||||
final TransactionAttribute innerTxatt = new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_NESTED);
|
||||
|
||||
@@ -287,7 +287,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
|
||||
TestBean outer = new TestBean() {
|
||||
@Override
|
||||
public void exceptional(Throwable t) throws Throwable {
|
||||
public void exceptional(Throwable t) {
|
||||
TransactionInfo ti = TransactionAspectSupport.currentTransactionInfo();
|
||||
assertThat(ti.hasTransaction()).isTrue();
|
||||
assertThat(ti.getTransactionAttribute()).isEqualTo(outerTxatt);
|
||||
@@ -322,42 +322,42 @@ public abstract class AbstractTransactionAspectTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackOnCheckedException() throws Throwable {
|
||||
void rollbackOnCheckedException() throws Throwable {
|
||||
doTestRollbackOnException(new Exception(), true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noRollbackOnCheckedException() throws Throwable {
|
||||
void noRollbackOnCheckedException() throws Throwable {
|
||||
doTestRollbackOnException(new Exception(), false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackOnUncheckedException() throws Throwable {
|
||||
void rollbackOnUncheckedException() throws Throwable {
|
||||
doTestRollbackOnException(new RuntimeException(), true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noRollbackOnUncheckedException() throws Throwable {
|
||||
void noRollbackOnUncheckedException() throws Throwable {
|
||||
doTestRollbackOnException(new RuntimeException(), false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackOnCheckedExceptionWithRollbackException() throws Throwable {
|
||||
void rollbackOnCheckedExceptionWithRollbackException() throws Throwable {
|
||||
doTestRollbackOnException(new Exception(), true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noRollbackOnCheckedExceptionWithRollbackException() throws Throwable {
|
||||
void noRollbackOnCheckedExceptionWithRollbackException() throws Throwable {
|
||||
doTestRollbackOnException(new Exception(), false, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackOnUncheckedExceptionWithRollbackException() throws Throwable {
|
||||
void rollbackOnUncheckedExceptionWithRollbackException() throws Throwable {
|
||||
doTestRollbackOnException(new RuntimeException(), true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noRollbackOnUncheckedExceptionWithRollbackException() throws Throwable {
|
||||
void noRollbackOnUncheckedExceptionWithRollbackException() throws Throwable {
|
||||
doTestRollbackOnException(new RuntimeException(), false, true);
|
||||
}
|
||||
|
||||
@@ -367,7 +367,6 @@ public abstract class AbstractTransactionAspectTests {
|
||||
* @param ex exception to be thrown by the target
|
||||
* @param shouldRollback whether this should cause a transaction rollback
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
protected void doTestRollbackOnException(
|
||||
final Exception ex, final boolean shouldRollback, boolean rollbackException) throws Exception {
|
||||
|
||||
@@ -429,7 +428,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
* Test that TransactionStatus.setRollbackOnly works.
|
||||
*/
|
||||
@Test
|
||||
public void programmaticRollback() throws Exception {
|
||||
void programmaticRollback() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
Method m = getNameMethod;
|
||||
@@ -464,7 +463,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
* Shouldn't invoke target method.
|
||||
*/
|
||||
@Test
|
||||
public void cannotCreateTransaction() throws Exception {
|
||||
void cannotCreateTransaction() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
Method m = getNameMethod;
|
||||
@@ -500,7 +499,7 @@ public abstract class AbstractTransactionAspectTests {
|
||||
* infrastructure exception was thrown to the client
|
||||
*/
|
||||
@Test
|
||||
public void cannotCommitTransaction() throws Exception {
|
||||
void cannotCommitTransaction() throws Exception {
|
||||
TransactionAttribute txatt = new DefaultTransactionAttribute();
|
||||
|
||||
Method m = setNameMethod;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,13 +54,13 @@ import static org.mockito.Mockito.verifyNoInteractions;
|
||||
* @author Juergen Hoeller
|
||||
* @since 23.04.2003
|
||||
*/
|
||||
public class BeanFactoryTransactionTests {
|
||||
class BeanFactoryTransactionTests {
|
||||
|
||||
private DefaultListableBeanFactory factory;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
this.factory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(this.factory).loadBeanDefinitions(
|
||||
new ClassPathResource("transactionalBeanFactory.xml", getClass()));
|
||||
@@ -68,7 +68,7 @@ public class BeanFactoryTransactionTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetsAreNotTransactionalWithProxyFactory1() {
|
||||
void testGetsAreNotTransactionalWithProxyFactory1() {
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory1");
|
||||
assertThat(Proxy.isProxyClass(testBean.getClass())).as("testBean is a dynamic proxy").isTrue();
|
||||
boolean condition = testBean instanceof TransactionalProxy;
|
||||
@@ -77,7 +77,7 @@ public class BeanFactoryTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetsAreNotTransactionalWithProxyFactory2DynamicProxy() {
|
||||
void testGetsAreNotTransactionalWithProxyFactory2DynamicProxy() {
|
||||
this.factory.preInstantiateSingletons();
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2DynamicProxy");
|
||||
assertThat(Proxy.isProxyClass(testBean.getClass())).as("testBean is a dynamic proxy").isTrue();
|
||||
@@ -87,7 +87,7 @@ public class BeanFactoryTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetsAreNotTransactionalWithProxyFactory2Cglib() {
|
||||
void testGetsAreNotTransactionalWithProxyFactory2Cglib() {
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Cglib");
|
||||
assertThat(AopUtils.isCglibProxy(testBean)).as("testBean is CGLIB advised").isTrue();
|
||||
boolean condition = testBean instanceof TransactionalProxy;
|
||||
@@ -96,7 +96,7 @@ public class BeanFactoryTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyFactory2Lazy() {
|
||||
void testProxyFactory2Lazy() {
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Lazy");
|
||||
assertThat(factory.containsSingleton("target")).isFalse();
|
||||
assertThat(testBean.getAge()).isEqualTo(666);
|
||||
@@ -104,7 +104,7 @@ public class BeanFactoryTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCglibTransactionProxyImplementsNoInterfaces() {
|
||||
void testCglibTransactionProxyImplementsNoInterfaces() {
|
||||
ImplementsNoInterfaces ini = (ImplementsNoInterfaces) factory.getBean("cglibNoInterfaces");
|
||||
assertThat(AopUtils.isCglibProxy(ini)).as("testBean is CGLIB advised").isTrue();
|
||||
boolean condition = ini instanceof TransactionalProxy;
|
||||
@@ -121,7 +121,7 @@ public class BeanFactoryTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetsAreNotTransactionalWithProxyFactory3() {
|
||||
void testGetsAreNotTransactionalWithProxyFactory3() {
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory3");
|
||||
boolean condition = testBean instanceof DerivedTestBean;
|
||||
assertThat(condition).as("testBean is a full proxy").isTrue();
|
||||
@@ -184,7 +184,7 @@ public class BeanFactoryTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBeansOfTypeWithAbstract() {
|
||||
void testGetBeansOfTypeWithAbstract() {
|
||||
Map<String, ITestBean> beansOfType = factory.getBeansOfType(ITestBean.class, true, true);
|
||||
assertThat(beansOfType).isNotNull();
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class BeanFactoryTransactionTests {
|
||||
* Check that we fail gracefully if the user doesn't set any transaction attributes.
|
||||
*/
|
||||
@Test
|
||||
public void testNoTransactionAttributeSource() {
|
||||
void testNoTransactionAttributeSource() {
|
||||
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(() -> {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("noTransactionAttributeSource.xml", getClass()));
|
||||
@@ -205,7 +205,7 @@ public class BeanFactoryTransactionTests {
|
||||
* Test that we can set the target to a dynamic TargetSource.
|
||||
*/
|
||||
@Test
|
||||
public void testDynamicTargetSource() {
|
||||
void testDynamicTargetSource() {
|
||||
// Install facade
|
||||
CallCountingTransactionManager txMan = new CallCountingTransactionManager();
|
||||
PlatformTransactionManagerFacade.delegate = txMan;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,7 @@ import org.springframework.beans.testfixture.beans.TestBean;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public class ImplementsNoInterfaces {
|
||||
class ImplementsNoInterfaces {
|
||||
|
||||
private TestBean testBean;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import java.util.Map;
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class MapTransactionAttributeSource extends AbstractFallbackTransactionAttributeSource {
|
||||
class MapTransactionAttributeSource extends AbstractFallbackTransactionAttributeSource {
|
||||
|
||||
private final Map<Object, TransactionAttribute> attributeMap = new HashMap<>();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.transaction.TransactionStatus;
|
||||
* @author Rod Johnson
|
||||
* @since 26.04.2003
|
||||
*/
|
||||
public class PlatformTransactionManagerFacade implements PlatformTransactionManager {
|
||||
class PlatformTransactionManagerFacade implements PlatformTransactionManager {
|
||||
|
||||
/**
|
||||
* This member can be changed to change behavior class-wide.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,11 +22,11 @@ import org.springframework.transaction.ReactiveTransactionManager;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link TransactionInterceptor} with reactive methods.
|
||||
* Tests for {@link TransactionInterceptor} with reactive methods.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class ReactiveTransactionInterceptorTests extends AbstractReactiveTransactionAspectTests {
|
||||
class ReactiveTransactionInterceptorTests extends AbstractReactiveTransactionAspectTests {
|
||||
|
||||
@Override
|
||||
protected Object advised(Object target, ReactiveTransactionManager ptm, TransactionAttributeSource[] tas) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,7 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link RollbackRuleAttribute} class.
|
||||
* Tests for {@link RollbackRuleAttribute}.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Rick Evans
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,10 +25,10 @@ import org.springframework.core.testfixture.io.SerializationTestUtils;
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public class TransactionAttributeSourceAdvisorTests {
|
||||
class TransactionAttributeSourceAdvisorTests {
|
||||
|
||||
@Test
|
||||
public void serializability() throws Exception {
|
||||
void serializability() throws Exception {
|
||||
TransactionInterceptor ti = new TransactionInterceptor();
|
||||
ti.setTransactionAttributes(new Properties());
|
||||
TransactionAttributeSourceAdvisor tas = new TransactionAttributeSourceAdvisor(ti);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link TransactionAttributeSourceEditor}.
|
||||
* Tests for {@link TransactionAttributeSourceEditor}.
|
||||
*
|
||||
* <p>Format is: {@code FQN.Method=tx attribute representation}
|
||||
*
|
||||
@@ -34,13 +34,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
* @author Sam Brannen
|
||||
* @since 26.04.2003
|
||||
*/
|
||||
public class TransactionAttributeSourceEditorTests {
|
||||
class TransactionAttributeSourceEditorTests {
|
||||
|
||||
private final TransactionAttributeSourceEditor editor = new TransactionAttributeSourceEditor();
|
||||
|
||||
|
||||
@Test
|
||||
public void nullValue() throws Exception {
|
||||
void nullValue() throws Exception {
|
||||
editor.setAsText(null);
|
||||
TransactionAttributeSource tas = (TransactionAttributeSource) editor.getValue();
|
||||
|
||||
@@ -49,13 +49,13 @@ public class TransactionAttributeSourceEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidFormat() throws Exception {
|
||||
void invalidFormat() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
editor.setAsText("foo=bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchesSpecific() throws Exception {
|
||||
void matchesSpecific() throws Exception {
|
||||
editor.setAsText("""
|
||||
java.lang.Object.hashCode=PROPAGATION_REQUIRED
|
||||
java.lang.Object.equals=PROPAGATION_MANDATORY
|
||||
@@ -82,7 +82,7 @@ public class TransactionAttributeSourceEditorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchesAll() throws Exception {
|
||||
void matchesAll() throws Exception {
|
||||
editor.setAsText("java.lang.Object.*=PROPAGATION_REQUIRED");
|
||||
TransactionAttributeSource tas = (TransactionAttributeSource) editor.getValue();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import org.springframework.transaction.TransactionDefinition;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Unit tests for the various {@link TransactionAttributeSource} implementations.
|
||||
* Tests for the various {@link TransactionAttributeSource} implementations.
|
||||
*
|
||||
* @author Colin Sampaleanu
|
||||
* @author Juergen Hoeller
|
||||
@@ -35,10 +35,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @since 15.10.2003
|
||||
* @see org.springframework.transaction.interceptor.TransactionProxyFactoryBean
|
||||
*/
|
||||
public class TransactionAttributeSourceTests {
|
||||
class TransactionAttributeSourceTests {
|
||||
|
||||
@Test
|
||||
public void matchAlwaysTransactionAttributeSource() throws Exception {
|
||||
void matchAlwaysTransactionAttributeSource() throws Exception {
|
||||
MatchAlwaysTransactionAttributeSource tas = new MatchAlwaysTransactionAttributeSource();
|
||||
TransactionAttribute ta = tas.getTransactionAttribute(Object.class.getMethod("hashCode"), null);
|
||||
assertThat(ta).isNotNull();
|
||||
@@ -51,7 +51,7 @@ public class TransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameMatchTransactionAttributeSourceWithStarAtStartOfMethodName() throws Exception {
|
||||
void nameMatchTransactionAttributeSourceWithStarAtStartOfMethodName() throws Exception {
|
||||
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
||||
Properties attributes = new Properties();
|
||||
attributes.put("*ashCode", "PROPAGATION_REQUIRED");
|
||||
@@ -62,7 +62,7 @@ public class TransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameMatchTransactionAttributeSourceWithStarAtEndOfMethodName() throws Exception {
|
||||
void nameMatchTransactionAttributeSourceWithStarAtEndOfMethodName() throws Exception {
|
||||
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
||||
Properties attributes = new Properties();
|
||||
attributes.put("hashCod*", "PROPAGATION_REQUIRED");
|
||||
@@ -73,7 +73,7 @@ public class TransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameMatchTransactionAttributeSourceMostSpecificMethodNameIsDefinitelyMatched() throws Exception {
|
||||
void nameMatchTransactionAttributeSourceMostSpecificMethodNameIsDefinitelyMatched() throws Exception {
|
||||
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
||||
Properties attributes = new Properties();
|
||||
attributes.put("*", "PROPAGATION_REQUIRED");
|
||||
@@ -85,7 +85,7 @@ public class TransactionAttributeSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameMatchTransactionAttributeSourceWithEmptyMethodName() throws Exception {
|
||||
void nameMatchTransactionAttributeSourceWithEmptyMethodName() throws Exception {
|
||||
NameMatchTransactionAttributeSource tas = new NameMatchTransactionAttributeSource();
|
||||
Properties attributes = new Properties();
|
||||
attributes.put("", "PROPAGATION_MANDATORY");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Juergen Hoeller
|
||||
* @since 16.03.2003
|
||||
*/
|
||||
public class TransactionInterceptorTests extends AbstractTransactionAspectTests {
|
||||
class TransactionInterceptorTests extends AbstractTransactionAspectTests {
|
||||
|
||||
@Override
|
||||
protected Object advised(Object target, PlatformTransactionManager ptm, TransactionAttributeSource[] tas) {
|
||||
@@ -83,7 +83,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
* PlatformTransactionManager is.
|
||||
*/
|
||||
@Test
|
||||
public void serializableWithAttributeProperties() throws Exception {
|
||||
void serializableWithAttributeProperties() throws Exception {
|
||||
TransactionInterceptor ti = new TransactionInterceptor();
|
||||
Properties props = new Properties();
|
||||
props.setProperty("methodName", "PROPAGATION_REQUIRED");
|
||||
@@ -99,7 +99,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializableWithCompositeSource() throws Exception {
|
||||
void serializableWithCompositeSource() throws Exception {
|
||||
NameMatchTransactionAttributeSource tas1 = new NameMatchTransactionAttributeSource();
|
||||
Properties props = new Properties();
|
||||
props.setProperty("methodName", "PROPAGATION_REQUIRED");
|
||||
@@ -128,7 +128,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerWithNoBeanFactory() {
|
||||
void determineTransactionManagerWithNoBeanFactory() {
|
||||
PlatformTransactionManager transactionManager = mock();
|
||||
TransactionInterceptor ti = transactionInterceptorWithTransactionManager(transactionManager, null);
|
||||
|
||||
@@ -136,7 +136,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerWithNoBeanFactoryAndNoTransactionAttribute() {
|
||||
void determineTransactionManagerWithNoBeanFactoryAndNoTransactionAttribute() {
|
||||
PlatformTransactionManager transactionManager = mock();
|
||||
TransactionInterceptor ti = transactionInterceptorWithTransactionManager(transactionManager, null);
|
||||
|
||||
@@ -144,7 +144,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerWithNoTransactionAttribute() {
|
||||
void determineTransactionManagerWithNoTransactionAttribute() {
|
||||
BeanFactory beanFactory = mock();
|
||||
TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory);
|
||||
|
||||
@@ -152,7 +152,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerWithQualifierUnknown() {
|
||||
void determineTransactionManagerWithQualifierUnknown() {
|
||||
BeanFactory beanFactory = mock();
|
||||
TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory);
|
||||
DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
|
||||
@@ -164,7 +164,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerWithQualifierAndDefault() {
|
||||
void determineTransactionManagerWithQualifierAndDefault() {
|
||||
BeanFactory beanFactory = mock();
|
||||
PlatformTransactionManager transactionManager = mock();
|
||||
TransactionInterceptor ti = transactionInterceptorWithTransactionManager(transactionManager, beanFactory);
|
||||
@@ -178,7 +178,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerWithQualifierAndDefaultName() {
|
||||
void determineTransactionManagerWithQualifierAndDefaultName() {
|
||||
BeanFactory beanFactory = mock();
|
||||
associateTransactionManager(beanFactory, "defaultTransactionManager");
|
||||
TransactionInterceptor ti = transactionInterceptorWithTransactionManagerName(
|
||||
@@ -193,7 +193,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerWithEmptyQualifierAndDefaultName() {
|
||||
void determineTransactionManagerWithEmptyQualifierAndDefaultName() {
|
||||
BeanFactory beanFactory = mock();
|
||||
PlatformTransactionManager defaultTransactionManager
|
||||
= associateTransactionManager(beanFactory, "defaultTransactionManager");
|
||||
@@ -207,7 +207,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerWithQualifierSeveralTimes() {
|
||||
void determineTransactionManagerWithQualifierSeveralTimes() {
|
||||
BeanFactory beanFactory = mock();
|
||||
TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory);
|
||||
|
||||
@@ -226,7 +226,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerWithBeanNameSeveralTimes() {
|
||||
void determineTransactionManagerWithBeanNameSeveralTimes() {
|
||||
BeanFactory beanFactory = mock();
|
||||
TransactionInterceptor ti = transactionInterceptorWithTransactionManagerName(
|
||||
"fooTransactionManager", beanFactory);
|
||||
@@ -244,7 +244,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineTransactionManagerDefaultSeveralTimes() {
|
||||
void determineTransactionManagerDefaultSeveralTimes() {
|
||||
BeanFactory beanFactory = mock();
|
||||
TransactionInterceptor ti = simpleTransactionInterceptor(beanFactory);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,22 +26,22 @@ import org.springframework.transaction.CannotCreateTransactionException;
|
||||
import org.springframework.transaction.IllegalTransactionStateException;
|
||||
import org.springframework.transaction.ReactiveTransaction;
|
||||
import org.springframework.transaction.ReactiveTransactionManager;
|
||||
import org.springframework.transaction.TestTransactionExecutionListener;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
import org.springframework.transaction.testfixture.TestTransactionExecutionListener;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Unit tests for transactional support through {@link ReactiveTestTransactionManager}.
|
||||
* Tests for transactional support through {@link ReactiveTestTransactionManager}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class ReactiveTransactionSupportTests {
|
||||
class ReactiveTransactionSupportTests {
|
||||
|
||||
@Test
|
||||
public void noExistingTransaction() {
|
||||
void noExistingTransaction() {
|
||||
ReactiveTransactionManager tm = new ReactiveTestTransactionManager(false, true);
|
||||
|
||||
tm.getReactiveTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS))
|
||||
@@ -62,7 +62,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void existingTransaction() {
|
||||
void existingTransaction() {
|
||||
ReactiveTransactionManager tm = new ReactiveTestTransactionManager(true, true);
|
||||
|
||||
tm.getReactiveTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS))
|
||||
@@ -88,7 +88,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commitWithoutExistingTransaction() {
|
||||
void commitWithoutExistingTransaction() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(false, true);
|
||||
TestTransactionExecutionListener tl = new TestTransactionExecutionListener();
|
||||
tm.addListener(tl);
|
||||
@@ -112,7 +112,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackWithoutExistingTransaction() {
|
||||
void rollbackWithoutExistingTransaction() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(false, true);
|
||||
TestTransactionExecutionListener tl = new TestTransactionExecutionListener();
|
||||
tm.addListener(tl);
|
||||
@@ -136,7 +136,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackOnlyWithoutExistingTransaction() {
|
||||
void rollbackOnlyWithoutExistingTransaction() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(false, true);
|
||||
TestTransactionExecutionListener tl = new TestTransactionExecutionListener();
|
||||
tm.addListener(tl);
|
||||
@@ -161,7 +161,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commitWithExistingTransaction() {
|
||||
void commitWithExistingTransaction() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(true, true);
|
||||
TestTransactionExecutionListener tl = new TestTransactionExecutionListener();
|
||||
tm.addListener(tl);
|
||||
@@ -185,7 +185,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackWithExistingTransaction() {
|
||||
void rollbackWithExistingTransaction() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(true, true);
|
||||
TestTransactionExecutionListener tl = new TestTransactionExecutionListener();
|
||||
tm.addListener(tl);
|
||||
@@ -209,7 +209,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackOnlyWithExistingTransaction() {
|
||||
void rollbackOnlyWithExistingTransaction() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(true, true);
|
||||
TestTransactionExecutionListener tl = new TestTransactionExecutionListener();
|
||||
tm.addListener(tl);
|
||||
@@ -233,7 +233,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionTemplate() {
|
||||
void transactionTemplate() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(false, true);
|
||||
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
|
||||
|
||||
@@ -250,7 +250,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transactionTemplateWithException() {
|
||||
void transactionTemplateWithException() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(false, true);
|
||||
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
|
||||
RuntimeException ex = new RuntimeException("Some application exception");
|
||||
@@ -292,7 +292,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beginFailure() {
|
||||
void beginFailure() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(false, false);
|
||||
TestTransactionExecutionListener tl = new TestTransactionExecutionListener();
|
||||
tm.addListener(tl);
|
||||
@@ -313,7 +313,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commitFailure() {
|
||||
void commitFailure() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(false, TransactionSystemException::new, null);
|
||||
TestTransactionExecutionListener tl = new TestTransactionExecutionListener();
|
||||
tm.addListener(tl);
|
||||
@@ -334,7 +334,7 @@ public class ReactiveTransactionSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackFailure() {
|
||||
void rollbackFailure() {
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(false, null, TransactionSystemException::new);
|
||||
TestTransactionExecutionListener tl = new TestTransactionExecutionListener();
|
||||
tm.addListener(tl);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,13 +40,13 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Mark Paluch
|
||||
* @author Enric Sala
|
||||
*/
|
||||
public class TransactionalOperatorTests {
|
||||
class TransactionalOperatorTests {
|
||||
|
||||
ReactiveTestTransactionManager tm = new ReactiveTestTransactionManager(false, true);
|
||||
|
||||
|
||||
@Test
|
||||
public void commitWithMono() {
|
||||
void commitWithMono() {
|
||||
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
|
||||
Mono.just(true).as(operator::transactional)
|
||||
.as(StepVerifier::create)
|
||||
@@ -57,7 +57,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void monoSubscriptionNotCancelled() {
|
||||
void monoSubscriptionNotCancelled() {
|
||||
AtomicBoolean cancelled = new AtomicBoolean();
|
||||
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
|
||||
Mono.just(true).doOnCancel(() -> cancelled.set(true)).as(operator::transactional)
|
||||
@@ -70,7 +70,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cancellationPropagatedToMono() {
|
||||
void cancellationPropagatedToMono() {
|
||||
AtomicBoolean cancelled = new AtomicBoolean();
|
||||
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
|
||||
Mono.create(sink -> sink.onCancel(() -> cancelled.set(true))).as(operator::transactional)
|
||||
@@ -84,7 +84,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cancellationPropagatedToFlux() {
|
||||
void cancellationPropagatedToFlux() {
|
||||
AtomicBoolean cancelled = new AtomicBoolean();
|
||||
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
|
||||
Flux.create(sink -> sink.onCancel(() -> cancelled.set(true))).as(operator::transactional)
|
||||
@@ -98,7 +98,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackWithMono() {
|
||||
void rollbackWithMono() {
|
||||
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
|
||||
Mono.error(new IllegalStateException()).as(operator::transactional)
|
||||
.as(StepVerifier::create)
|
||||
@@ -108,7 +108,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commitFailureWithMono() {
|
||||
void commitFailureWithMono() {
|
||||
ReactiveTransactionManager tm = mock(ReactiveTransactionManager.class);
|
||||
given(tm.getReactiveTransaction(any())).willReturn(Mono.just(mock(ReactiveTransaction.class)));
|
||||
PublisherProbe<Void> commit = PublisherProbe.of(Mono.error(IOException::new));
|
||||
@@ -125,7 +125,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackFailureWithMono() {
|
||||
void rollbackFailureWithMono() {
|
||||
ReactiveTransactionManager tm = mock(ReactiveTransactionManager.class);
|
||||
given(tm.getReactiveTransaction(any())).willReturn(Mono.just(mock(ReactiveTransaction.class)));
|
||||
PublisherProbe<Void> commit = PublisherProbe.empty();
|
||||
@@ -145,7 +145,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commitWithFlux() {
|
||||
void commitWithFlux() {
|
||||
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
|
||||
Flux.just(1, 2, 3, 4).as(operator::transactional)
|
||||
.as(StepVerifier::create)
|
||||
@@ -156,7 +156,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackWithFlux() {
|
||||
void rollbackWithFlux() {
|
||||
TransactionalOperator operator = TransactionalOperator.create(tm, new DefaultTransactionDefinition());
|
||||
Flux.error(new IllegalStateException()).as(operator::transactional)
|
||||
.as(StepVerifier::create)
|
||||
@@ -166,7 +166,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commitFailureWithFlux() {
|
||||
void commitFailureWithFlux() {
|
||||
ReactiveTransactionManager tm = mock(ReactiveTransactionManager.class);
|
||||
given(tm.getReactiveTransaction(any())).willReturn(Mono.just(mock(ReactiveTransaction.class)));
|
||||
PublisherProbe<Void> commit = PublisherProbe.of(Mono.error(IOException::new));
|
||||
@@ -184,7 +184,7 @@ public class TransactionalOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rollbackFailureWithFlux() {
|
||||
void rollbackFailureWithFlux() {
|
||||
ReactiveTransactionManager tm = mock(ReactiveTransactionManager.class);
|
||||
given(tm.getReactiveTransaction(any())).willReturn(Mono.just(mock(ReactiveTransaction.class)));
|
||||
PublisherProbe<Void> commit = PublisherProbe.empty();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,10 +30,10 @@ import static org.mockito.Mockito.mock;
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public class JtaTransactionManagerSerializationTests {
|
||||
class JtaTransactionManagerSerializationTests {
|
||||
|
||||
@Test
|
||||
public void serializable() throws Exception {
|
||||
void serializable() throws Exception {
|
||||
UserTransaction ut1 = mock();
|
||||
UserTransaction ut2 = mock();
|
||||
TransactionManager tm = mock();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,11 +34,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class SimpleTransactionScopeTests {
|
||||
class SimpleTransactionScopeTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void getFromScope() throws Exception {
|
||||
public void getFromScope() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerScope("tx", new SimpleTransactionScope());
|
||||
|
||||
@@ -63,10 +62,10 @@ public class SimpleTransactionScopeTests {
|
||||
context.getBean(DerivedTestBean.class))
|
||||
.withCauseInstanceOf(IllegalStateException.class);
|
||||
|
||||
TestBean bean1 = null;
|
||||
DerivedTestBean bean2 = null;
|
||||
DerivedTestBean bean2a = null;
|
||||
DerivedTestBean bean2b = null;
|
||||
TestBean bean1;
|
||||
DerivedTestBean bean2;
|
||||
DerivedTestBean bean2a;
|
||||
DerivedTestBean bean2b;
|
||||
|
||||
TransactionSynchronizationManager.initSynchronization();
|
||||
try {
|
||||
@@ -110,7 +109,7 @@ public class SimpleTransactionScopeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWithTransactionManager() throws Exception {
|
||||
void getWithTransactionManager() {
|
||||
try (GenericApplicationContext context = new GenericApplicationContext()) {
|
||||
context.getBeanFactory().registerScope("tx", new SimpleTransactionScope());
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.transaction.IllegalTransactionStateException;
|
||||
import org.springframework.transaction.MockCallbackPreferringTransactionManager;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TestTransactionExecutionListener;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
import org.springframework.transaction.testfixture.MockCallbackPreferringTransactionManager;
|
||||
import org.springframework.transaction.testfixture.TestTransactionExecutionListener;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
Reference in New Issue
Block a user