Merge branch '2.0.x' into 2.1.x
Closes gh-17078
This commit is contained in:
@@ -60,12 +60,10 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
@Import({ ServletWebServerFactoryAutoConfiguration.class, DispatcherServletAutoConfiguration.class,
|
||||
WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class })
|
||||
@ComponentScan(
|
||||
basePackageClasses = { SampleController.class, HelloWorldService.class })
|
||||
@ComponentScan(basePackageClasses = { SampleController.class, HelloWorldService.class })
|
||||
public static class NonAutoConfigurationSampleTomcatApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -70,23 +70,18 @@ public class SampleTomcatApplicationTests {
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept-Encoding", "gzip");
|
||||
HttpEntity<?> requestEntity = new HttpEntity<>(requestHeaders);
|
||||
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET,
|
||||
requestEntity, byte[].class);
|
||||
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
try (GZIPInputStream inflater = new GZIPInputStream(
|
||||
new ByteArrayInputStream(entity.getBody()))) {
|
||||
assertThat(StreamUtils.copyToString(inflater, StandardCharsets.UTF_8))
|
||||
.isEqualTo("Hello World");
|
||||
try (GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()))) {
|
||||
assertThat(StreamUtils.copyToString(inflater, StandardCharsets.UTF_8)).isEqualTo("Hello World");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeout() {
|
||||
ServletWebServerApplicationContext context = (ServletWebServerApplicationContext) this.applicationContext;
|
||||
TomcatWebServer embeddedServletContainer = (TomcatWebServer) context
|
||||
.getWebServer();
|
||||
ProtocolHandler protocolHandler = embeddedServletContainer.getTomcat()
|
||||
.getConnector().getProtocolHandler();
|
||||
TomcatWebServer embeddedServletContainer = (TomcatWebServer) context.getWebServer();
|
||||
ProtocolHandler protocolHandler = embeddedServletContainer.getTomcat().getConnector().getProtocolHandler();
|
||||
int timeout = ((AbstractProtocol<?>) protocolHandler).getConnectionTimeout();
|
||||
assertThat(timeout).isEqualTo(5000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user