From 68da06fe86bda618bf5e7592e164fb1f721a4d24 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Thu, 16 Oct 2025 10:00:27 +0200 Subject: [PATCH] Add nullability annotations to tests in smoke-test/spring-boot-smoke-test-web-secure-jdbc See gh-47263 --- .../spring-boot-smoke-test-web-secure-jdbc/build.gradle | 4 ++++ .../secure/jdbc/SampleWebSecureJdbcApplicationTests.java | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle b/smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle index fd358486631..9b81ede18d8 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle @@ -31,3 +31,7 @@ dependencies { testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } + +tasks.named("compileTestJava") { + options.nullability.checking = "tests" +} diff --git a/smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java index 1f6a4f8b919..8b46bff3e25 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java @@ -16,6 +16,7 @@ package smoketest.web.secure.jdbc; +import java.net.URI; import java.util.Collections; import org.junit.jupiter.api.Test; @@ -61,7 +62,9 @@ class SampleWebSecureJdbcApplicationTests { ResponseEntity entity = this.restTemplate.withRedirects(HttpRedirects.DONT_FOLLOW) .exchange("/", HttpMethod.GET, new HttpEntity<>(headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND); - assertThat(entity.getHeaders().getLocation().toString()).endsWith(this.port + "/login"); + URI location = entity.getHeaders().getLocation(); + assertThat(location).isNotNull(); + assertThat(location.toString()).endsWith(this.port + "/login"); } @Test @@ -85,7 +88,9 @@ class SampleWebSecureJdbcApplicationTests { ResponseEntity entity = this.restTemplate.withRedirects(HttpRedirects.DONT_FOLLOW) .exchange("/login", HttpMethod.POST, new HttpEntity<>(form, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND); - assertThat(entity.getHeaders().getLocation().toString()).endsWith(this.port + "/"); + URI location = entity.getHeaders().getLocation(); + assertThat(location).isNotNull(); + assertThat(location.toString()).endsWith(this.port + "/"); } }