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
pull/6752/head
Stephane Nicoll 8 years ago
parent 5a1741e2e8
commit 2c61064d93

@ -39,7 +39,7 @@ import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder;
@Configuration @Configuration
@ConditionalOnClass(WebClient.class) @ConditionalOnClass(WebClient.class)
@AutoConfigureAfter(MockMvcAutoConfiguration.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 { public class MockMvcWebClientAutoConfiguration {
private final Environment environment; private final Environment environment;

@ -41,7 +41,7 @@ import org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDr
@Configuration @Configuration
@ConditionalOnClass(HtmlUnitDriver.class) @ConditionalOnClass(HtmlUnitDriver.class)
@AutoConfigureAfter(MockMvcAutoConfiguration.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 { public class MockMvcWebDriverAutoConfiguration {
private final Environment environment; private final Environment environment;

@ -17,10 +17,13 @@
package org.springframework.boot.test.autoconfigure.web.servlet; package org.springframework.boot.test.autoconfigure.web.servlet;
import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebClient;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.test.context.junit4.SpringRunner; 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}. * Tests for {@link WebMvcTest} with {@link AutoConfigureMockMvc}.
* *
* @author Phillip Webb * @author Phillip Webb
* @author Stephane Nicoll
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@WebMvcTest @WebMvcTest
@AutoConfigureMockMvc(addFilters = false, webClientEnabled = false, webDriverEnabled = false) @AutoConfigureMockMvc(addFilters = false, webClientEnabled = false, webDriverEnabled = false)
public class WebMvcTestWithAutoConfigureMockMvcIntegrationTests { public class WebMvcTestWithAutoConfigureMockMvcIntegrationTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Autowired @Autowired
private ApplicationContext context; private ApplicationContext context;
@ -52,11 +59,13 @@ public class WebMvcTestWithAutoConfigureMockMvcIntegrationTests {
@Test @Test
public void shouldNotHaveWebDriver() throws Exception { public void shouldNotHaveWebDriver() throws Exception {
this.thrown.expect(NoSuchBeanDefinitionException.class);
this.context.getBean(WebDriver.class); this.context.getBean(WebDriver.class);
} }
@Test @Test
public void shouldNotHaveWebClient() throws Exception { public void shouldNotHaveWebClient() throws Exception {
this.thrown.expect(NoSuchBeanDefinitionException.class);
this.context.getBean(WebClient.class); this.context.getBean(WebClient.class);
} }

Loading…
Cancel
Save