Browse Source

Merge branch '4.0.x'

pull/48869/head
Phillip Webb 4 weeks ago
parent
commit
dad1ca5e95
  1. 3
      config/checkstyle/checkstyle-suppressions.xml
  2. 8
      config/checkstyle/checkstyle.xml
  3. 6
      core/spring-boot-docker-compose/src/dockerTest/java/org/springframework/boot/docker/compose/core/DefaultDockerComposeIntegrationTests.java
  4. 11
      core/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java
  5. 22
      core/spring-boot/src/test/java/org/springframework/boot/context/properties/PropertyMapperTests.java
  6. 4
      module/spring-boot-micrometer-tracing-brave/src/test/java/org/springframework/boot/micrometer/tracing/brave/autoconfigure/BraveAutoConfigurationTests.java
  7. 6
      module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheStandaloneIntegrationTests.java
  8. 10
      module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java

3
config/checkstyle/checkstyle-suppressions.xml

@ -71,6 +71,9 @@ @@ -71,6 +71,9 @@
<suppress files="ConfigurationPropertyCaching\.java" checks="SpringJavadoc" message="\@since"/>
<suppress files="StructuredLoggingJsonMembersCustomizer\.java" checks="SpringJavadoc" message="\@since"/>
<suppress files="FieldValues\.java" checks="SimplifyBooleanExpression" />
<suppress files="TestPrintStream\.java" id="staticAssertJ"/>
<suppress files="ItemMetadataAssert\.java" id="staticAssertJ"/>
<suppress files="SpringApplicationShutdownHookInstance\.java" id="staticAssertJ"/>
<!-- jspecify: https://github.com/spring-io/spring-javaformat/issues/454 -->
<suppress files="PemPrivateKeyParser\.java" checks="NoWhitespaceBefore" message="'...' is preceded with whitespace"/>
<suppress files="Bindable\.java" checks="NoWhitespaceBefore" message="'...' is preceded with whitespace"/>

8
config/checkstyle/checkstyle.xml

@ -80,6 +80,14 @@ @@ -80,6 +80,14 @@
value="Please use Collections.emptyList()/emptyMap()/emptySet() for creating empty lists/maps/sets." />
<property name="ignoreComments" value="true" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
<property name="id" value="staticAssertJ"/>
<property name="maximum" value="0"/>
<property name="format" value="import org\.assertj\.core\.api\.Assertions;" />
<property name="message"
value="Please use static AssertJ imports." />
<property name="ignoreComments" value="true" />
</module>
<module name="io.spring.javaformat.checkstyle.check.SpringJavadocCheck">
<property name="publicOnlySinceTags" value="true" />
<property name="requireSinceTag" value="true" />

6
core/spring-boot-docker-compose/src/dockerTest/java/org/springframework/boot/docker/compose/core/DefaultDockerComposeIntegrationTests.java

