mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-25 02:49:03 +00:00
Add nullability annotations to tests in smoke-test/spring-boot-smoke-test-web-secure
See gh-47263
This commit is contained in:
@@ -28,3 +28,7 @@ dependencies {
|
||||
testImplementation(project(":starter:spring-boot-starter-webmvc-test"))
|
||||
testImplementation("org.apache.httpcomponents.client5:httpclient5")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+2
@@ -73,6 +73,7 @@ abstract class AbstractErrorPageTests {
|
||||
.exchange(this.pathPrefix + "/public/notfound", HttpMethod.GET, null, JsonNode.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
JsonNode jsonResponse = response.getBody();
|
||||
assertThat(jsonResponse).isNotNull();
|
||||
assertThat(jsonResponse.get("error").asString()).isEqualTo("Not Found");
|
||||
}
|
||||
|
||||
@@ -91,6 +92,7 @@ abstract class AbstractErrorPageTests {
|
||||
.exchange(this.pathPrefix + "/fail", HttpMethod.GET, null, JsonNode.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
JsonNode jsonResponse = response.getBody();
|
||||
assertThat(jsonResponse).isNotNull();
|
||||
assertThat(jsonResponse.get("error").asString()).isEqualTo("Internal Server Error");
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -52,6 +52,7 @@ abstract class AbstractUnauthenticatedErrorPageTests {
|
||||
.exchange(this.pathPrefix + "/test", HttpMethod.GET, null, JsonNode.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
JsonNode jsonResponse = response.getBody();
|
||||
assertThat(jsonResponse).isNotNull();
|
||||
assertThat(jsonResponse.get("error").asString()).isEqualTo("Unauthorized");
|
||||
}
|
||||
|
||||
@@ -61,6 +62,7 @@ abstract class AbstractUnauthenticatedErrorPageTests {
|
||||
HttpMethod.GET, null, JsonNode.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
JsonNode jsonResponse = response.getBody();
|
||||
assertThat(jsonResponse).isNotNull();
|
||||
assertThat(jsonResponse.get("error").asString()).isEqualTo("Unauthorized");
|
||||
}
|
||||
|
||||
@@ -70,6 +72,7 @@ abstract class AbstractUnauthenticatedErrorPageTests {
|
||||
HttpMethod.GET, null, JsonNode.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
JsonNode jsonResponse = response.getBody();
|
||||
assertThat(jsonResponse).isNotNull();
|
||||
assertThat(jsonResponse.get("error").asString()).isEqualTo("Not Found");
|
||||
}
|
||||
|
||||
@@ -79,6 +82,7 @@ abstract class AbstractUnauthenticatedErrorPageTests {
|
||||
.exchange(this.pathPrefix + "/public/notfound", HttpMethod.GET, null, JsonNode.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
JsonNode jsonResponse = response.getBody();
|
||||
assertThat(jsonResponse).isNotNull();
|
||||
assertThat(jsonResponse.get("error").asString()).isEqualTo("Not Found");
|
||||
}
|
||||
|
||||
@@ -88,6 +92,7 @@ abstract class AbstractUnauthenticatedErrorPageTests {
|
||||
.exchange(this.pathPrefix + "/public/notfound", HttpMethod.GET, null, JsonNode.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
JsonNode jsonResponse = response.getBody();
|
||||
assertThat(jsonResponse).isNotNull();
|
||||
assertThat(jsonResponse.get("error").asString()).isEqualTo("Unauthorized");
|
||||
}
|
||||
|
||||
@@ -97,6 +102,7 @@ abstract class AbstractUnauthenticatedErrorPageTests {
|
||||
.exchange(this.pathPrefix + "/fail", HttpMethod.GET, null, JsonNode.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
JsonNode jsonResponse = response.getBody();
|
||||
assertThat(jsonResponse).isNotNull();
|
||||
assertThat(jsonResponse.get("error").asString()).isEqualTo("Internal Server Error");
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package smoketest.web.secure;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
|
||||
import jakarta.servlet.DispatcherType;
|
||||
@@ -68,7 +69,9 @@ class SampleWebSecureApplicationTests {
|
||||
ResponseEntity<String> entity = this.restTemplate.withRedirects(HttpRedirects.DONT_FOLLOW)
|
||||
.exchange("/home", 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
|
||||
@@ -92,7 +95,9 @@ class SampleWebSecureApplicationTests {
|
||||
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 + "/");
|
||||
}
|
||||
|
||||
@org.springframework.boot.test.context.TestConfiguration(proxyBeanMethods = false)
|
||||
|
||||
Reference in New Issue
Block a user