Browse Source

Add nullability annotations to tests in module/spring-boot-mustache

See gh-47263
pull/47626/head
Moritz Halbritter 4 months ago
parent
commit
45ea5b9071
  1. 6
      module/spring-boot-mustache/build.gradle
  2. 5
      module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationServletIntegrationTests.java
  3. 5
      module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/reactive/view/MustacheViewResolverTests.java
  4. 9
      module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/servlet/view/MustacheViewResolverTests.java

6
module/spring-boot-mustache/build.gradle

@ -46,5 +46,11 @@ dependencies { @@ -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"
}

5
module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationServletIntegrationTests.java

@ -34,6 +34,7 @@ import org.springframework.boot.resttestclient.TestRestTemplate; @@ -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 { @@ -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

5
module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/reactive/view/MustacheViewResolverTests.java

@ -17,6 +17,7 @@ @@ -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 { @@ -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();
}
}

9
module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/servlet/view/MustacheViewResolverTests.java

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

Loading…
Cancel
Save