@ -26,7 +26,6 @@ import java.util.Collections; @@ -26,7 +26,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.assertj.core.api.Assertions;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@ -39,6 +38,7 @@ import org.springframework.boot.testsupport.process.DisabledIfProcessUnavailable @@ -39,6 +38,7 @@ import org.springframework.boot.testsupport.process.DisabledIfProcessUnavailable
import org.springframework.core.io.ClassPathResource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
/**
* Tests for {@link DefaultDockerCompose}.
@ -100,13 +100,13 @@ class DefaultDockerComposeIntegrationTests { @@ -100,13 +100,13 @@ class DefaultDockerComposeIntegrationTests {
private void assertThatDoesNotContainService(List<RunningService> runningServices, String service) {
if (findService(runningServices, service) != null) {
Assertions.fail("Did not expect service '%s', but found it in [%s]", service, runningServices);
fail("Did not expect service '%s', but found it in [%s]", service, runningServices);
}
}
private void assertThatContainsService(List<RunningService> runningServices, String service) {
if (findService(runningServices, service) == null) {
Assertions.fail("Expected service '%s', but hasn't been found in [%s]", service, runningServices);
fail("Expected service '%s', but hasn't been found in [%s]", service, runningServices);
}
}

11
core/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java

@ -26,7 +26,6 @@ import java.io.Reader; @@ -26,7 +26,6 @@ import java.io.Reader;
import java.io.StringReader;
import java.lang.reflect.Field;
import org.assertj.core.api.Assertions;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.ObjectFactory;
@ -42,8 +41,10 @@ import org.springframework.util.ReflectionUtils; @@ -42,8 +41,10 @@ import org.springframework.util.ReflectionUtils;
/**
* Base class for AssertJ based JSON marshal testers. Exposes specific Asserts following a
* {@code read}, {@code write} or {@code parse} of JSON content. Typically used in
* combination with an AssertJ {@link Assertions#assertThat(Object) assertThat} call. For
* example: <pre class="code">
* combination with an AssertJ {@link org.assertj.core.api.Assertions#assertThat(Object)
* assertThat} call. For example:
*
* <pre class="code">
* public class ExampleObjectJsonTests {
*
* private AbstractJsonTester&lt;ExampleObject&gt; json = //...
@ -56,7 +57,9 @@ import org.springframework.util.ReflectionUtils; @@ -56,7 +57,9 @@ import org.springframework.util.ReflectionUtils;
* }
*
* }
* </pre> For a complete list of supported assertions see {@link JsonContentAssert} and
* </pre>
*
* For a complete list of supported assertions see {@link JsonContentAssert} and
* {@link ObjectContentAssert}.
* <p>
* To use this library JSONAssert must be on the test classpath.

22
core/spring-boot/src/test/java/org/springframework/boot/context/properties/PropertyMapperTests.java

@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicBoolean; @@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.function.Supplier;
import org.assertj.core.api.Assertions;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@ -31,6 +30,7 @@ import org.springframework.boot.context.properties.PropertyMapper.Source.Always; @@ -31,6 +30,7 @@ import org.springframework.boot.context.properties.PropertyMapper.Source.Always;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.fail;
/**
* Tests for {@link PropertyMapper}.
@ -124,7 +124,7 @@ class PropertyMapperTests { @@ -124,7 +124,7 @@ class PropertyMapperTests {
@Test
void whenTrueWhenValueIsFalseShouldNotMap() {
this.map.from(false).whenTrue().toCall(Assertions::fail);
this.map.from(false).whenTrue().toCall(this::failure);
}
@Test
@ -135,17 +135,17 @@ class PropertyMapperTests { @@ -135,17 +135,17 @@ class PropertyMapperTests {
@Test
void whenFalseWhenValueIsTrueShouldNotMap() {
this.map.from(true).whenFalse().toCall(Assertions::fail);
this.map.from(true).whenFalse().toCall(this::failure);
}
@Test
void whenHasTextWhenValueIsNullShouldNotMap() {
this.map.from(() -> null).whenHasText().toCall(Assertions::fail);
this.map.from(() -> null).whenHasText().toCall(this::failure);
}
@Test
void whenHasTextWhenValueIsEmptyShouldNotMap() {
this.map.from("").whenHasText().toCall(Assertions::fail);
this.map.from("").whenHasText().toCall(this::failure);
}
@Test
@ -162,7 +162,7 @@ class PropertyMapperTests { @@ -162,7 +162,7 @@ class PropertyMapperTests {
@Test
void whenEqualToWhenValueIsNotEqualShouldNotMatch() {
this.map.from("123").whenEqualTo("321").toCall(Assertions::fail);
this.map.from("123").whenEqualTo("321").toCall(this::failure);
}
@Test
@ -174,7 +174,7 @@ class PropertyMapperTests { @@ -174,7 +174,7 @@ class PropertyMapperTests {
@Test
void whenInstanceOfWhenValueIsNotTargetTypeShouldNotMatch() {
Supplier<Number> supplier = () -> 123L;
this.map.from(supplier).whenInstanceOf(Double.class).toCall(Assertions::fail);
this.map.from(supplier).whenInstanceOf(Double.class).toCall(this::failure);
}
@Test
@ -185,7 +185,7 @@ class PropertyMapperTests { @@ -185,7 +185,7 @@ class PropertyMapperTests {
@Test
void whenWhenValueDoesNotMatchShouldNotMap() {
this.map.from("123").when("321"::equals).toCall(Assertions::fail);
this.map.from("123").when("321"::equals).toCall(this::failure);
}
@Test
@ -203,7 +203,7 @@ class PropertyMapperTests { @@ -203,7 +203,7 @@ class PropertyMapperTests {
@Test
void whenWhenValueNotMatchesShouldSupportChainedCalls() {
this.map.from("123").when("456"::equals).when("123"::equals).toCall(Assertions::fail);
this.map.from("123").when("456"::equals).when("123"::equals).toCall(this::failure);
}
@Test
@ -256,6 +256,10 @@ class PropertyMapperTests { @@ -256,6 +256,10 @@ class PropertyMapperTests {
assertThat(called).isFalse();
}
private void failure() {
fail();
}
/**
* Tests for {@link Always}.
*/

