mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-29 21:59:02 +00:00
Add nullability annotations to tests in module/spring-boot-mustache
See gh-47263
This commit is contained in:
@@ -46,5 +46,11 @@ dependencies {
|
||||
testImplementation(testFixtures(project(":core:spring-boot-autoconfigure")))
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
|
||||
testCompileOnly("com.google.code.findbugs:jsr305")
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+4
-1
@@ -34,6 +34,7 @@ import org.springframework.boot.resttestclient.TestRestTemplate;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
|
||||
import org.springframework.boot.web.server.WebServer;
|
||||
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -63,7 +64,9 @@ class MustacheAutoConfigurationServletIntegrationTests {
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
this.port = this.context.getWebServer().getPort();
|
||||
WebServer webServer = this.context.getWebServer();
|
||||
assertThat(webServer).isNotNull();
|
||||
this.port = webServer.getPort();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.mustache.reactive.view;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -46,13 +47,13 @@ class MustacheViewResolverTests {
|
||||
|
||||
@Test
|
||||
void resolveNonExistent() {
|
||||
assertThat(this.resolver.resolveViewName("bar", null).block(Duration.ofSeconds(30))).isNull();
|
||||
assertThat(this.resolver.resolveViewName("bar", Locale.ROOT).block(Duration.ofSeconds(30))).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithResource(name = "template.html", content = "Hello {{World}}")
|
||||
void resolveExisting() {
|
||||
assertThat(this.resolver.resolveViewName("template", null).block(Duration.ofSeconds(30))).isNotNull();
|
||||
assertThat(this.resolver.resolveViewName("template", Locale.ROOT).block(Duration.ofSeconds(30))).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-3
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.mustache.servlet.view;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -49,20 +51,21 @@ class MustacheViewResolverTests {
|
||||
|
||||
@Test
|
||||
void resolveNonExistent() throws Exception {
|
||||
assertThat(this.resolver.resolveViewName("bar", null)).isNull();
|
||||
assertThat(this.resolver.resolveViewName("bar", Locale.ROOT)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithResource(name = "template.html", content = "Hello {{World}}")
|
||||
void resolveExisting() throws Exception {
|
||||
assertThat(this.resolver.resolveViewName("template", null)).isNotNull();
|
||||
assertThat(this.resolver.resolveViewName("template", Locale.ROOT)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithResource(name = "template.html", content = "Hello {{World}}")
|
||||
void setsContentType() throws Exception {
|
||||
this.resolver.setContentType("application/octet-stream");
|
||||
View view = this.resolver.resolveViewName("template", null);
|
||||
View view = this.resolver.resolveViewName("template", Locale.ROOT);
|
||||
assertThat(view).isNotNull();
|
||||
Assertions.assertThat(view.getContentType()).isEqualTo("application/octet-stream");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user