Browse Source

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

See gh-47263
pull/47665/head
Moritz Halbritter 3 months ago
parent
commit
68da06fe86
  1. 4
      smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle
  2. 9
      smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java

4
smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle

@ -31,3 +31,7 @@ dependencies { @@ -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"
}

9
smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java

@ -16,6 +16,7 @@ @@ -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 { @@ -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 { @@ -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 + "/");
}
}

Loading…
Cancel
Save