Browse Source

Add nullability annotations to tests in module/spring-boot-webmvc-test

See gh-47263
pull/47665/head
Moritz Halbritter 2 months ago
parent
commit
9d5c7a15f3
  1. 5
      module/spring-boot-webmvc-test/build.gradle
  2. 8
      module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/SpringBootMockMvcBuilderCustomizerTests.java

5
module/spring-boot-webmvc-test/build.gradle

@ -56,3 +56,8 @@ dependencies { @@ -56,3 +56,8 @@ dependencies {
tasks.named("test") {
exclude("**/WebMvcTestPrintDefaultIntegrationTests\$*")
}
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}

8
module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/SpringBootMockMvcBuilderCustomizerTests.java

@ -70,6 +70,7 @@ class SpringBootMockMvcBuilderCustomizerTests { @@ -70,6 +70,7 @@ class SpringBootMockMvcBuilderCustomizerTests {
FilterRegistrationBean<?> registrationBean = (FilterRegistrationBean<?>) context.getBean("otherTestFilter");
TestFilter testFilter = context.getBean("testFilter", TestFilter.class);
OtherTestFilter otherTestFilter = (OtherTestFilter) registrationBean.getFilter();
assertThat(otherTestFilter).isNotNull();
assertThat(builder).extracting("filters", as(InstanceOfAssertFactories.LIST))
.extracting("delegate", "dispatcherTypes")
.containsExactlyInAnyOrder(tuple(testFilter, EnumSet.of(DispatcherType.REQUEST)),
@ -96,6 +97,7 @@ class SpringBootMockMvcBuilderCustomizerTests { @@ -96,6 +97,7 @@ class SpringBootMockMvcBuilderCustomizerTests {
Thread thread = new Thread(() -> {
for (int j = 0; j < 1000; j++) {
DeferredLinesWriter writer = DeferredLinesWriter.get(context);
assertThat(writer).isNotNull();
writer.write(Arrays.asList("1", "2", "3", "4", "5"));
writer.writeDeferredResult();
writer.clear();
@ -162,9 +164,10 @@ class SpringBootMockMvcBuilderCustomizerTests { @@ -162,9 +164,10 @@ class SpringBootMockMvcBuilderCustomizerTests {
static class TestFilter implements Filter {
@SuppressWarnings("NullAway.Init")
private String filterName;
private Map<String, String> initParams = new HashMap<>();
private final Map<String, String> initParams = new HashMap<>();
@Override
public void init(FilterConfig filterConfig) {
@ -187,9 +190,10 @@ class SpringBootMockMvcBuilderCustomizerTests { @@ -187,9 +190,10 @@ class SpringBootMockMvcBuilderCustomizerTests {
static class OtherTestFilter implements Filter {
@SuppressWarnings("NullAway.Init")
private String filterName;
private Map<String, String> initParams = new HashMap<>();
private final Map<String, String> initParams = new HashMap<>();
@Override
public void init(FilterConfig filterConfig) {

Loading…
Cancel
Save