mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '4.0.x'
This commit is contained in:
@@ -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"/>
|
||||
|
||||
@@ -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" />
|
||||
|
||||
+3
-3
@@ -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
|
||||
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 {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -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;
|
||||
/**
|
||||
* 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<ExampleObject> json = //...
|
||||
@@ -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.
|
||||
|
||||
+13
-9
@@ -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;
|
||||
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 {
|
||||
|
||||
@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 {
|
||||
|
||||
@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 {
|
||||
|
||||
@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 {
|
||||
@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 {
|
||||
|
||||
@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 {
|
||||
|
||||
@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 {
|
||||
assertThat(called).isFalse();
|
||||
}
|
||||
|
||||
private void failure() {
|
||||
fail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for {@link Always}.
|
||||
*/
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
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 {
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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;
|
||||
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 {
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -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;
|
||||
|
||||
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 {
|
||||
|
||||
@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 {
|
||||
}
|
||||
}
|
||||
});
|
||||
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 {
|
||||
}
|
||||
}
|
||||
});
|
||||
Assertions.setExtractBareNamePropertyMethods(true);
|
||||
setExtractBareNamePropertyMethods(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user