Merge branch '2.5.x'

Closes gh-27474
pull/27482/head
Andy Wilkinson 3 years ago
commit 355226c21e

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

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

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

@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -72,7 +73,7 @@ class MappingsEndpointServletDocumentationTests extends AbstractEndpointDocument
@BeforeEach @BeforeEach
void webTestClient(RestDocumentationContextProvider restDocumentation) { void webTestClient(RestDocumentationContextProvider restDocumentation) {
this.client = WebTestClient.bindToServer().filter(documentationConfiguration(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 @Test

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

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

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

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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> { 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)?"; private static final String ACTUATOR_MEDIA_TYPE_PATTERN = "application/vnd.test\\+json(;charset=UTF-8)?";

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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) { private WebTestClient createWebTestClient(int port) {
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory("http://localhost:" + port); DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory("http://localhost:" + port);
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE); uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
return WebTestClient.bindToServer().uriBuilderFactory(uriBuilderFactory).responseTimeout(Duration.ofMinutes(2)) return WebTestClient.bindToServer().uriBuilderFactory(uriBuilderFactory).responseTimeout(Duration.ofMinutes(5))
.build(); .build();
} }

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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) { private WebTestClient createWebTestClient(int port) {
DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory("http://localhost:" + port); DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory("http://localhost:" + port);
uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE); uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
return WebTestClient.bindToServer().uriBuilderFactory(uriBuilderFactory).responseTimeout(Duration.ofMinutes(2)) return WebTestClient.bindToServer().uriBuilderFactory(uriBuilderFactory).responseTimeout(Duration.ofMinutes(5))
.build(); .build();
} }

@ -126,7 +126,7 @@ class WebEndpointTestInvocationContextProvider implements TestTemplateInvocation
static class WebEndpointsInvocationContext static class WebEndpointsInvocationContext
implements TestTemplateInvocationContext, BeforeEachCallback, AfterEachCallback, ParameterResolver { 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; private final String name;

@ -79,7 +79,8 @@ class RSocketWebSocketNettyRouteProviderTests {
} }
private WebTestClient createWebTestClient(WebServer server) { 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) { private RSocketRequester createRSocketRequester(ApplicationContext context, WebServer server) {

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

Loading…
Cancel
Save