Skip to content

Commit ee209de

Browse files
committed
Merge branch '5.3.x'
# Conflicts: # spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java # spring-context/src/test/java/org/springframework/ejb/access/LocalSlsbInvokerInterceptorTests.java # spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptorTests.java # spring-web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java # spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java
2 parents b659030 + 1beb706 commit ee209de

File tree

42 files changed

+533
-780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+533
-780
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ configure(allprojects) { project ->
170170
dependency "org.junit.support:testng-engine:1.0.1"
171171
dependency "org.hamcrest:hamcrest:2.1"
172172
dependency "org.awaitility:awaitility:3.1.6"
173-
dependency "org.assertj:assertj-core:3.22.0"
173+
dependency "org.assertj:assertj-core:3.23.0"
174174
dependencySet(group: 'org.xmlunit', version: '2.9.0') {
175175
entry 'xmlunit-assertj'
176176
entry('xmlunit-matchers') {

integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerAdviceOrderIntegrationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
2828
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2929

3030
import static org.assertj.core.api.Assertions.assertThat;
31-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
31+
import static org.assertj.core.api.Assertions.assertThatException;
3232

3333
/**
3434
* Integration tests for advice invocation order for advice configured via the
@@ -52,7 +52,7 @@ void afterAdviceIsInvokedFirst(@Autowired Echo echo, @Autowired InvocationTracki
5252
assertThat(aspect.invocations).containsExactly("around - start", "before", "around - end", "after", "after returning");
5353

5454
aspect.invocations.clear();
55-
assertThatExceptionOfType(Exception.class).isThrownBy(() -> echo.echo(new Exception()));
55+
assertThatException().isThrownBy(() -> echo.echo(new Exception()));
5656
assertThat(aspect.invocations).containsExactly("around - start", "before", "around - end", "after", "after throwing");
5757
}
5858
}
@@ -69,7 +69,7 @@ void afterAdviceIsInvokedLast(@Autowired Echo echo, @Autowired InvocationTrackin
6969
assertThat(aspect.invocations).containsExactly("around - start", "before", "around - end", "after returning", "after");
7070

7171
aspect.invocations.clear();
72-
assertThatExceptionOfType(Exception.class).isThrownBy(() -> echo.echo(new Exception()));
72+
assertThatException().isThrownBy(() -> echo.echo(new Exception()));
7373
assertThat(aspect.invocations).containsExactly("around - start", "before", "around - end", "after throwing", "after");
7474
}
7575
}

integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AspectJAutoProxyAdviceOrderIntegrationTests.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
3838
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3939

4040
import static org.assertj.core.api.Assertions.assertThat;
41-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
41+
import static org.assertj.core.api.Assertions.assertThatException;
4242

4343
/**
4444
* Integration tests for advice invocation order for advice configured via
@@ -65,8 +65,7 @@ void afterAdviceIsInvokedLast(@Autowired Echo echo, @Autowired AfterAdviceFirstA
6565
assertThat(aspect.invocations).containsExactly("around - start", "before", "after returning", "after", "around - end");
6666

6767
aspect.invocations.clear();
68-
assertThatExceptionOfType(Exception.class).isThrownBy(
69-
() -> echo.echo(new Exception()));
68+
assertThatException().isThrownBy(() -> echo.echo(new Exception()));
7069
assertThat(aspect.invocations).containsExactly("around - start", "before", "after throwing", "after", "around - end");
7170
}
7271
}
@@ -95,8 +94,7 @@ void afterAdviceIsInvokedLast(@Autowired Echo echo, @Autowired AfterAdviceLastAs
9594
assertThat(aspect.invocations).containsExactly("around - start", "before", "after returning", "after", "around - end");
9695

9796
aspect.invocations.clear();
98-
assertThatExceptionOfType(Exception.class).isThrownBy(
99-
() -> echo.echo(new Exception()));
97+
assertThatException().isThrownBy(() -> echo.echo(new Exception()));
10098
assertThat(aspect.invocations).containsExactly("around - start", "before", "after throwing", "after", "around - end");
10199
}
102100
}

integration-tests/src/test/java/org/springframework/cache/annotation/EnableCachingIntegrationTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
3434
import org.springframework.stereotype.Repository;
3535

3636
import static org.assertj.core.api.Assertions.assertThat;
37-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
37+
import static org.assertj.core.api.Assertions.assertThatException;
3838

3939
/**
4040
* Integration tests for the @EnableCaching annotation.
@@ -62,8 +62,7 @@ void repositoryUsesAspectJAdviceMode() {
6262
// this test is a bit fragile, but gets the job done, proving that an
6363
// attempt was made to look up the AJ aspect. It's due to classpath issues
6464
// in .integration-tests that it's not found.
65-
assertThatExceptionOfType(Exception.class).isThrownBy(
66-
ctx::refresh)
65+
assertThatException().isThrownBy(ctx::refresh)
6766
.withMessageContaining("AspectJCachingConfiguration");
6867
}
6968

integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@
4545
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
4646

4747
import static org.assertj.core.api.Assertions.assertThat;
48-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
48+
import static org.assertj.core.api.Assertions.assertThatException;
4949

5050
/**
5151
* Integration tests for the @EnableTransactionManagement annotation.
@@ -98,7 +98,7 @@ void repositoryUsesAspectJAdviceMode() {
9898
// this test is a bit fragile, but gets the job done, proving that an
9999
// attempt was made to look up the AJ aspect. It's due to classpath issues
100100
// in .integration-tests that it's not found.
101-
assertThatExceptionOfType(Exception.class)
101+
assertThatException()
102102
.isThrownBy(ctx::refresh)
103103
.withMessageContaining("AspectJJtaTransactionManagementConfiguration");
104104
}

spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@
4444
import org.springframework.core.testfixture.TimeStamped;
4545

4646
import static org.assertj.core.api.Assertions.assertThat;
47-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
47+
import static org.assertj.core.api.Assertions.assertThatRuntimeException;
4848

4949
/**
5050
* Also tests AdvisedSupport and ProxyCreatorSupport superclasses.
@@ -277,7 +277,7 @@ public void testCanAddAndRemoveAspectInterfacesOnSingleton() {
277277

278278
assertThat(config.getAdvisors().length == oldCount).isTrue();
279279

280-
assertThatExceptionOfType(RuntimeException.class)
280+
assertThatRuntimeException()
281281
.as("Existing object won't implement this interface any more")
282282
.isThrownBy(ts::getTimeStamp); // Existing reference will fail
283283

spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
import org.springframework.aop.testfixture.advice.MyThrowsHandler;
2727

2828
import static org.assertj.core.api.Assertions.assertThat;
29+
import static org.assertj.core.api.Assertions.assertThatException;
2930
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3031
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
3132
import static org.mockito.BDDMockito.given;
@@ -63,9 +64,7 @@ public void testNoHandlerMethodForThrowable() throws Throwable {
6364
Exception ex = new Exception();
6465
MethodInvocation mi = mock(MethodInvocation.class);
6566
given(mi.proceed()).willThrow(ex);
66-
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
67-
ti.invoke(mi))
68-
.isSameAs(ex);
67+
assertThatException().isThrownBy(() -> ti.invoke(mi)).isSameAs(ex);
6968
assertThat(th.getCalls()).isEqualTo(0);
7069
}
7170

spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,9 @@
2222
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
2323

2424
import static org.assertj.core.api.Assertions.assertThat;
25+
import static org.assertj.core.api.Assertions.assertThatException;
2526
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
27+
import static org.assertj.core.api.Assertions.assertThatRuntimeException;
2628

2729
/**
2830
* @author Rod Johnson
@@ -104,44 +106,44 @@ public void notTransactional() throws Throwable {
104106
@Test
105107
public void defaultCommitOnAnnotatedClass() throws Throwable {
106108
Exception ex = new Exception();
107-
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
108-
testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), false))
109+
assertThatException()
110+
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), false))
109111
.isSameAs(ex);
110112
}
111113

112114
@Test
113115
public void defaultRollbackOnAnnotatedClass() throws Throwable {
114116
RuntimeException ex = new RuntimeException();
115-
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
116-
testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), true))
117+
assertThatRuntimeException()
118+
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), true))
117119
.isSameAs(ex);
118120
}
119121

120122
@Test
121123
public void defaultCommitOnSubclassOfAnnotatedClass() throws Throwable {
122124
Exception ex = new Exception();
123-
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
124-
testRollback(() -> new SubclassOfClassWithTransactionalAnnotation().echo(ex), false))
125+
assertThatException()
126+
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalAnnotation().echo(ex), false))
125127
.isSameAs(ex);
126128
}
127129

128130
@Test
129131
public void defaultCommitOnSubclassOfClassWithTransactionalMethodAnnotated() throws Throwable {
130132
Exception ex = new Exception();
131-
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
132-
testRollback(() -> new SubclassOfClassWithTransactionalMethodAnnotation().echo(ex), false))
133+
assertThatException()
134+
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalMethodAnnotation().echo(ex), false))
133135
.isSameAs(ex);
134136
}
135137

136138
@Test
137139
public void noCommitOnImplementationOfAnnotatedInterface() throws Throwable {
138-
final Exception ex = new Exception();
140+
Exception ex = new Exception();
139141
testNotTransactional(() -> new ImplementsAnnotatedInterface().echo(ex), ex);
140142
}
141143

142144
@Test
143145
public void noRollbackOnImplementationOfAnnotatedInterface() throws Throwable {
144-
final Exception rollbackProvokingException = new RuntimeException();
146+
Exception rollbackProvokingException = new RuntimeException();
145147
testNotTransactional(() -> new ImplementsAnnotatedInterface().echo(rollbackProvokingException),
146148
rollbackProvokingException);
147149
}
@@ -165,8 +167,9 @@ protected void testRollback(TransactionOperationCallback toc, boolean rollback)
165167
protected void testNotTransactional(TransactionOperationCallback toc, Throwable expected) throws Throwable {
166168
txManager.clear();
167169
assertThat(txManager.begun).isEqualTo(0);
168-
assertThatExceptionOfType(Throwable.class).isThrownBy(
169-
toc::performTransactionalOperation).isSameAs(expected);
170+
assertThatExceptionOfType(Throwable.class)
171+
.isThrownBy(toc::performTransactionalOperation)
172+
.isSameAs(expected);
170173
assertThat(txManager.begun).isEqualTo(0);
171174
}
172175

spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,7 @@
2323
import org.springframework.core.io.ClassPathResource;
2424

2525
import static org.assertj.core.api.Assertions.assertThat;
26-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
27-
26+
import static org.assertj.core.api.Assertions.assertThatException;
2827

2928
/**
3029
* With Spring 3.1, bean id attributes (and all other id attributes across the
@@ -40,22 +39,23 @@
4039
* @see org.springframework.beans.factory.xml.XmlBeanFactoryTests#withDuplicateName
4140
* @see org.springframework.beans.factory.xml.XmlBeanFactoryTests#withDuplicateNameInAlias
4241
*/
43-
public class DuplicateBeanIdTests {
42+
class DuplicateBeanIdTests {
4443

4544
@Test
46-
public void duplicateBeanIdsWithinSameNestingLevelRaisesError() {
45+
void duplicateBeanIdsWithinSameNestingLevelRaisesError() {
4746
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
4847
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
49-
assertThatExceptionOfType(Exception.class).as("duplicate ids in same nesting level").isThrownBy(() ->
48+
assertThatException().as("duplicate ids in same nesting level").isThrownBy(() ->
5049
reader.loadBeanDefinitions(new ClassPathResource("DuplicateBeanIdTests-sameLevel-context.xml", this.getClass())));
5150
}
5251

5352
@Test
54-
public void duplicateBeanIdsAcrossNestingLevels() {
53+
void duplicateBeanIdsAcrossNestingLevels() {
5554
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
5655
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
5756
reader.loadBeanDefinitions(new ClassPathResource("DuplicateBeanIdTests-multiLevel-context.xml", this.getClass()));
5857
TestBean testBean = bf.getBean(TestBean.class); // there should be only one
5958
assertThat(testBean.getName()).isEqualTo("nested");
6059
}
60+
6161
}

spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheCustomInterceptorTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@
4040
import org.springframework.contextsupport.testfixture.jcache.JCacheableService;
4141

4242
import static org.assertj.core.api.Assertions.assertThat;
43-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
43+
import static org.assertj.core.api.Assertions.assertThatRuntimeException;
4444

4545
/**
4646
* @author Stephane Nicoll
@@ -86,8 +86,8 @@ public void customInterceptorAppliesWithRuntimeException() {
8686

8787
@Test
8888
public void customInterceptorAppliesWithCheckedException() {
89-
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
90-
cs.cacheWithCheckedException("id", true))
89+
assertThatRuntimeException()
90+
.isThrownBy(() -> cs.cacheWithCheckedException("id", true))
9191
.withCauseExactlyInstanceOf(IOException.class);
9292
}
9393

spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import org.springframework.context.support.ClassPathXmlApplicationContext;
2828

29-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
29+
import static org.assertj.core.api.Assertions.assertThatRuntimeException;
3030

3131
/**
3232
* @author Adrian Colyer
@@ -35,12 +35,12 @@
3535
class SPR3064Tests {
3636

3737
@Test
38-
void testServiceIsAdvised() {
38+
void serviceIsAdvised() {
3939
ClassPathXmlApplicationContext ctx =
4040
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
4141

4242
Service service = ctx.getBean(Service.class);
43-
assertThatExceptionOfType(RuntimeException.class)
43+
assertThatRuntimeException()
4444
.isThrownBy(service::serveMe)
4545
.withMessage("advice invoked");
4646

0 commit comments

Comments
 (0)