Skip to content

Commit a4f3568

Browse files
committed
Merge branch '3.5.x' into 4.0.x
2 parents 2e2981b + 92263e7 commit a4f3568

8 files changed

Lines changed: 44 additions & 26 deletions

File tree

config/checkstyle/checkstyle-suppressions.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
<suppress files="ConfigurationPropertyCaching\.java" checks="SpringJavadoc" message="\@since"/>
7272
<suppress files="StructuredLoggingJsonMembersCustomizer\.java" checks="SpringJavadoc" message="\@since"/>
7373
<suppress files="FieldValues\.java" checks="SimplifyBooleanExpression" />
74+
<suppress files="TestPrintStream\.java" id="staticAssertJ"/>
75+
<suppress files="ItemMetadataAssert\.java" id="staticAssertJ"/>
76+
<suppress files="SpringApplicationShutdownHookInstance\.java" id="staticAssertJ"/>
7477
<!-- jspecify: https://github.com/spring-io/spring-javaformat/issues/454 -->
7578
<suppress files="PemPrivateKeyParser\.java" checks="NoWhitespaceBefore" message="'...' is preceded with whitespace"/>
7679
<suppress files="Bindable\.java" checks="NoWhitespaceBefore" message="'...' is preceded with whitespace"/>

config/checkstyle/checkstyle.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@
8080
value="Please use Collections.emptyList()/emptyMap()/emptySet() for creating empty lists/maps/sets." />
8181
<property name="ignoreComments" value="true" />
8282
</module>
83+
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
84+
<property name="id" value="staticAssertJ"/>
85+
<property name="maximum" value="0"/>
86+
<property name="format" value="import org\.assertj\.core\.api\.Assertions;" />
87+
<property name="message"
88+
value="Please use static AssertJ imports." />
89+
<property name="ignoreComments" value="true" />
90+
</module>
8391
<module name="io.spring.javaformat.checkstyle.check.SpringJavadocCheck">
8492
<property name="publicOnlySinceTags" value="true" />
8593
<property name="requireSinceTag" value="true" />

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.List;
2727
import java.util.Set;
2828

29-
import org.assertj.core.api.Assertions;
3029
import org.jspecify.annotations.Nullable;
3130
import org.junit.jupiter.api.Test;
3231
import org.junit.jupiter.api.io.TempDir;
@@ -39,6 +38,7 @@
3938
import org.springframework.core.io.ClassPathResource;
4039

4140
import static org.assertj.core.api.Assertions.assertThat;
41+
import static org.assertj.core.api.Assertions.fail;
4242

