From 2c61064d93f8f429977a7c311fd606e3f584e0d2 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 23 Aug 2016 17:11:14 +0200 Subject: [PATCH] Fix property prefix This commit fixes the prefix for the WebClient and WebDriver auto-config so that it complies with the prefix set on `AutoconfigureWebMvc` Closes gh-6727 --- .../web/servlet/MockMvcWebClientAutoConfiguration.java | 2 +- .../web/servlet/MockMvcWebDriverAutoConfiguration.java | 2 +- ...bMvcTestWithAutoConfigureMockMvcIntegrationTests.java | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebClientAutoConfiguration.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebClientAutoConfiguration.java index b884e28104..a3a2805b78 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebClientAutoConfiguration.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebClientAutoConfiguration.java @@ -39,7 +39,7 @@ import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder; @Configuration @ConditionalOnClass(WebClient.class) @AutoConfigureAfter(MockMvcAutoConfiguration.class) -@ConditionalOnProperty(prefix = "spring.test.webmvc.webclient", name = "enabled", matchIfMissing = true) +@ConditionalOnProperty(prefix = "spring.test.mockmvc.webclient", name = "enabled", matchIfMissing = true) public class MockMvcWebClientAutoConfiguration { private final Environment environment; diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebDriverAutoConfiguration.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebDriverAutoConfiguration.java index 5fadb29625..5b348b5fbb 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebDriverAutoConfiguration.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebDriverAutoConfiguration.java @@ -41,7 +41,7 @@ import org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDr @Configuration @ConditionalOnClass(HtmlUnitDriver.class) @AutoConfigureAfter(MockMvcAutoConfiguration.class) -@ConditionalOnProperty(prefix = "spring.test.webmvc.webdriver", name = "enabled", matchIfMissing = true) +@ConditionalOnProperty(prefix = "spring.test.mockmvc.webdriver", name = "enabled", matchIfMissing = true) public class MockMvcWebDriverAutoConfiguration { private final Environment environment; diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java index 5c1b84359c..4684c8368f 100644 --- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java @@ -17,10 +17,13 @@ package org.springframework.boot.test.autoconfigure.web.servlet; import com.gargoylesoftware.htmlunit.WebClient; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.junit4.SpringRunner; @@ -33,12 +36,16 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Tests for {@link WebMvcTest} with {@link AutoConfigureMockMvc}. * * @author Phillip Webb + * @author Stephane Nicoll */ @RunWith(SpringRunner.class) @WebMvcTest @AutoConfigureMockMvc(addFilters = false, webClientEnabled = false, webDriverEnabled = false) public class WebMvcTestWithAutoConfigureMockMvcIntegrationTests { + @Rule + public ExpectedException thrown = ExpectedException.none(); + @Autowired private ApplicationContext context; @@ -52,11 +59,13 @@ public class WebMvcTestWithAutoConfigureMockMvcIntegrationTests { @Test public void shouldNotHaveWebDriver() throws Exception { + this.thrown.expect(NoSuchBeanDefinitionException.class); this.context.getBean(WebDriver.class); } @Test public void shouldNotHaveWebClient() throws Exception { + this.thrown.expect(NoSuchBeanDefinitionException.class); this.context.getBean(WebClient.class); }