本文整理汇总了Java中org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java ErrorMvcAutoConfiguration类的具体用法?Java ErrorMvcAutoConfiguration怎么用?Java ErrorMvcAutoConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorMvcAutoConfiguration类属于org.springframework.boot.autoconfigure.web包,在下文中一共展示了ErrorMvcAutoConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDifferentPort
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void onDifferentPort() throws Exception {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, "endpointoutput");
assertContent("/error", ports.get().management, startsWith("{"));
ApplicationContext managementContext = this.applicationContext
.getBean(ManagementContextResolver.class).getApplicationContext();
List<?> interceptors = (List<?>) ReflectionTestUtils.getField(
managementContext.getBean(EndpointHandlerMapping.class), "interceptors");
assertThat(interceptors).hasSize(1);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:EndpointWebMvcAutoConfigurationTests.java
示例2: onDifferentPortWithSpecificContainer
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void onDifferentPortWithSpecificContainer() throws Exception {
this.applicationContext.register(SpecificContainerConfig.class, RootConfig.class,
DifferentPortConfig.class, EndpointConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, "endpointoutput");
assertContent("/error", ports.get().management, startsWith("{"));
ApplicationContext managementContext = this.applicationContext
.getBean(ManagementContextResolver.class).getApplicationContext();
List<?> interceptors = (List<?>) ReflectionTestUtils.getField(
managementContext.getBean(EndpointHandlerMapping.class), "interceptors");
assertThat(interceptors).hasSize(1);
EmbeddedServletContainerFactory parentContainerFactory = this.applicationContext
.getBean(EmbeddedServletContainerFactory.class);
EmbeddedServletContainerFactory managementContainerFactory = managementContext
.getBean(EmbeddedServletContainerFactory.class);
assertThat(parentContainerFactory)
.isInstanceOf(SpecificEmbeddedServletContainerFactory.class);
assertThat(managementContainerFactory)
.isInstanceOf(SpecificEmbeddedServletContainerFactory.class);
assertThat(managementContainerFactory).isNotSameAs(parentContainerFactory);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:27,代码来源:EndpointWebMvcAutoConfigurationTests.java
示例3: onRandomPort
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void onRandomPort() throws Exception {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
RandomPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
GrabManagementPort grabManagementPort = new GrabManagementPort(
this.applicationContext);
this.applicationContext.addApplicationListener(grabManagementPort);
this.applicationContext.refresh();
int managementPort = grabManagementPort.getServletContainer().getPort();
assertThat(managementPort).isNotEqualTo(ports.get().server);
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertContent("/controller", managementPort, null);
assertContent("/endpoint", managementPort, "endpointoutput");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:EndpointWebMvcAutoConfigurationTests.java
示例4: specificPortsViaPropertiesWithClash
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void specificPortsViaPropertiesWithClash() throws Exception {
int managementPort = ports.get().management;
ServerSocket serverSocket = new ServerSocket();
serverSocket.bind(new InetSocketAddress(managementPort));
try {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"server.port:" + ports.get().server,
"management.port:" + ports.get().management);
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class);
this.thrown.expect(EmbeddedServletContainerException.class);
this.applicationContext.refresh();
}
finally {
serverSocket.close();
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:EndpointWebMvcAutoConfigurationTests.java
示例5: portPropertiesOnDifferentPort
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void portPropertiesOnDifferentPort() throws Exception {
new ServerPortInfoApplicationContextInitializer()
.initialize(this.applicationContext);
this.applicationContext.register(RootConfig.class, DifferentPortConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
Integer localServerPort = this.applicationContext.getEnvironment()
.getProperty("local.server.port", Integer.class);
Integer localManagementPort = this.applicationContext.getEnvironment()
.getProperty("local.management.port", Integer.class);
assertThat(localServerPort).isNotNull();
assertThat(localManagementPort).isNotNull();
assertThat(localServerPort).isNotEqualTo(localManagementPort);
assertThat(this.applicationContext.getBean(ServerPortConfig.class).getCount())
.isEqualTo(2);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:EndpointWebMvcAutoConfigurationTests.java
示例6: managementSpecificSslUsingDifferentPort
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void managementSpecificSslUsingDifferentPort() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"management.ssl.enabled=true",
"management.ssl.key-store=classpath:test.jks",
"management.ssl.key-password=password");
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertHttpsContent("/controller", ports.get().management, null);
assertHttpsContent("/endpoint", ports.get().management, "endpointoutput");
assertHttpsContent("/error", ports.get().management, startsWith("{"));
ApplicationContext managementContext = this.applicationContext
.getBean(ManagementContextResolver.class).getApplicationContext();
List<?> interceptors = (List<?>) ReflectionTestUtils.getField(
managementContext.getBean(EndpointHandlerMapping.class), "interceptors");
assertThat(interceptors).hasSize(1);
ManagementServerProperties managementServerProperties = this.applicationContext
.getBean(ManagementServerProperties.class);
assertThat(managementServerProperties.getSsl()).isNotNull();
assertThat(managementServerProperties.getSsl().isEnabled()).isTrue();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:EndpointWebMvcAutoConfigurationTests.java
示例7: managementServerCanDisableSslWhenUsingADifferentPort
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void managementServerCanDisableSslWhenUsingADifferentPort() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"server.ssl.enabled=true", "server.ssl.key-store=classpath:test.jks",
"server.ssl.key-password=password", "management.ssl.enabled=false");
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertHttpsContent("/controller", ports.get().server, "controlleroutput");
assertHttpsContent("/endpoint", ports.get().server, null);
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, "endpointoutput");
assertContent("/error", ports.get().management, startsWith("{"));
ApplicationContext managementContext = this.applicationContext
.getBean(ManagementContextResolver.class).getApplicationContext();
List<?> interceptors = (List<?>) ReflectionTestUtils.getField(
managementContext.getBean(EndpointHandlerMapping.class), "interceptors");
assertThat(interceptors).hasSize(1);
ManagementServerProperties managementServerProperties = this.applicationContext
.getBean(ManagementServerProperties.class);
assertThat(managementServerProperties.getSsl()).isNotNull();
assertThat(managementServerProperties.getSsl().isEnabled()).isFalse();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:EndpointWebMvcAutoConfigurationTests.java
示例8: onDifferentPort
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void onDifferentPort() throws Exception {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, "endpointoutput");
assertContent("/error", ports.get().management, startsWith("{"));
ApplicationContext managementContext = this.applicationContext
.getBean(ManagementContextResolver.class).getApplicationContext();
List<?> interceptors = (List<?>) ReflectionTestUtils.getField(
managementContext.getBean(EndpointHandlerMapping.class), "interceptors");
assertEquals(1, interceptors.size());
this.applicationContext.close();
assertAllClosed();
}
示例9: onDifferentPortInServletContainer
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void onDifferentPortInServletContainer() throws Exception {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
ServletContext servletContext = mock(ServletContext.class);
given(servletContext.getInitParameterNames())
.willReturn(new Vector<String>().elements());
given(servletContext.getAttributeNames())
.willReturn(new Vector<String>().elements());
this.applicationContext.setServletContext(servletContext);
this.applicationContext.refresh();
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, null);
this.applicationContext.close();
assertAllClosed();
}
示例10: onRandomPort
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void onRandomPort() throws Exception {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
RandomPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
GrabManagementPort grabManagementPort = new GrabManagementPort(
this.applicationContext);
this.applicationContext.addApplicationListener(grabManagementPort);
this.applicationContext.refresh();
int managementPort = grabManagementPort.getServletContainer().getPort();
assertThat(managementPort, not(equalTo(ports.get().server)));
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertContent("/controller", managementPort, null);
assertContent("/endpoint", managementPort, "endpointoutput");
}
示例11: specificPortsViaProperties
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void specificPortsViaProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"server.port:" + ports.get().server,
"management.port:" + ports.get().management);
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, "endpointoutput");
this.applicationContext.close();
assertAllClosed();
}
示例12: specificPortsViaPropertiesWithClash
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void specificPortsViaPropertiesWithClash() throws Exception {
int managementPort = ports.get().management;
ServerSocket serverSocket = new ServerSocket();
serverSocket.bind(new InetSocketAddress(managementPort));
try {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"server.port:" + ports.get().server,
"management.port:" + ports.get().management);
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class);
this.thrown.expect(EmbeddedServletContainerException.class);
this.applicationContext.refresh();
this.applicationContext.close();
}
finally {
serverSocket.close();
assertAllClosed();
}
}
示例13: portPropertiesOnDifferentPort
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void portPropertiesOnDifferentPort() throws Exception {
new ServerPortInfoApplicationContextInitializer()
.initialize(this.applicationContext);
this.applicationContext.register(RootConfig.class, DifferentPortConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
Integer localServerPort = this.applicationContext.getEnvironment()
.getProperty("local.server.port", Integer.class);
Integer localManagementPort = this.applicationContext.getEnvironment()
.getProperty("local.management.port", Integer.class);
assertThat(localServerPort, notNullValue());
assertThat(localManagementPort, notNullValue());
assertThat(localServerPort, not(equalTo(localManagementPort)));
assertThat(this.applicationContext.getBean(ServerPortConfig.class).getCount(),
equalTo(2));
this.applicationContext.close();
assertAllClosed();
}
示例14: onDifferentPortAndContext
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void onDifferentPortAndContext() throws Exception {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
management.setContextPath("/admin");
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/admin/endpoint", ports.get().management, "endpointoutput");
assertContent("/error", ports.get().management, startsWith("{"));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:EndpointWebMvcAutoConfigurationTests.java
示例15: onDifferentPortAndMainContext
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration; //导入依赖的package包/类
@Test
public void onDifferentPortAndMainContext() throws Exception {
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
management.setContextPath("/admin");
server.setContextPath("/spring");
this.applicationContext.refresh();
assertContent("/spring/controller", ports.get().server, "controlleroutput");
assertContent("/admin/endpoint", ports.get().management, "endpointoutput");
assertContent("/error", ports.get().management, startsWith("{"));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:EndpointWebMvcAutoConfigurationTests.java