Merge branch '2.4.x' into 2.5.x

Closes gh-27473
This commit is contained in:
Andy Wilkinson 2021-07-23 13:06:47 +01:00
commit eaca9c7a83
13 changed files with 39 additions and 24 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
@ -151,7 +152,8 @@ class CloudFoundryWebFluxEndpointIntegrationTests {
return (context) -> {
int port = ((AnnotationConfigReactiveWebServerApplicationContext) context.getSourceApplicationContext())
.getWebServer().getPort();
clientConsumer.accept(WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build());
clientConsumer.accept(WebTestClient.bindToServer().baseUrl("http://localhost:" + port)
.responseTimeout(Duration.ofMinutes(5)).build());
};
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
@ -146,8 +147,8 @@ class CloudFoundryMvcWebEndpointIntegrationTests {
BiConsumer<ApplicationContext, WebTestClient> consumer = (context, client) -> clientConsumer.accept(client);
try (AnnotationConfigServletWebServerApplicationContext context = createApplicationContext(configuration,
CloudFoundryMvcConfiguration.class)) {
consumer.accept(context,
WebTestClient.bindToServer().baseUrl("http://localhost:" + getPort(context)).build());
consumer.accept(context, WebTestClient.bindToServer().baseUrl("http://localhost:" + getPort(context))
.responseTimeout(Duration.ofMinutes(5)).build());
}
}

View File

@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -73,7 +74,7 @@ class MappingsEndpointReactiveDocumentationTests extends AbstractEndpointDocumen
void webTestClient(RestDocumentationContextProvider restDocumentation) {
this.client = WebTestClient.bindToServer()
.filter(documentationConfiguration(restDocumentation).snippets().withDefaults())
.baseUrl("http://localhost:" + this.port).build();
.baseUrl("http://localhost:" + this.port).responseTimeout(Duration.ofMinutes(5)).build();
}
@Test

View File

@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -72,7 +73,7 @@ class MappingsEndpointServletDocumentationTests extends AbstractEndpointDocument
@BeforeEach
void webTestClient(RestDocumentationContextProvider restDocumentation) {
this.client = WebTestClient.bindToServer().filter(documentationConfiguration(restDocumentation))
.baseUrl("http://localhost:" + this.port).build();
.baseUrl("http://localhost:" + this.port).responseTimeout(Duration.ofMinutes(5)).build();
}
@Test

View File

@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.integrationtest;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -63,7 +64,8 @@ class JerseyEndpointIntegrationTests {
int port = context
.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
.getWebServer().getPort();
WebTestClient client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
WebTestClient client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port)
.responseTimeout(Duration.ofMinutes(5)).build();
client.get().uri("/actuator").exchange().expectStatus().isNotFound();
});
}
@ -81,7 +83,8 @@ class JerseyEndpointIntegrationTests {
contextRunner.run((context) -> {
int port = context.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
.getWebServer().getPort();
WebTestClient client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
WebTestClient client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port)
.responseTimeout(Duration.ofMinutes(5)).build();
client.get().uri("/actuator").exchange().expectStatus().isUnauthorized();
});
@ -91,7 +94,8 @@ class JerseyEndpointIntegrationTests {
getContextRunner(userConfigurations).run((context) -> {
int port = context.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
.getWebServer().getPort();
WebTestClient client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
WebTestClient client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port)
.responseTimeout(Duration.ofMinutes(5)).build();
client.get().uri("/actuator").exchange().expectStatus().isOk().expectBody().jsonPath("_links.beans")
.isNotEmpty().jsonPath("_links.restcontroller").doesNotExist().jsonPath("_links.controller")
.doesNotExist();

View File

@ -17,6 +17,7 @@
package org.springframework.boot.actuate.autoconfigure.integrationtest;
import java.io.IOException;
import java.time.Duration;
import java.util.function.Supplier;
import javax.servlet.ServletException;
@ -168,7 +169,7 @@ class WebMvcEndpointExposureIntegrationTests {
ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder()
.codecs((configurer) -> configurer.defaultCodecs().maxInMemorySize(-1)).build();
return WebTestClient.bindToServer().baseUrl("http://localhost:" + port).exchangeStrategies(exchangeStrategies)
.build();
.responseTimeout(Duration.ofMinutes(5)).build();
}
private boolean isExposed(WebTestClient client, HttpMethod method, String path) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.security.servlet;
import java.time.Duration;
import java.util.Base64;
import java.util.function.Supplier;
@ -90,7 +91,8 @@ abstract class AbstractEndpointRequestIntegrationTests {
protected WebTestClient getWebTestClient(AssertableWebApplicationContext context) {
int port = context.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
.getWebServer().getPort();
return WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
return WebTestClient.bindToServer().baseUrl("http://localhost:" + port).responseTimeout(Duration.ofMinutes(5))
.build();
}
String getBasicAuth() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -65,7 +65,7 @@ import static org.mockito.Mockito.verify;
*/
public abstract class AbstractWebEndpointIntegrationTests<T extends ConfigurableApplicationContext & AnnotationConfigRegistry> {
private static final Duration TIMEOUT = Duration.ofMinutes(6);
private static final Duration TIMEOUT = Duration.ofMinutes(5);
private static final String ACTUATOR_MEDIA_TYPE_PATTERN = "application/vnd.test\\+json(;charset=UTF-8)?";

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -97,7 +97,7 @@ class ControllerEndpointHandlerMappingIntegrationTests {
private WebTestClient createWebTestClient(int port) {
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory("http://localhost:" + port);
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
return WebTestClient.bindToServer().uriBuilderFactory(uriBuilderFactory).responseTimeout(Duration.ofMinutes(2))
return WebTestClient.bindToServer().uriBuilderFactory(uriBuilderFactory).responseTimeout(Duration.ofMinutes(5))
.build();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -95,7 +95,7 @@ class ControllerEndpointHandlerMappingIntegrationTests {
private WebTestClient createWebTestClient(int port) {
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory("http://localhost:" + port);
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
return WebTestClient.bindToServer().uriBuilderFactory(uriBuilderFactory).responseTimeout(Duration.ofMinutes(2))
return WebTestClient.bindToServer().uriBuilderFactory(uriBuilderFactory).responseTimeout(Duration.ofMinutes(5))
.build();
}

View File

@ -126,7 +126,7 @@ class WebEndpointTestInvocationContextProvider implements TestTemplateInvocation
static class WebEndpointsInvocationContext
implements TestTemplateInvocationContext, BeforeEachCallback, AfterEachCallback, ParameterResolver {
private static final Duration TIMEOUT = Duration.ofMinutes(6);
private static final Duration TIMEOUT = Duration.ofMinutes(5);
private final String name;

View File

@ -79,7 +79,8 @@ class RSocketWebSocketNettyRouteProviderTests {
}
private WebTestClient createWebTestClient(WebServer server) {
return WebTestClient.bindToServer().baseUrl("http://localhost:" + server.getPort()).build();
return WebTestClient.bindToServer().baseUrl("http://localhost:" + server.getPort())
.responseTimeout(Duration.ofMinutes(5)).build();
}
private RSocketRequester createRSocketRequester(ApplicationContext context, WebServer server) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
package org.springframework.boot.test.context;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
@ -67,8 +69,8 @@ abstract class AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests {
@Test
void runAndTestHttpEndpoint() {
assertThat(this.port).isNotEqualTo(8080).isNotEqualTo(0);
WebTestClient.bindToServer().baseUrl("http://localhost:" + this.port).build().get().uri("/").exchange()
.expectBody(String.class).isEqualTo("Hello World");
WebTestClient.bindToServer().baseUrl("http://localhost:" + this.port).responseTimeout(Duration.ofMinutes(5))
.build().get().uri("/").exchange().expectBody(String.class).isEqualTo("Hello World");
}
@Test