Skip to content

Commit a0b999c

Browse files
committed
Merge branch '2.7.x' into 3.0.x
Closes gh-37965
2 parents c16f9dd + abdad1c commit a0b999c

File tree

28 files changed

+125
-124
lines changed

28 files changed

+125
-124
lines changed

buildSrc/src/test/java/org/springframework/boot/build/mavenplugin/PluginXmlParserTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.springframework.boot.build.mavenplugin.PluginXmlParser.Plugin;
2525

2626
import static org.assertj.core.api.Assertions.assertThat;
27-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
27+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2828

2929
/**
3030
* Tests for {@link PluginXmlParser}.
@@ -49,9 +49,9 @@ void parseExistingDescriptorReturnPluginDescriptor() {
4949

5050
@Test
5151
void parseNonExistingFileThrowException() {
52-
assertThatThrownBy(() -> this.parser.parse(new File("src/test/resources/nonexistent.xml")))
53-
.isInstanceOf(RuntimeException.class)
54-
.hasCauseInstanceOf(FileNotFoundException.class);
52+
assertThatExceptionOfType(RuntimeException.class)
53+
.isThrownBy(() -> this.parser.parse(new File("src/test/resources/nonexistent.xml")))
54+
.withCauseInstanceOf(FileNotFoundException.class);
5555
}
5656

5757
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
5151

5252
import static org.assertj.core.api.Assertions.assertThat;
53-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
53+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
5454
import static org.mockito.BDDMockito.given;
5555
import static org.mockito.Mockito.mock;
5656

@@ -117,8 +117,8 @@ void entityManagerFactoryInstrumentationIsDisabledIfNotHibernateSessionFactory()
117117
.withUserConfiguration(NonHibernateEntityManagerFactoryConfiguration.class)
118118
.run((context) -> {
119119
// ensure EntityManagerFactory is not a Hibernate SessionFactory
120-
assertThatThrownBy(() -> context.getBean(EntityManagerFactory.class).unwrap(SessionFactory.class))
121-
.isInstanceOf(PersistenceException.class);
120+
assertThatExceptionOfType(PersistenceException.class)
121+
.isThrownBy(() -> context.getBean(EntityManagerFactory.class).unwrap(SessionFactory.class));
122122
MeterRegistry registry = context.getBean(MeterRegistry.class);
123123
assertThat(registry.find("hibernate.statements").meter()).isNull();
124124
});

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/ObservationAutoConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import org.springframework.core.annotation.Order;
5151

5252
import static org.assertj.core.api.Assertions.assertThat;
53-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
53+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
5454
import static org.mockito.Mockito.mock;
5555

5656
/**
@@ -174,8 +174,8 @@ void autoConfiguresObservationPredicates() {
174174
Observation.start("observation2", observationRegistry).stop();
175175
MeterRegistry meterRegistry = context.getBean(MeterRegistry.class);
176176
assertThat(meterRegistry.get("observation1").timer().count()).isOne();
177-
assertThatThrownBy(() -> meterRegistry.get("observation2").timer())
178-
.isInstanceOf(MeterNotFoundException.class);
177+
assertThatExceptionOfType(MeterNotFoundException.class)
178+
.isThrownBy(() -> meterRegistry.get("observation2").timer());
179179
});
180180
}
181181

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinHttpSenderTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import zipkin2.reporter.Sender;
3333

3434
import static org.assertj.core.api.Assertions.assertThat;
35-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
35+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3636

3737
/**
3838
* Abstract base test class which is used for testing the different implementations of the
@@ -54,7 +54,8 @@ void setUp() {
5454
@Test
5555
void sendSpansShouldThrowIfCloseWasCalled() throws IOException {
5656
this.sut.close();
57-
assertThatThrownBy(() -> this.sut.sendSpans(Collections.emptyList())).isInstanceOf(ClosedSenderException.class);
57+
assertThatExceptionOfType(ClosedSenderException.class)
58+
.isThrownBy(() -> this.sut.sendSpans(Collections.emptyList()));
5859
}
5960

6061
protected void makeRequest(List<byte[]> encodedSpans, boolean async) throws IOException {

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinRestTemplateSenderTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.springframework.web.client.RestTemplate;
3535

3636
import static org.assertj.core.api.Assertions.assertThat;
37-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
37+
import static org.assertj.core.api.Assertions.assertThatException;
3838
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
3939
import static org.springframework.test.web.client.match.MockRestRequestMatchers.header;
4040
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
@@ -107,8 +107,8 @@ void sendSpansShouldHandleHttpFailures(boolean async) {
107107
assertThat(callbackResult.error()).isNotNull().hasMessageContaining("500 Internal Server Error");
108108
}
109109
else {
110-
assertThatThrownBy(() -> makeSyncRequest(Collections.emptyList()))
111-
.hasMessageContaining("500 Internal Server Error");
110+
assertThatException().isThrownBy(() -> makeSyncRequest(Collections.emptyList()))
111+
.withMessageContaining("500 Internal Server Error");
112112
}
113113
}
114114

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinWebClientSenderTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.springframework.web.reactive.function.client.WebClient;
3737

3838
import static org.assertj.core.api.Assertions.assertThat;
39-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
39+
import static org.assertj.core.api.Assertions.assertThatException;
4040

4141
/**
4242
* Tests for {@link ZipkinWebClientSender}.
@@ -112,8 +112,8 @@ void sendSpansShouldHandleHttpFailures(boolean async) throws InterruptedExceptio
112112
assertThat(callbackResult.error()).isNotNull().hasMessageContaining("500 Internal Server Error");
113113
}
114114
else {
115-
assertThatThrownBy(() -> makeSyncRequest(Collections.emptyList()))
116-
.hasMessageContaining("500 Internal Server Error");
115+
assertThatException().isThrownBy(() -> makeSyncRequest(Collections.emptyList()))
116+
.withMessageContaining("500 Internal Server Error");
117117
}
118118

119119
requestAssertions((request) -> assertThat(request.getMethod()).isEqualTo("POST"));

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/wavefront/WavefrontPropertiesTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException;
2424

2525
import static org.assertj.core.api.Assertions.assertThat;
26-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
26+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2727

2828
/**
2929
* Tests for {@link WavefrontProperties}.
@@ -47,8 +47,8 @@ void apiTokenIsMandatoryWhenNotUsingProxy() {
4747
sut.setUri(URI.create("http://localhost:2878"));
4848
sut.setApiToken(null);
4949
assertThat(sut.getEffectiveUri()).isEqualTo(URI.create("http://localhost:2878"));
50-
assertThatThrownBy(sut::getApiTokenOrThrow).isInstanceOf(InvalidConfigurationPropertyValueException.class)
51-
.hasMessageContaining("management.wavefront.api-token");
50+
assertThatExceptionOfType(InvalidConfigurationPropertyValueException.class).isThrownBy(sut::getApiTokenOrThrow)
51+
.withMessageContaining("management.wavefront.api-token");
5252
}
5353

5454
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131
import com.datastax.oss.driver.internal.core.session.throttling.RateLimitingRequestThrottler;
3232
import org.junit.jupiter.api.Test;
3333

34+
import org.springframework.beans.factory.BeanCreationException;
3435
import org.springframework.boot.autoconfigure.AutoConfigurations;
3536
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3637
import org.springframework.context.annotation.Bean;
3738
import org.springframework.context.annotation.Configuration;
3839

3940
import static org.assertj.core.api.Assertions.assertThat;
40-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
41+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
4142

4243
/**
4344
* Tests for {@link CassandraAutoConfiguration}
@@ -215,9 +216,10 @@ void driverConfigLoaderUsePassThroughLimitingRequestThrottlerByDefault() {
215216
@Test
216217
void driverConfigLoaderWithRateLimitingRequiresExtraConfiguration() {
217218
this.contextRunner.withPropertyValues("spring.cassandra.request.throttler.type=rate-limiting")
218-
.run((context) -> assertThatThrownBy(() -> context.getBean(CqlSession.class))
219-
.hasMessageContaining("Error instantiating class RateLimitingRequestThrottler")
220-
.hasMessageContaining("No configuration setting found for key"));
219+
.run((context) -> assertThatExceptionOfType(BeanCreationException.class)
220+
.isThrownBy(() -> context.getBean(CqlSession.class))
221+
.withMessageContaining("Error instantiating class RateLimitingRequestThrottler")
222+
.withMessageContaining("No configuration setting found for key"));
221223
}
222224

223225
@Test

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationWithPasswordAuthenticationIntegrationTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@
3434
import org.testcontainers.junit.jupiter.Container;
3535
import org.testcontainers.junit.jupiter.Testcontainers;
3636

37+
import org.springframework.beans.factory.BeanCreationException;
3738
import org.springframework.boot.autoconfigure.AutoConfigurations;
3839
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3940
import org.springframework.boot.testsupport.testcontainers.CassandraContainer;
4041
import org.springframework.util.StreamUtils;
4142

4243
import static org.assertj.core.api.Assertions.assertThat;
43-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
44+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
4445

4546
/**
4647
* Tests for {@link CassandraAutoConfiguration} that only uses password authentication.
@@ -77,8 +78,9 @@ void authenticationWithValidUsernameAndPassword() {
7778
void authenticationWithInvalidCredentials() {
7879
this.contextRunner
7980
.withPropertyValues("spring.cassandra.username=not-a-user", "spring.cassandra.password=invalid-password")
80-
.run((context) -> assertThatThrownBy(() -> context.getBean(CqlSession.class))
81-
.hasMessageContaining("Authentication error"));
81+
.run((context) -> assertThatExceptionOfType(BeanCreationException.class)
82+
.isThrownBy(() -> context.getBean(CqlSession.class))
83+
.withMessageContaining("Authentication error"));
8284
}
8385

8486
static final class PasswordAuthenticatorCassandraContainer extends CassandraContainer {

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/OnBeanConditionTypeDeductionFailureTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.springframework.core.type.AnnotationMetadata;
3030

3131
import static org.assertj.core.api.Assertions.assertThat;
32-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
32+
import static org.assertj.core.api.Assertions.assertThatException;
3333

3434
/**
3535
* Tests for {@link OnBeanCondition} when deduction of the bean's type fails
@@ -41,7 +41,7 @@ class OnBeanConditionTypeDeductionFailureTests {
4141

4242
@Test
4343
void conditionalOnMissingBeanWithDeducedTypeThatIsPartiallyMissingFromClassPath() {
44-
assertThatExceptionOfType(Exception.class)
44+
assertThatException()
4545
.isThrownBy(() -> new AnnotationConfigApplicationContext(ImportingConfiguration.class).close())
4646
.satisfies((ex) -> {
4747
Throwable beanTypeDeductionException = findNestedCause(ex, BeanTypeDeductionException.class);

0 commit comments

Comments
 (0)