diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java index c483214e30e..c9a78e35a2d 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java @@ -97,7 +97,7 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom } @Configuration - @ConditionalOnProperty(prefix = "error.whitelable", name = "enabled", matchIfMissing = true) + @ConditionalOnProperty(prefix = "error.whitelabel", name = "enabled", matchIfMissing = true) @Conditional(ErrorTemplateMissingCondition.class) protected static class WhitelabelErrorViewConfiguration { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerDirectMockMvcTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerDirectMockMvcTests.java index a0f5e269a0e..7bb3248889a 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerDirectMockMvcTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerDirectMockMvcTests.java @@ -22,8 +22,13 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.servlet.ServletException; + import org.junit.After; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -47,9 +52,13 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * {@link SpringJUnit4ClassRunner}. * * @author Dave Syer + * @author Sebastien Deleuze */ public class BasicErrorControllerDirectMockMvcTests { + @Rule + public final ExpectedException thrown = ExpectedException.none(); + private ConfigurableWebApplicationContext wac; private MockMvc mockMvc; @@ -87,6 +96,15 @@ public class BasicErrorControllerDirectMockMvcTests { assertTrue("Wrong content: " + content, content.contains("status=999")); } + @Test + public void errorPageNotAvailableWithWhitelabelDisabled() throws Exception { + setup((ConfigurableWebApplicationContext) new SpringApplication( + WebMvcIncludedConfiguration.class).run("--server.port=0", "--error.whitelabel.enabled=false")); + + thrown.expect(ServletException.class); + this.mockMvc.perform(get("/error").accept(MediaType.TEXT_HTML)); + } + @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented