本文整理匯總了Java中org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration類的典型用法代碼示例。如果您正苦於以下問題:Java WebMvcAutoConfiguration類的具體用法?Java WebMvcAutoConfiguration怎麽用?Java WebMvcAutoConfiguration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WebMvcAutoConfiguration類屬於org.springframework.boot.autoconfigure.web包,在下文中一共展示了WebMvcAutoConfiguration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: agentServletWithCustomPath
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void agentServletWithCustomPath() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"endpoints.jolokia.path=/foo/bar");
this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
JolokiaAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBeanNamesForType(JolokiaMvcEndpoint.class)).hasSize(1);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
mockMvc.perform(MockMvcRequestBuilders.get("/foo/bar"))
.andExpect(MockMvcResultMatchers.content()
.string(Matchers.containsString("\"request\":{\"type\"")));
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:18,代碼來源:JolokiaAutoConfigurationTests.java
示例2: contextPath
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void contextPath() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"management.contextPath:/test");
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
EndpointWebMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/test/endpoint", ports.get().server, "endpointoutput");
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:17,代碼來源:EndpointWebMvcAutoConfigurationTests.java
示例3: overrideServerProperties
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void overrideServerProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"server.displayName:foo");
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
EndpointWebMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
ServerProperties serverProperties = this.applicationContext
.getBean(ServerProperties.class);
assertThat(serverProperties.getDisplayName()).isEqualTo("foo");
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:19,代碼來源:EndpointWebMvcAutoConfigurationTests.java
示例4: testWebConfiguration
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void testWebConfiguration() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(SecurityAutoConfiguration.class,
WebMvcAutoConfiguration.class,
ManagementWebSecurityAutoConfiguration.class,
JacksonAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false");
this.context.refresh();
assertThat(this.context.getBean(AuthenticationManagerBuilder.class)).isNotNull();
FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
// 1 for static resources, one for management endpoints and one for the rest
assertThat(filterChainProxy.getFilterChains()).hasSize(3);
assertThat(filterChainProxy.getFilters("/beans")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/beans/")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/beans.foo")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/beans/foo/bar")).isNotEmpty();
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:24,代碼來源:ManagementWebSecurityAutoConfigurationTests.java
示例5: sitePreferenceHandlerInterceptorRegistered
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void sitePreferenceHandlerInterceptorRegistered() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(Config.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
SitePreferenceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
RequestMappingHandlerMapping mapping = this.context
.getBean(RequestMappingHandlerMapping.class);
HandlerInterceptor[] interceptors = mapping
.getHandler(new MockHttpServletRequest()).getInterceptors();
assertThat(interceptors)
.hasAtLeastOneElementOfType(SitePreferenceHandlerInterceptor.class);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:17,代碼來源:SitePreferenceAutoConfigurationTests.java
示例6: deviceDelegatingThymeleafViewResolverEnabled
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void deviceDelegatingThymeleafViewResolverEnabled() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mobile.devicedelegatingviewresolver.enabled:true");
this.context.register(Config.class, WebMvcAutoConfiguration.class,
ThymeleafAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DeviceDelegatingViewResolverConfiguration.class);
this.context.refresh();
ThymeleafViewResolver thymeleafViewResolver = this.context
.getBean(ThymeleafViewResolver.class);
AbstractDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context
.getBean("deviceDelegatingViewResolver",
AbstractDeviceDelegatingViewResolver.class);
assertThat(thymeleafViewResolver).isNotNull();
assertThat(deviceDelegatingViewResolver).isNotNull();
assertThat(deviceDelegatingViewResolver.getViewResolver())
.isInstanceOf(ThymeleafViewResolver.class);
assertThat(this.context.getBean(InternalResourceViewResolver.class)).isNotNull();
assertThat(this.context.getBean(ThymeleafViewResolver.class)).isNotNull();
assertThat(deviceDelegatingViewResolver.getOrder())
.isEqualTo(thymeleafViewResolver.getOrder() - 1);
}
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:26,代碼來源:DeviceDelegatingViewResolverAutoConfigurationTests.java
示例7: deviceDelegatingThymeleafViewResolverDisabled
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingThymeleafViewResolverDisabled() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mobile.devicedelegatingviewresolver.enabled:false");
this.context.register(Config.class, WebMvcAutoConfiguration.class,
ThymeleafAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DeviceDelegatingViewResolverConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(InternalResourceViewResolver.class)).isNotNull();
assertThat(this.context.getBean(ThymeleafViewResolver.class)).isNotNull();
this.context.getBean("deviceDelegatingViewResolver",
AbstractDeviceDelegatingViewResolver.class);
}
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:17,代碼來源:DeviceDelegatingViewResolverAutoConfigurationTests.java
示例8: defaultPropertyValues
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void defaultPropertyValues() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mobile.devicedelegatingviewresolver.enabled:true");
this.context.register(Config.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DeviceDelegatingViewResolverConfiguration.class);
this.context.refresh();
LiteDeviceDelegatingViewResolver liteDeviceDelegatingViewResolver = this.context
.getBean("deviceDelegatingViewResolver",
LiteDeviceDelegatingViewResolver.class);
DirectFieldAccessor accessor = new DirectFieldAccessor(
liteDeviceDelegatingViewResolver);
assertThat(accessor.getPropertyValue("enableFallback")).isEqualTo(Boolean.FALSE);
assertThat(accessor.getPropertyValue("normalPrefix")).isEqualTo("");
assertThat(accessor.getPropertyValue("mobilePrefix")).isEqualTo("mobile/");
assertThat(accessor.getPropertyValue("tabletPrefix")).isEqualTo("tablet/");
assertThat(accessor.getPropertyValue("normalSuffix")).isEqualTo("");
assertThat(accessor.getPropertyValue("mobileSuffix")).isEqualTo("");
assertThat(accessor.getPropertyValue("tabletSuffix")).isEqualTo("");
}
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:25,代碼來源:DeviceDelegatingViewResolverAutoConfigurationTests.java
示例9: agentServletWithCustomPath
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void agentServletWithCustomPath() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"endpoints.jolokia.path=/foo/bar");
this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
JolokiaAutoConfiguration.class);
this.context.refresh();
assertEquals(1,
this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
mockMvc.perform(MockMvcRequestBuilders.get("/foo/bar"))
.andExpect(MockMvcResultMatchers.content()
.string(Matchers.containsString("\"request\":{\"type\"")));
}
示例10: contextPath
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void contextPath() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"management.contextPath:/test");
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
EndpointWebMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/test/endpoint", ports.get().server, "endpointoutput");
this.applicationContext.close();
assertAllClosed();
}
示例11: testWebConfiguration
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void testWebConfiguration() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(SecurityAutoConfiguration.class,
WebMvcAutoConfiguration.class,
ManagementWebSecurityAutoConfiguration.class,
JacksonAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false");
this.context.refresh();
assertNotNull(this.context.getBean(AuthenticationManagerBuilder.class));
FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
// 4 for static resources, one for management endpoints and one for the rest
assertThat(filterChainProxy.getFilterChains(), hasSize(6));
assertThat(filterChainProxy.getFilters("/beans"), hasSize(greaterThan(0)));
assertThat(filterChainProxy.getFilters("/beans/"), hasSize(greaterThan(0)));
assertThat(filterChainProxy.getFilters("/beans.foo"), hasSize(greaterThan(0)));
assertThat(filterChainProxy.getFilters("/beans/foo/bar"),
hasSize(greaterThan(0)));
}
示例12: sitePreferenceHandlerInterceptorRegistered
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void sitePreferenceHandlerInterceptorRegistered() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(Config.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
SitePreferenceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
RequestMappingHandlerMapping mapping = this.context
.getBean(RequestMappingHandlerMapping.class);
HandlerInterceptor[] interceptors = mapping
.getHandler(new MockHttpServletRequest()).getInterceptors();
assertThat(interceptors,
hasItemInArray(instanceOf(SitePreferenceHandlerInterceptor.class)));
}
示例13: deviceDelegatingInternalResourceViewResolverDisabled
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingInternalResourceViewResolverDisabled() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mobile.devicedelegatingviewresolver.enabled:false");
this.context.register(Config.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DeviceDelegatingViewResolverConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
try {
this.context.getBean(ThymeleafViewResolver.class);
}
catch (NoSuchBeanDefinitionException ex) {
// expected. ThymeleafViewResolver shouldn't be defined.
}
this.context.getBean("deviceDelegatingViewResolver",
AbstractDeviceDelegatingViewResolver.class);
}
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:21,代碼來源:DeviceDelegatingViewResolverAutoConfigurationTests.java
示例14: deviceDelegatingThymeleafViewResolverEnabled
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test
public void deviceDelegatingThymeleafViewResolverEnabled() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mobile.devicedelegatingviewresolver.enabled:true");
this.context.register(Config.class, WebMvcAutoConfiguration.class,
ThymeleafAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DeviceDelegatingViewResolverConfiguration.class);
this.context.refresh();
ThymeleafViewResolver thymeleafViewResolver = this.context
.getBean(ThymeleafViewResolver.class);
AbstractDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context
.getBean("deviceDelegatingViewResolver",
AbstractDeviceDelegatingViewResolver.class);
assertNotNull(thymeleafViewResolver);
assertNotNull(deviceDelegatingViewResolver);
assertTrue(deviceDelegatingViewResolver
.getViewResolver() instanceof ThymeleafViewResolver);
assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
assertNotNull(this.context.getBean(ThymeleafViewResolver.class));
assertTrue(deviceDelegatingViewResolver
.getOrder() == thymeleafViewResolver.getOrder() - 1);
}
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:26,代碼來源:DeviceDelegatingViewResolverAutoConfigurationTests.java
示例15: deviceDelegatingThymeleafViewResolverDisabled
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; //導入依賴的package包/類
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingThymeleafViewResolverDisabled() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mobile.devicedelegatingviewresolver.enabled:false");
this.context.register(Config.class, WebMvcAutoConfiguration.class,
ThymeleafAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DeviceDelegatingViewResolverConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
assertNotNull(this.context.getBean(ThymeleafViewResolver.class));
this.context.getBean("deviceDelegatingViewResolver",
AbstractDeviceDelegatingViewResolver.class);
}
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:17,代碼來源:DeviceDelegatingViewResolverAutoConfigurationTests.java