4343
/**
4444
* Tests for {@link DefaultDockerCompose}.
@@ -100,13 +100,13 @@ void shouldWorkWithProfiles(@TempDir Path tempDir) throws IOException {
100100

101101
private void assertThatDoesNotContainService(List<RunningService> runningServices, String service) {
102102
if (findService(runningServices, service) != null) {
103-
Assertions.fail("Did not expect service '%s', but found it in [%s]", service, runningServices);
103+
fail("Did not expect service '%s', but found it in [%s]", service, runningServices);
104104
}
105105
}
106106

107107
private void assertThatContainsService(List<RunningService> runningServices, String service) {
108108
if (findService(runningServices, service) == null) {
109-
Assertions.fail("Expected service '%s', but hasn't been found in [%s]", service, runningServices);
109+
fail("Expected service '%s', but hasn't been found in [%s]", service, runningServices);
110110
}
111111
}
112112

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.io.StringReader;
2727
import java.lang.reflect.Field;
2828

29-
import org.assertj.core.api.Assertions;
3029
import org.jspecify.annotations.Nullable;
3130

3231
import org.springframework.beans.factory.ObjectFactory;
@@ -42,8 +41,10 @@
4241
/**
4342
* Base class for AssertJ based JSON marshal testers. Exposes specific Asserts following a
4443
* {@code read}, {@code write} or {@code parse} of JSON content. Typically used in
45-
* combination with an AssertJ {@link Assertions#assertThat(Object) assertThat} call. For
46-
* example: <pre class="code">
44+
* combination with an AssertJ {@link org.assertj.core.api.Assertions#assertThat(Object)
45+
* assertThat} call. For example:
46+
*
47+
* <pre class="code">
4748
* public class ExampleObjectJsonTests {
4849
*
4950
* private AbstractJsonTester&lt;ExampleObject&gt; json = //...
@@ -56,7 +57,9 @@
5657
* }
5758
*
5859
* }
59-
* </pre> For a complete list of supported assertions see {@link JsonContentAssert} and
60+
* </pre>
61+
*
62+
* For a complete list of supported assertions see {@link JsonContentAssert} and
6063
* {@link ObjectContentAssert}.
6164
* <p>
6265
* To use this library JSONAssert must be on the test classpath.

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.function.Function;
2222
import java.util.function.Supplier;
2323

24-
import org.assertj.core.api.Assertions;
2524
import org.jspecify.annotations.Nullable;
2625
import org.junit.jupiter.api.Nested;
2726
import org.junit.jupiter.api.Test;
@@ -31,6 +30,7 @@
3130
import static org.assertj.core.api.Assertions.assertThat;
3231
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3332
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
33+
import static org.assertj.core.api.Assertions.fail;
3434

3535
/**
3636
* Tests for {@link PropertyMapper}.
@@ -124,7 +124,7 @@ void whenTrueWhenValueIsTrueShouldMap() {
124124

125125
@Test
126126
void whenTrueWhenValueIsFalseShouldNotMap() {
127-
this.map.from(false).whenTrue().toCall(Assertions::fail);
127+
this.map.from(false).whenTrue().toCall(this::failure);
128128
}
129129

130130
@Test
@@ -135,17 +135,17 @@ void whenFalseWhenValueIsFalseShouldMap() {
135135

136136
@Test
137137
void whenFalseWhenValueIsTrueShouldNotMap() {
138-
this.map.from(true).whenFalse().toCall(Assertions::fail);
138+
this.map.from(true).whenFalse().toCall(this::failure);
139139
}
140140

141141
@Test
142142
void whenHasTextWhenValueIsNullShouldNotMap() {
143-
this.map.from(() -> null).whenHasText().toCall(Assertions::fail);
143+
this.map.from(() -> null).whenHasText().toCall(this::failure);
144144
}
145145

146146
@Test
147147
void whenHasTextWhenValueIsEmptyShouldNotMap() {
148-
this.map.from("").whenHasText().toCall(Assertions::fail);
148+
this.map.from("").whenHasText().toCall(this::failure);
149149
}
150150

151151
@Test
@@ -162,7 +162,7 @@ void whenEqualToWhenValueIsEqualShouldMatch() {
162162

163163
@Test
164164
void whenEqualToWhenValueIsNotEqualShouldNotMatch() {
165-
this.map.from("123").whenEqualTo("321").toCall(Assertions::fail);
165+
this.map.from("123").whenEqualTo("321").toCall(this::failure);
166166
}
167167

168168
@Test
@@ -174,7 +174,7 @@ void whenInstanceOfWhenValueIsTargetTypeShouldMatch() {
174174
@Test
175175
void whenInstanceOfWhenValueIsNotTargetTypeShouldNotMatch() {
176176
Supplier<Number> supplier = () -> 123L;
177-
this.map.from(supplier).whenInstanceOf(Double.class).toCall(Assertions::fail);
177+
this.map.from(supplier).whenInstanceOf(Double.class).toCall(this::failure);
178178
}
179179

180180
@Test
@@ -185,7 +185,7 @@ void whenWhenValueMatchesShouldMap() {
185185

186186
@Test
187187
void whenWhenValueDoesNotMatchShouldNotMap() {
188-
this.map.from("123").when("321"::equals).toCall(Assertions::fail);
188+
this.map.from("123").when("321"::equals).toCall(this::failure);
189189
}
190190

191191
@Test
@@ -203,7 +203,7 @@ void whenWhenCombinedWithAsUsesSourceValue() {
203203

204204
@Test
205205
void whenWhenValueNotMatchesShouldSupportChainedCalls() {
206-
this.map.from("123").when("456"::equals).when("123"::equals).toCall(Assertions::fail);
206+
this.map.from("123").when("456"::equals).when("123"::equals).toCall(this::failure);
207207
}
208208

209209
@Test
@@ -256,6 +256,10 @@ void toCallWhenNull() {
256256
assertThat(called).isFalse();
257257
}
258258

259+
private void failure() {
260+
fail();
261+
}
262+
259263
/**
260264
* Tests for {@link Always}.
261265
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import io.micrometer.tracing.exporter.SpanExportingPredicate;
4747
import io.micrometer.tracing.exporter.SpanFilter;
4848
import io.micrometer.tracing.exporter.SpanReporter;
49-
import org.assertj.core.api.Assertions;
5049
import org.assertj.core.api.InstanceOfAssertFactories;
5150
import org.junit.jupiter.api.Test;
5251

@@ -63,6 +62,7 @@
6362

6463
import static org.assertj.core.api.Assertions.assertThat;
6564
import static org.assertj.core.api.Assertions.assertThatException;
65+
import static org.assertj.core.api.Assertions.fail;
6666
import static org.mockito.Mockito.mock;
6767

6868
/**
@@ -401,7 +401,7 @@ private List<Factory> getInjectors(Factory factory) {
401401
if (factory instanceof CompositePropagationFactory compositePropagationFactory) {
402402
return compositePropagationFactory.getInjectors().toList();
403403
}
404-
Assertions.fail("Expected CompositePropagationFactory, found %s".formatted(factory.getClass()));
404+
fail("Expected CompositePropagationFactory, found %s".formatted(factory.getClass()));
405405
throw new AssertionError("Unreachable");
406406
}
407407

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.Collections;
2020

2121
import com.samskivert.mustache.Mustache;
22-
import org.assertj.core.api.Assertions;
2322
import org.junit.jupiter.api.Test;
2423

2524
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +29,8 @@
3029
import org.springframework.context.annotation.Import;
3130
import org.springframework.test.annotation.DirtiesContext;
3231

32+
import static org.assertj.core.api.Assertions.assertThat;
33+
3334
/**
3435
* Integration Tests for {@link MustacheAutoConfiguration} outside of a web application.
3536
*
@@ -44,8 +45,7 @@ class MustacheStandaloneIntegrationTests {
4445

4546
@Test
4647
void directCompilation() {
47-
Assertions
48-
.assertThat(this.compiler.compile("Hello: {{world}}").execute(Collections.singletonMap("world", "World")))
48+
assertThat(this.compiler.compile("Hello: {{world}}").execute(Collections.singletonMap("world", "World")))
4949
.isEqualTo("Hello: World");
5050
}
5151

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.aspectj.lang.JoinPoint;
3737
import org.aspectj.lang.annotation.AfterReturning;
3838
import org.aspectj.lang.annotation.Aspect;
39-
import org.assertj.core.api.Assertions;
4039
import org.assertj.core.api.InstanceOfAssertFactories;
4140
import org.jspecify.annotations.Nullable;
4241
import org.junit.jupiter.api.Test;
@@ -133,6 +132,7 @@
133132

134133
import static org.assertj.core.api.Assertions.assertThat;
135134
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
135+
import static org.assertj.core.api.Assertions.setExtractBareNamePropertyMethods;
136136
import static org.mockito.ArgumentMatchers.any;
137137
import static org.mockito.BDDMockito.then;
138138
import static org.mockito.Mockito.mock;
@@ -488,7 +488,7 @@ void multipleWebFluxRegistrations() {
488488

489489
@Test
490490
void cachePeriod() {
491-
Assertions.setExtractBareNamePropertyMethods(false);
491+
setExtractBareNamePropertyMethods(false);
492492
this.contextRunner.withPropertyValues("spring.web.resources.cache.period:5").run((context) -> {
493493
Map<PathPattern, Object> handlerMap = getHandlerMap(context);
494494
assertThat(handlerMap).hasSize(2);
@@ -499,12 +499,12 @@ void cachePeriod() {
499499
}
500500
}
501501
});
502-
Assertions.setExtractBareNamePropertyMethods(true);
502+
setExtractBareNamePropertyMethods(true);
503503
}
504504

505505
@Test
506506
void cacheControl() {
507-
Assertions.setExtractBareNamePropertyMethods(false);
507+
setExtractBareNamePropertyMethods(false);
508508
this.contextRunner
509509
.withPropertyValues("spring.web.resources.cache.cachecontrol.max-age:5",
510510
"spring.web.resources.cache.cachecontrol.proxy-revalidate:true")
@@ -518,7 +518,7 @@ void cacheControl() {
518518
}
519519
}
520520
});
521-
Assertions.setExtractBareNamePropertyMethods(true);
521+
setExtractBareNamePropertyMethods(true);
522522
}
523523

524524
@Test

0 commit comments

Comments
 (0)