Merge branch '2.0.x' into 2.1.x

Closes gh-17078
This commit is contained in:
Andy Wilkinson
2019-06-07 10:50:34 +01:00
2691 changed files with 27746 additions and 46049 deletions

View File

@@ -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) {

View File

@@ -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);
}