Skip to content

Commit b871a1e

Browse files
committed
Merge branch '2.7.x'
2 parents 8d18e5f + 48f8021 commit b871a1e

File tree

57 files changed

+431
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+431
-95
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/LocalManagementPort.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,14 +28,16 @@
2828
* Annotation at the field or method/constructor parameter level that injects the HTTP
2929
* management port that got allocated at runtime. Provides a convenient alternative for
3030
* <code>&#064;Value(&quot;${local.management.port}&quot;)</code>.
31-
*
31+
* @deprecated since 2.7.0 for removal in 2.9.0 in favor of
32+
* {@code org.springframework.boot.test.web.server.LocalManagementPort}
3233
* @author Stephane Nicoll
3334
* @since 2.0.0
3435
*/
3536
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
3637
@Retention(RetentionPolicy.RUNTIME)
3738
@Documented
3839
@Value("${local.management.port}")
40+
@Deprecated
3941
public @interface LocalManagementPort {
4042

4143
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointReactiveDocumentationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@
3131
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlersMappingDescriptionProvider;
3232
import org.springframework.boot.test.context.SpringBootTest;
3333
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
34+
import org.springframework.boot.test.web.server.LocalServerPort;
3435
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
35-
import org.springframework.boot.web.server.LocalServerPort;
3636
import org.springframework.context.ConfigurableApplicationContext;
3737
import org.springframework.context.annotation.Bean;
3838
import org.springframework.context.annotation.Configuration;

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MappingsEndpointServletDocumentationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,8 +33,8 @@
3333
import org.springframework.boot.actuate.web.mappings.servlet.ServletsMappingDescriptionProvider;
3434
import org.springframework.boot.test.context.SpringBootTest;
3535
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
36+
import org.springframework.boot.test.web.server.LocalServerPort;
3637
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
37-
import org.springframework.boot.web.server.LocalServerPort;
3838
import org.springframework.context.ConfigurableApplicationContext;
3939
import org.springframework.context.annotation.Bean;
4040
import org.springframework.context.annotation.Configuration;

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.springframework.boot.builder.SpringApplicationBuilder;
2727
import org.springframework.boot.test.context.SpringBootTest;
2828
import org.springframework.boot.test.web.client.TestRestTemplate;
29-
import org.springframework.boot.web.server.LocalServerPort;
29+
import org.springframework.boot.test.web.server.LocalServerPort;
3030
import org.springframework.context.annotation.Configuration;
3131
import org.springframework.context.annotation.Import;
3232
import org.springframework.http.MediaType;

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/RemappedErrorViewIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,10 +27,10 @@
2727
import org.springframework.boot.test.context.SpringBootTest;
2828
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2929
import org.springframework.boot.test.web.client.TestRestTemplate;
30+
import org.springframework.boot.test.web.server.LocalServerPort;
3031
import org.springframework.boot.web.server.ErrorPage;
3132
import org.springframework.boot.web.server.ErrorPageRegistrar;
3233
import org.springframework.boot.web.server.ErrorPageRegistry;
33-
import org.springframework.boot.web.server.LocalServerPort;
3434
import org.springframework.context.annotation.Configuration;
3535
import org.springframework.context.annotation.Import;
3636
import org.springframework.stereotype.Controller;

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
4040
import org.springframework.boot.context.properties.EnableConfigurationProperties;
4141
import org.springframework.boot.test.util.TestPropertyValues;
42-
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
4342
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
4443
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
4544
import org.springframework.context.annotation.Bean;
@@ -147,7 +146,6 @@ private List<MessageConverter> getDefaultConverters() {
147146
private Object performStompSubscription(String topic) throws Throwable {
148147
TestPropertyValues.of("server.port:0", "spring.jackson.serialization.indent-output:true").applyTo(this.context);
149148
this.context.register(WebSocketMessagingConfiguration.class);
150-
new ServerPortInfoApplicationContextInitializer().initialize(this.context);
151149
this.context.refresh();
152150
WebSocketStompClient stompClient = new WebSocketStompClient(this.sockJsClient);
153151
final AtomicReference<Throwable> failure = new AtomicReference<>();
@@ -194,8 +192,7 @@ public void handleTransportError(StompSession session, Throwable exception) {
194192
};
195193

196194
stompClient.setMessageConverter(new SimpleMessageConverter());
197-
stompClient.connect("ws://localhost:{port}/messaging", handler,
198-
this.context.getEnvironment().getProperty("local.server.port"));
195+
stompClient.connect("ws://localhost:{port}/messaging", handler, this.context.getWebServer().getPort());
199196

200197
if (!latch.await(30, TimeUnit.SECONDS)) {
201198
if (failure.get() != null) {

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
2424
import org.springframework.boot.test.context.SpringBootTest;
2525
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
26-
import org.springframework.boot.web.server.LocalServerPort;
26+
import org.springframework.boot.test.web.server.LocalServerPort;
2727

2828
import static io.restassured.RestAssured.given;
2929
import static org.hamcrest.Matchers.is;

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/webserver/discoverport/MyWebIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
1818

1919
import org.springframework.boot.test.context.SpringBootTest;
2020
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
21-
import org.springframework.boot.web.server.LocalServerPort;
21+
import org.springframework.boot.test.web.server.LocalServerPort;
2222

2323
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
2424
public class MyWebIntegrationTests {

spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired
2424
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs
2525
import org.springframework.boot.test.context.SpringBootTest
2626
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment
27-
import org.springframework.boot.web.server.LocalServerPort
27+
import org.springframework.boot.test.web.server.LocalServerPort
2828
import org.springframework.restdocs.restassured.RestAssuredRestDocumentation
2929

3030
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -41,4 +41,4 @@ class MyUserDocumentationTests {
4141
.statusCode(Matchers.`is`(200))
4242
}
4343

44-
}
44+
}

spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/discoverport/MyWebIntegrationTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package org.springframework.boot.docs.howto.webserver.discoverport
1818

1919
import org.springframework.boot.test.context.SpringBootTest
2020
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment
21-
import org.springframework.boot.web.server.LocalServerPort
21+
import org.springframework.boot.test.web.server.LocalServerPort
2222

2323
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
2424
class MyWebIntegrationTests {

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import org.springframework.boot.test.context.SpringBootTest;
2727
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2828
import org.springframework.boot.test.context.TestConfiguration;
29+
import org.springframework.boot.test.web.server.LocalServerPort;
2930
import org.springframework.boot.testsupport.BuildOutput;
30-
import org.springframework.boot.web.server.LocalServerPort;
3131
import org.springframework.context.annotation.Bean;
3232
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
3333
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler;

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import org.springframework.beans.factory.annotation.Autowired;
2626
import org.springframework.boot.test.context.SpringBootTest;
2727
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
28+
import org.springframework.boot.test.web.server.LocalServerPort;
2829
import org.springframework.boot.testsupport.BuildOutput;
29-
import org.springframework.boot.web.server.LocalServerPort;
3030
import org.springframework.util.FileSystemUtils;
3131

3232
import static io.restassured.RestAssured.given;

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,8 +29,8 @@
2929
import org.springframework.boot.SpringApplication;
3030
import org.springframework.boot.SpringBootConfiguration;
3131
import org.springframework.boot.WebApplicationType;
32+
import org.springframework.boot.test.web.server.LocalServerPort;
3233
import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
33-
import org.springframework.boot.web.server.LocalServerPort;
3434
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
3535
import org.springframework.context.ApplicationContext;
3636
import org.springframework.context.annotation.Configuration;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.test.rsocket.server;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import org.springframework.beans.factory.annotation.Value;
26+
27+
/**
28+
* Annotation at the field or method/constructor parameter level that injects the RSocket
29+
* port that was allocated at runtime. Provides a convenient alternative for
30+
* <code>&#064;Value(&quot;${local.rsocket.server.port}&quot;)</code>.
31+
*
32+
* @author Verónica Vásquez
33+
* @author Eddú Meléndez
34+
* @since 2.7.0
35+
*/
36+
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
37+
@Retention(RetentionPolicy.RUNTIME)
38+
@Documented
39+
@Value("${local.rsocket.server.port}")
40+
public @interface LocalRSocketServerPort {
41+
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* RSocket server test utilities and support classes.
19+
*/
20+
package org.springframework.boot.test.rsocket.server;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.test.web.server;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import org.springframework.beans.factory.annotation.Value;
26+
27+
/**
28+
* Annotation at the field or method/constructor parameter level that injects the HTTP
29+
* management port that was allocated at runtime. Provides a convenient alternative for
30+
* <code>&#064;Value(&quot;${local.management.port}&quot;)</code>.
31+
*
32+
* @author Stephane Nicoll
33+
* @since 2.7.0
34+
*/
35+
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
36+
@Retention(RetentionPolicy.RUNTIME)
37+
@Documented
38+
@Value("${local.management.port}")
39+
public @interface LocalManagementPort {
40+
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.test.web.server;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import org.springframework.beans.factory.annotation.Value;
26+
27+
/**
28+
* Annotation at the field or method/constructor parameter level that injects the HTTP
29+
* server port that was allocated at runtime. Provides a convenient alternative for
30+
* <code>&#064;Value(&quot;${local.server.port}&quot;)</code>.
31+
*
32+
* @author Anand Shah
33+
* @author Stephane Nicoll
34+
* @since 2.7.0
35+
*/
36+
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
37+
@Retention(RetentionPolicy.RUNTIME)
38+
@Documented
39+
@Value("${local.server.port}")
40+
public @interface LocalServerPort {
41+
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Web server test utilities and support classes.
19+
*/
20+
package org.springframework.boot.test.web.server;

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,10 +24,10 @@
2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.beans.factory.annotation.Value;
2626
import org.springframework.boot.test.web.client.TestRestTemplate;
27+
import org.springframework.boot.test.web.server.LocalServerPort;
2728
import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory;
2829
import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
2930
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
30-
import org.springframework.boot.web.server.LocalServerPort;
3131
import org.springframework.context.ApplicationContext;
3232
import org.springframework.context.annotation.Bean;
3333
import org.springframework.context.annotation.Configuration;

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/AbstractSpringBootTestWebServerWebEnvironmentTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.beans.factory.annotation.Value;
2424
import org.springframework.boot.test.web.client.TestRestTemplate;
25+
import org.springframework.boot.test.web.server.LocalServerPort;
2526
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
26-
import org.springframework.boot.web.server.LocalServerPort;
2727
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
2828
import org.springframework.context.annotation.Bean;
2929
import org.springframework.context.annotation.Configuration;

0 commit comments

Comments
 (0)