Add nullability annotations to tests in smoke-test/spring-boot-smoke-test-web-secure-jdbc

See gh-47263
This commit is contained in:
Moritz Halbritter
2025-10-16 11:24:50 +02:00
parent 34cad95638
commit 68da06fe86
2 changed files with 11 additions and 2 deletions
@@ -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"
}
@@ -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<String> 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<String> 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 + "/");
}
}