4
module/spring-boot-micrometer-tracing-brave/src/test/java/org/springframework/boot/micrometer/tracing/brave/autoconfigure/BraveAutoConfigurationTests.java

@ -46,7 +46,6 @@ import io.micrometer.tracing.brave.bridge.W3CPropagation; @@ -46,7 +46,6 @@ import io.micrometer.tracing.brave.bridge.W3CPropagation;
import io.micrometer.tracing.exporter.SpanExportingPredicate;
import io.micrometer.tracing.exporter.SpanFilter;
import io.micrometer.tracing.exporter.SpanReporter;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.Test;
@ -63,6 +62,7 @@ import org.springframework.core.annotation.Order; @@ -63,6 +62,7 @@ import org.springframework.core.annotation.Order;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.Mockito.mock;
/**
@ -401,7 +401,7 @@ class BraveAutoConfigurationTests { @@ -401,7 +401,7 @@ class BraveAutoConfigurationTests {
if (factory instanceof CompositePropagationFactory compositePropagationFactory) {
return compositePropagationFactory.getInjectors().toList();
}
Assertions.fail("Expected CompositePropagationFactory, found %s".formatted(factory.getClass()));
fail("Expected CompositePropagationFactory, found %s".formatted(factory.getClass()));
throw new AssertionError("Unreachable");
}

6
module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheStandaloneIntegrationTests.java

@ -19,7 +19,6 @@ package org.springframework.boot.mustache.autoconfigure; @@ -19,7 +19,6 @@ package org.springframework.boot.mustache.autoconfigure;
import java.util.Collections;
import com.samskivert.mustache.Mustache;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,6 +29,8 @@ import org.springframework.context.annotation.Configuration; @@ -30,6 +29,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration Tests for {@link MustacheAutoConfiguration} outside of a web application.
*
@ -44,8 +45,7 @@ class MustacheStandaloneIntegrationTests { @@ -44,8 +45,7 @@ class MustacheStandaloneIntegrationTests {
@Test
void directCompilation() {
Assertions
.assertThat(this.compiler.compile("Hello: {{world}}").execute(Collections.singletonMap("world", "World")))
assertThat(this.compiler.compile("Hello: {{world}}").execute(Collections.singletonMap("world", "World")))
.isEqualTo("Hello: World");
}

10
module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/WebFluxAutoConfigurationTests.java

@ -36,7 +36,6 @@ import jakarta.validation.ValidatorFactory; @@ -36,7 +36,6 @@ import jakarta.validation.ValidatorFactory;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
@ -133,6 +132,7 @@ import org.springframework.web.util.pattern.PathPattern; @@ -133,6 +132,7 @@ import org.springframework.web.util.pattern.PathPattern;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.setExtractBareNamePropertyMethods;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
@ -488,7 +488,7 @@ class WebFluxAutoConfigurationTests { @@ -488,7 +488,7 @@ class WebFluxAutoConfigurationTests {
@Test
void cachePeriod() {
Assertions.setExtractBareNamePropertyMethods(false);
setExtractBareNamePropertyMethods(false);
this.contextRunner.withPropertyValues("spring.web.resources.cache.period:5").run((context) -> {
Map<PathPattern, Object> handlerMap = getHandlerMap(context);
assertThat(handlerMap).hasSize(2);
@ -499,12 +499,12 @@ class WebFluxAutoConfigurationTests { @@ -499,12 +499,12 @@ class WebFluxAutoConfigurationTests {
}
}
});
Assertions.setExtractBareNamePropertyMethods(true);
setExtractBareNamePropertyMethods(true);
}
@Test
void cacheControl() {
Assertions.setExtractBareNamePropertyMethods(false);
setExtractBareNamePropertyMethods(false);
this.contextRunner
.withPropertyValues("spring.web.resources.cache.cachecontrol.max-age:5",
"spring.web.resources.cache.cachecontrol.proxy-revalidate:true")
@ -518,7 +518,7 @@ class WebFluxAutoConfigurationTests { @@ -518,7 +518,7 @@ class WebFluxAutoConfigurationTests {
}
}
});
Assertions.setExtractBareNamePropertyMethods(true);
setExtractBareNamePropertyMethods(true);
}
@Test

Loading…
Cancel
Save