Skip to content

Commit 0955f54

Browse files
committed
Polishing
1 parent e5e61df commit 0955f54

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.jupiter.api.Test;
2424

2525
import org.springframework.aop.support.AopUtils;
26+
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
2627
import org.springframework.beans.factory.annotation.Autowired;
2728
import org.springframework.context.ConfigurableApplicationContext;
2829
import org.springframework.context.annotation.AdviceMode;
@@ -46,6 +47,7 @@
4647

4748
import static org.assertj.core.api.Assertions.assertThat;
4849
import static org.assertj.core.api.Assertions.assertThatException;
50+
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
4951

5052
/**
5153
* Tests demonstrating use of @EnableTransactionManagement @Configuration classes.
@@ -226,8 +228,8 @@ void proxyTypeAspectJCausesRegistrationOfAnnotationTransactionAspect() {
226228
// should throw CNFE when trying to load AnnotationTransactionAspect.
227229
// Do you actually have org.springframework.aspects on the classpath?
228230
assertThatException()
229-
.isThrownBy(() -> new AnnotationConfigApplicationContext(EnableAspectjTxConfig.class, TxManagerConfig.class))
230-
.withMessageContaining("AspectJJtaTransactionManagementConfiguration");
231+
.isThrownBy(() -> new AnnotationConfigApplicationContext(EnableAspectjTxConfig.class, TxManagerConfig.class))
232+
.withMessageContaining("AspectJJtaTransactionManagementConfiguration");
231233
}
232234

233235
@Test
@@ -254,11 +256,13 @@ void spr11915TransactionManagerAsManualSingleton() {
254256
assertThat(txManager.commits).isEqualTo(2);
255257
assertThat(txManager.rollbacks).isEqualTo(0);
256258

259+
assertThatExceptionOfType(NoUniqueBeanDefinitionException.class).isThrownBy(bean::findAllFoos);
260+
257261
ctx.close();
258262
}
259263

260264
@Test
261-
void spr14322FindsOnInterfaceWithInterfaceProxy() {
265+
void spr14322AnnotationOnInterfaceWithInterfaceProxy() {
262266
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14322ConfigA.class);
263267
TransactionalTestInterface bean = ctx.getBean(TransactionalTestInterface.class);
264268
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
@@ -273,7 +277,7 @@ void spr14322FindsOnInterfaceWithInterfaceProxy() {
273277
}
274278

275279
@Test
276-
void spr14322FindsOnInterfaceWithCglibProxy() {
280+
void spr14322AnnotationOnInterfaceWithCglibProxy() {
277281
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14322ConfigB.class);
278282
TransactionalTestInterface bean = ctx.getBean(TransactionalTestInterface.class);
279283
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
@@ -504,6 +508,11 @@ public void initializeApp(ConfigurableApplicationContext applicationContext) {
504508
public TransactionalTestBean testBean() {
505509
return new TransactionalTestBean();
506510
}
511+
512+
@Bean
513+
public CallCountingTransactionManager otherTxManager() {
514+
return new CallCountingTransactionManager();
515+
}
507516
}
508517

509518

spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,11 @@ void serializableWithCompositeSource() throws Exception {
116116
ti.setTransactionManager(ptm);
117117
ti = SerializationTestUtils.serializeAndDeserialize(ti);
118118

119-
boolean condition3 = ti.getTransactionManager() instanceof SerializableTransactionManager;
120-
assertThat(condition3).isTrue();
121-
boolean condition2 = ti.getTransactionAttributeSource() instanceof CompositeTransactionAttributeSource;
122-
assertThat(condition2).isTrue();
119+
assertThat(ti.getTransactionManager() instanceof SerializableTransactionManager).isTrue();
120+
assertThat(ti.getTransactionAttributeSource() instanceof CompositeTransactionAttributeSource).isTrue();
123121
CompositeTransactionAttributeSource ctas = (CompositeTransactionAttributeSource) ti.getTransactionAttributeSource();
124-
boolean condition1 = ctas.getTransactionAttributeSources()[0] instanceof NameMatchTransactionAttributeSource;
125-
assertThat(condition1).isTrue();
126-
boolean condition = ctas.getTransactionAttributeSources()[1] instanceof NameMatchTransactionAttributeSource;
127-
assertThat(condition).isTrue();
122+
assertThat(ctas.getTransactionAttributeSources()[0] instanceof NameMatchTransactionAttributeSource).isTrue();
123+
assertThat(ctas.getTransactionAttributeSources()[1] instanceof NameMatchTransactionAttributeSource).isTrue();
128124
}
129125

130126
@Test
@@ -158,9 +154,9 @@ void determineTransactionManagerWithQualifierUnknown() {
158154
DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
159155
attribute.setQualifier("fooTransactionManager");
160156

161-
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
162-
ti.determineTransactionManager(attribute))
163-
.withMessageContaining("'fooTransactionManager'");
157+
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
158+
.isThrownBy(() -> ti.determineTransactionManager(attribute))
159+
.withMessageContaining("'fooTransactionManager'");
164160
}
165161

166162
@Test

0 commit comments

Comments
 (0)