Merge branch '3.1.x'
Closes gh-37967
This commit is contained in:
@@ -26,7 +26,7 @@ import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* Tests for {@link RabbitProperties}.
|
||||
@@ -369,9 +369,9 @@ class RabbitPropertiesTests {
|
||||
void hostPropertyMustBeSingleHost() {
|
||||
this.properties.setHost("my-rmq-host.net,my-rmq-host-2.net");
|
||||
assertThat(this.properties.getHost()).isEqualTo("my-rmq-host.net,my-rmq-host-2.net");
|
||||
assertThatThrownBy(this.properties::determineAddresses)
|
||||
.isInstanceOf(InvalidConfigurationPropertyValueException.class)
|
||||
.hasMessageContaining("spring.rabbitmq.host");
|
||||
assertThatExceptionOfType(InvalidConfigurationPropertyValueException.class)
|
||||
.isThrownBy(this.properties::determineAddresses)
|
||||
.withMessageContaining("spring.rabbitmq.host");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.datastax.oss.driver.internal.core.session.throttling.PassThroughReque
|
||||
import com.datastax.oss.driver.internal.core.session.throttling.RateLimitingRequestThrottler;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration.PropertiesCassandraConnectionDetails;
|
||||
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
|
||||
@@ -42,7 +43,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatException;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* Tests for {@link CassandraAutoConfiguration}
|
||||
@@ -299,9 +300,10 @@ class CassandraAutoConfigurationTests {
|
||||
@Test
|
||||
void driverConfigLoaderWithRateLimitingRequiresExtraConfiguration() {
|
||||
this.contextRunner.withPropertyValues("spring.cassandra.request.throttler.type=rate-limiting")
|
||||
.run((context) -> assertThatThrownBy(() -> context.getBean(CqlSession.class))
|
||||
.hasMessageContaining("Error instantiating class RateLimitingRequestThrottler")
|
||||
.hasMessageContaining("No configuration setting found for key"));
|
||||
.run((context) -> assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> context.getBean(CqlSession.class))
|
||||
.withMessageContaining("Error instantiating class RateLimitingRequestThrottler")
|
||||
.withMessageContaining("No configuration setting found for key"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -34,13 +34,14 @@ import org.testcontainers.images.builder.Transferable;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.testcontainers.CassandraContainer;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* Tests for {@link CassandraAutoConfiguration} that only uses password authentication.
|
||||
@@ -77,8 +78,9 @@ class CassandraAutoConfigurationWithPasswordAuthenticationIntegrationTests {
|
||||
void authenticationWithInvalidCredentials() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.cassandra.username=not-a-user", "spring.cassandra.password=invalid-password")
|
||||
.run((context) -> assertThatThrownBy(() -> context.getBean(CqlSession.class))
|
||||
.hasMessageContaining("Authentication error"));
|
||||
.run((context) -> assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> context.getBean(CqlSession.class))
|
||||
.withMessageContaining("Authentication error"));
|
||||
}
|
||||
|
||||
static final class PasswordAuthenticatorCassandraContainer extends CassandraContainer {
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.context.annotation.ImportSelector;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatException;
|
||||
|
||||
/**
|
||||
* Tests for {@link OnBeanCondition} when deduction of the bean's type fails
|
||||
@@ -41,7 +41,7 @@ class OnBeanConditionTypeDeductionFailureTests {
|
||||
|
||||
@Test
|
||||
void conditionalOnMissingBeanWithDeducedTypeThatIsPartiallyMissingFromClassPath() {
|
||||
assertThatExceptionOfType(Exception.class)
|
||||
assertThatException()
|
||||
.isThrownBy(() -> new AnnotationConfigApplicationContext(ImportingConfiguration.class).close())
|
||||
.satisfies((ex) -> {
|
||||
Throwable beanTypeDeductionException = findNestedCause(ex, BeanTypeDeductionException.class);
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
@@ -69,11 +69,11 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
|
||||
void registerIntegrationPropertiesPropertySourceWithUnknownResourceThrowsException() {
|
||||
ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
ClassPathResource unknown = new ClassPathResource("does-not-exist.properties", getClass());
|
||||
assertThatThrownBy(() -> new IntegrationPropertiesEnvironmentPostProcessor()
|
||||
.registerIntegrationPropertiesPropertySource(environment, unknown))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasCauseInstanceOf(FileNotFoundException.class)
|
||||
.hasMessageContaining(unknown.toString());
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> new IntegrationPropertiesEnvironmentPostProcessor()
|
||||
.registerIntegrationPropertiesPropertySource(environment, unknown))
|
||||
.withCauseInstanceOf(FileNotFoundException.class)
|
||||
.withMessageContaining(unknown.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -75,7 +75,7 @@ import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@@ -363,10 +363,10 @@ class JacksonAutoConfigurationTests {
|
||||
void disableDefaultLeniency() {
|
||||
this.contextRunner.withPropertyValues("spring.jackson.default-leniency:false").run((context) -> {
|
||||
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
||||
assertThatThrownBy(() -> mapper.readValue("{\"birthDate\": \"2010-12-30\"}", Person.class))
|
||||
.isInstanceOf(InvalidFormatException.class)
|
||||
.hasMessageContaining("expected format")
|
||||
.hasMessageContaining("yyyyMMdd");
|
||||
assertThatExceptionOfType(InvalidFormatException.class)
|
||||
.isThrownBy(() -> mapper.readValue("{\"birthDate\": \"2010-12-30\"}", Person.class))
|
||||
.withMessageContaining("expected format")
|
||||
.withMessageContaining("yyyyMMdd");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatException;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConditionEvaluationReportLoggingListener}.
|
||||
@@ -67,7 +67,7 @@ class ConditionEvaluationReportLoggingListenerTests {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
this.initializer.initialize(context);
|
||||
context.register(ErrorConfig.class);
|
||||
assertThatExceptionOfType(Exception.class).isThrownBy(context::refresh)
|
||||
assertThatException().isThrownBy(context::refresh)
|
||||
.satisfies((ex) -> withDebugLogging(() -> context
|
||||
.publishEvent(new ApplicationFailedEvent(new SpringApplication(), new String[0], context, ex))));
|
||||
assertThat(output).contains("CONDITIONS EVALUATION REPORT");
|
||||
@@ -78,7 +78,7 @@ class ConditionEvaluationReportLoggingListenerTests {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
this.initializer.initialize(context);
|
||||
context.register(ErrorConfig.class);
|
||||
assertThatExceptionOfType(Exception.class).isThrownBy(context::refresh)
|
||||
assertThatException().isThrownBy(context::refresh)
|
||||
.satisfies((ex) -> withInfoLogging(() -> context
|
||||
.publishEvent(new ApplicationFailedEvent(new SpringApplication(), new String[0], context, ex))));
|
||||
assertThat(output).doesNotContain("CONDITIONS EVALUATION REPORT")
|
||||
|
||||
Reference in New Issue
Block a user