@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");
}
java类org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration的实例源码
EndpointWebMvcAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 43
收藏 0
点赞 0
评论 0
EndpointWebMvcAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 38
收藏 0
点赞 0
评论 0
@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");
}
SpringApplicationAdminJmxAutoConfigurationTests.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 34
收藏 0
点赞 0
评论 0
@Test
public void registerWithSimpleWebApp() throws Exception {
this.context = new SpringApplicationBuilder()
.sources(EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class)
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
"EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
int expected = ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedServletContainer().getPort();
String actual = getProperty(createDefaultObjectName(), "local.server.port");
assertThat(actual).isEqualTo(String.valueOf(expected));
}
EndpointWebMvcAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 35
收藏 0
点赞 0
评论 0
@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");
}
EndpointWebMvcAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 37
收藏 0
点赞 0
评论 0
@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");
}
SpringApplicationAdminJmxAutoConfigurationTests.java 文件源码
项目:spring-boot-concourse
阅读 33
收藏 0
点赞 0
评论 0
@Test
public void registerWithSimpleWebApp() throws Exception {
this.context = new SpringApplicationBuilder()
.sources(EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class)
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
"EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
int expected = ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedServletContainer().getPort();
String actual = getProperty(createDefaultObjectName(), "local.server.port");
assertThat(actual).isEqualTo(String.valueOf(expected));
}
EndpointWebMvcAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 35
收藏 0
点赞 0
评论 0
@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();
}
SpringApplicationAdminJmxAutoConfigurationTests.java 文件源码
项目:contestparser
阅读 25
收藏 0
点赞 0
评论 0
@Test
public void registerWithSimpleWebApp() throws Exception {
this.context = new SpringApplicationBuilder()
.sources(EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
JmxAutoConfiguration.class,
SpringApplicationAdminJmxAutoConfiguration.class)
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
assertTrue(this.context instanceof EmbeddedWebApplicationContext);
assertEquals(true, this.mBeanServer.getAttribute(createDefaultObjectName(),
"EmbeddedWebApplication"));
int expected = ((EmbeddedWebApplicationContext) this.context)
.getEmbeddedServletContainer().getPort();
String actual = getProperty(createDefaultObjectName(), "local.server.port");
assertEquals(String.valueOf(expected), actual);
}
EndpointObfuscatorConfiguration.java 文件源码
项目:joal
阅读 34
收藏 0
点赞 0
评论 0
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
final ServletRegistrationBean registration = new ServletRegistrationBean(
dispatcherServlet(),
"/" + this.pathPrefix + "/*"
);
registration.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
return registration;
}
AsyncServletConfiguration.java 文件源码
项目:service-integration-sdk
阅读 37
收藏 0
点赞 0
评论 0
/**
* Register dispatcherServlet programmatically
*
* @return ServletRegistrationBean
*/
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(
dispatcherServlet(), "/");
registration
.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
registration.setAsyncSupported(true);
registration.setEnabled(true);
registration.setLoadOnStartup(1);
return registration;
}
EndpointWebMvcAutoConfiguration.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 27
收藏 0
点赞 0
评论 0
private void createChildManagementContext() {
AnnotationConfigEmbeddedWebApplicationContext childContext = new AnnotationConfigEmbeddedWebApplicationContext();
childContext.setParent(this.applicationContext);
childContext.setNamespace("management");
childContext.setId(this.applicationContext.getId() + ":management");
childContext.register(EndpointWebMvcChildContextConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
DispatcherServletAutoConfiguration.class);
registerEmbeddedServletContainerFactory(childContext);
CloseManagementContextListener.addIfPossible(this.applicationContext,
childContext);
childContext.refresh();
managementContextResolver().setApplicationContext(childContext);
}
EndpointWebMvcAutoConfiguration.java 文件源码
项目:spring-boot-concourse
阅读 32
收藏 0
点赞 0
评论 0
private void createChildManagementContext() {
AnnotationConfigEmbeddedWebApplicationContext childContext = new AnnotationConfigEmbeddedWebApplicationContext();
childContext.setParent(this.applicationContext);
childContext.setNamespace("management");
childContext.setId(this.applicationContext.getId() + ":management");
childContext.register(EndpointWebMvcChildContextConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
DispatcherServletAutoConfiguration.class);
registerEmbeddedServletContainerFactory(childContext);
CloseManagementContextListener.addIfPossible(this.applicationContext,
childContext);
childContext.refresh();
managementContextResolver().setApplicationContext(childContext);
}
FakeHackpadServer.java 文件源码
项目:awesome-agile
阅读 35
收藏 0
点赞 0
评论 0
private void start() {
try {
webApplicationContext = SpringApplication.run(
new Object[]{
FakeHackpadServerConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class},
new String[]{"--server.port=" + port});
webApplicationContext.getAutowireCapableBeanFactory().autowireBean(this);
} catch (Exception ex) {
throw new RuntimeException("Unable to start fake Google OAuth server", ex);
}
}
FakeGoogleServer.java 文件源码
项目:awesome-agile
阅读 29
收藏 0
点赞 0
评论 0
private void start() {
try {
webApplicationContext = SpringApplication.run(
new Object[] {
FakeGoogleOAuthServerConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
DispatcherServletAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class},
new String[] { "--server.port=" + port });
webApplicationContext.getAutowireCapableBeanFactory().autowireBean(this);
} catch (Exception ex) {
throw new RuntimeException("Unable to start fake Google OAuth server", ex);
}
}
EndpointWebMvcAutoConfiguration.java 文件源码
项目:contestparser
阅读 34
收藏 0
点赞 0
评论 0
private void createChildManagementContext() {
final AnnotationConfigEmbeddedWebApplicationContext childContext = new AnnotationConfigEmbeddedWebApplicationContext();
childContext.setParent(this.applicationContext);
childContext.setNamespace("management");
childContext.setId(this.applicationContext.getId() + ":management");
childContext.register(EndpointWebMvcChildContextConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
DispatcherServletAutoConfiguration.class);
CloseEventPropagationListener.addIfPossible(this.applicationContext,
childContext);
childContext.refresh();
managementContextResolver().setApplicationContext(childContext);
}
Main.java 文件源码
项目:infotranspub-backend
阅读 30
收藏 0
点赞 0
评论 0
@Bean
public ServletRegistrationBean dispatchServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(dispatcherServlet(), "/api/*");
registration.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
return registration;
}
Application.java 文件源码
项目:gradlejug
阅读 37
收藏 0
点赞 0
评论 0
@Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
public DispatcherServlet dispatcherServlet() {
return new DispatcherServlet();
}