Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
f6a32a1d
Commit
f6a32a1d
authored
Mar 01, 2016
by
Anand Shah
Committed by
Stephane Nicoll
Mar 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `@LocalServerPort`
Closes gh-5262
parent
a3a38c6b
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
134 additions
and
22 deletions
+134
-22
EndpointMvcIntegrationTests.java
...ot/actuate/autoconfigure/EndpointMvcIntegrationTests.java
+2
-2
HalBrowserMvcEndpointServerContextPathIntegrationTests.java
...lBrowserMvcEndpointServerContextPathIntegrationTests.java
+2
-2
JerseyAutoConfigurationCustomFilterContextPathTests.java
.../JerseyAutoConfigurationCustomFilterContextPathTests.java
+2
-1
JerseyAutoConfigurationCustomFilterPathTests.java
.../jersey/JerseyAutoConfigurationCustomFilterPathTests.java
+2
-1
JerseyAutoConfigurationCustomObjectMapperProviderTests.java
...rseyAutoConfigurationCustomObjectMapperProviderTests.java
+2
-2
JerseyAutoConfigurationCustomServletContextPathTests.java
...JerseyAutoConfigurationCustomServletContextPathTests.java
+2
-1
JerseyAutoConfigurationCustomServletPathTests.java
...jersey/JerseyAutoConfigurationCustomServletPathTests.java
+2
-1
JerseyAutoConfigurationDefaultFilterPathTests.java
...jersey/JerseyAutoConfigurationDefaultFilterPathTests.java
+2
-1
JerseyAutoConfigurationDefaultServletPathTests.java
...ersey/JerseyAutoConfigurationDefaultServletPathTests.java
+2
-1
JerseyAutoConfigurationObjectMapperProviderTests.java
...sey/JerseyAutoConfigurationObjectMapperProviderTests.java
+2
-2
JerseyAutoConfigurationServletContainerTests.java
.../jersey/JerseyAutoConfigurationServletContainerTests.java
+2
-1
JerseyAutoConfigurationWithoutApplicationPathTests.java
...y/JerseyAutoConfigurationWithoutApplicationPathTests.java
+2
-1
UserInfoTokenServicesRefreshTokenTests.java
...uth2/resource/UserInfoTokenServicesRefreshTokenTests.java
+2
-2
RemappedErrorViewIntegrationTests.java
.../autoconfigure/web/RemappedErrorViewIntegrationTests.java
+2
-2
SpringApplicationIntegrationTestTests.java
...work/boot/test/SpringApplicationIntegrationTestTests.java
+2
-1
SpringApplicationWebIntegrationTestTests.java
...k/boot/test/SpringApplicationWebIntegrationTestTests.java
+2
-1
LocalServerPort.java
...n/java/org/springframework/boot/bind/LocalServerPort.java
+34
-0
LocalServerPortTests.java
...a/org/springframework/boot/bind/LocalServerPortTests.java
+67
-0
some.properties
spring-boot/src/test/resources/some.properties
+1
-0
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java
View file @
f6a32a1d
...
@@ -34,7 +34,6 @@ import org.junit.Test;
...
@@ -34,7 +34,6 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.actuate.autoconfigure.EndpointMvcIntegrationTests.Application
;
import
org.springframework.boot.actuate.autoconfigure.EndpointMvcIntegrationTests.Application
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping
;
import
org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping
;
...
@@ -48,6 +47,7 @@ import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
...
@@ -48,6 +47,7 @@ import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
import
org.springframework.boot.autoconfigure.web.HttpMessageConverters
;
import
org.springframework.boot.autoconfigure.web.HttpMessageConverters
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -78,7 +78,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -78,7 +78,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@DirtiesContext
@DirtiesContext
public
class
EndpointMvcIntegrationTests
{
public
class
EndpointMvcIntegrationTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
@Autowired
@Autowired
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerContextPathIntegrationTests.java
View file @
f6a32a1d
...
@@ -21,9 +21,9 @@ import java.util.Arrays;
...
@@ -21,9 +21,9 @@ import java.util.Arrays;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication
;
import
org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication
;
import
org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpointServerContextPathIntegrationTests.SpringBootHypermediaApplication
;
import
org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpointServerContextPathIntegrationTests.SpringBootHypermediaApplication
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -57,7 +57,7 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
...
@@ -57,7 +57,7 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
@DirtiesContext
@DirtiesContext
public
class
HalBrowserMvcEndpointServerContextPathIntegrationTests
{
public
class
HalBrowserMvcEndpointServerContextPathIntegrationTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
@Test
@Test
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationCustomFilterContextPathTests.java
View file @
f6a32a1d
...
@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterContextPathTests.Application
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterContextPathTests.Application
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -62,7 +63,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -62,7 +63,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
@WebAppConfiguration
public
class
JerseyAutoConfigurationCustomFilterContextPathTests
{
public
class
JerseyAutoConfigurationCustomFilterContextPathTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationCustomFilterPathTests.java
View file @
f6a32a1d
...
@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterPathTests.Application
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterPathTests.Application
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -61,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -61,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
@WebAppConfiguration
public
class
JerseyAutoConfigurationCustomFilterPathTests
{
public
class
JerseyAutoConfigurationCustomFilterPathTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationCustomObjectMapperProviderTests.java
View file @
f6a32a1d
...
@@ -30,13 +30,13 @@ import org.glassfish.jersey.server.ResourceConfig;
...
@@ -30,13 +30,13 @@ import org.glassfish.jersey.server.ResourceConfig;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
@WebAppConfiguration
public
class
JerseyAutoConfigurationCustomObjectMapperProviderTests
{
public
class
JerseyAutoConfigurationCustomObjectMapperProviderTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationCustomServletContextPathTests.java
View file @
f6a32a1d
...
@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletContextPathTests.Application
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletContextPathTests.Application
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -61,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -61,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
@WebAppConfiguration
public
class
JerseyAutoConfigurationCustomServletContextPathTests
{
public
class
JerseyAutoConfigurationCustomServletContextPathTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationCustomServletPathTests.java
View file @
f6a32a1d
...
@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -61,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -61,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
@WebAppConfiguration
public
class
JerseyAutoConfigurationCustomServletPathTests
{
public
class
JerseyAutoConfigurationCustomServletPathTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationDefaultFilterPathTests.java
View file @
f6a32a1d
...
@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultFilterPathTests.Application
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultFilterPathTests.Application
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -60,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -60,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
@WebAppConfiguration
public
class
JerseyAutoConfigurationDefaultFilterPathTests
{
public
class
JerseyAutoConfigurationDefaultFilterPathTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationDefaultServletPathTests.java
View file @
f6a32a1d
...
@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultServletPathTests.Application
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultServletPathTests.Application
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -60,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -60,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
@WebAppConfiguration
public
class
JerseyAutoConfigurationDefaultServletPathTests
{
public
class
JerseyAutoConfigurationDefaultServletPathTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationObjectMapperProviderTests.java
View file @
f6a32a1d
...
@@ -30,13 +30,13 @@ import org.glassfish.jersey.server.ResourceConfig;
...
@@ -30,13 +30,13 @@ import org.glassfish.jersey.server.ResourceConfig;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
@WebAppConfiguration
public
class
JerseyAutoConfigurationObjectMapperProviderTests
{
public
class
JerseyAutoConfigurationObjectMapperProviderTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationServletContainerTests.java
View file @
f6a32a1d
...
@@ -33,6 +33,7 @@ import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationServ
...
@@ -33,6 +33,7 @@ import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationServ
import
org.springframework.boot.autoconfigure.test.ImportAutoConfiguration
;
import
org.springframework.boot.autoconfigure.test.ImportAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.boot.test.OutputCapture
;
...
@@ -62,7 +63,7 @@ public class JerseyAutoConfigurationServletContainerTests {
...
@@ -62,7 +63,7 @@ public class JerseyAutoConfigurationServletContainerTests {
@ClassRule
@ClassRule
public
static
OutputCapture
output
=
new
OutputCapture
();
public
static
OutputCapture
output
=
new
OutputCapture
();
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
@Test
@Test
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfigurationWithoutApplicationPathTests.java
View file @
f6a32a1d
...
@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application
;
import
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.TestRestTemplate
;
...
@@ -60,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -60,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
@WebAppConfiguration
public
class
JerseyAutoConfigurationWithoutApplicationPathTests
{
public
class
JerseyAutoConfigurationWithoutApplicationPathTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
private
RestTemplate
restTemplate
=
new
TestRestTemplate
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServicesRefreshTokenTests.java
View file @
f6a32a1d
...
@@ -24,7 +24,6 @@ import org.junit.Test;
...
@@ -24,7 +24,6 @@ import org.junit.Test;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServicesRefreshTokenTests.Application
;
import
org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServicesRefreshTokenTests.Application
;
import
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
;
...
@@ -32,6 +31,7 @@ import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoCo
...
@@ -32,6 +31,7 @@ import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoCo
import
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.WebIntegrationTest
;
import
org.springframework.boot.test.WebIntegrationTest
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -71,7 +71,7 @@ public class UserInfoTokenServicesRefreshTokenTests {
...
@@ -71,7 +71,7 @@ public class UserInfoTokenServicesRefreshTokenTests {
@Rule
@Rule
public
ExpectedException
expected
=
ExpectedException
.
none
();
public
ExpectedException
expected
=
ExpectedException
.
none
();
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
UserInfoTokenServices
services
;
private
UserInfoTokenServices
services
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/RemappedErrorViewIntegrationTests.java
View file @
f6a32a1d
...
@@ -19,9 +19,9 @@ package org.springframework.boot.autoconfigure.web;
...
@@ -19,9 +19,9 @@ package org.springframework.boot.autoconfigure.web;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.RemappedErrorViewIntegrationTests.TestConfiguration
;
import
org.springframework.boot.autoconfigure.web.RemappedErrorViewIntegrationTests.TestConfiguration
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
;
...
@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@DirtiesContext
@DirtiesContext
public
class
RemappedErrorViewIntegrationTests
{
public
class
RemappedErrorViewIntegrationTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
private
RestTemplate
template
=
new
TestRestTemplate
();
private
RestTemplate
template
=
new
TestRestTemplate
();
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/SpringApplicationIntegrationTestTests.java
View file @
f6a32a1d
...
@@ -23,6 +23,7 @@ import org.junit.runner.RunWith;
...
@@ -23,6 +23,7 @@ import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.test.SpringApplicationIntegrationTestTests.Config
;
import
org.springframework.boot.test.SpringApplicationIntegrationTestTests.Config
;
...
@@ -54,7 +55,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -54,7 +55,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@IntegrationTest
({
"server.port=0"
,
"value=123"
})
@IntegrationTest
({
"server.port=0"
,
"value=123"
})
public
class
SpringApplicationIntegrationTestTests
{
public
class
SpringApplicationIntegrationTestTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
=
0
;
private
int
port
=
0
;
@Value
(
"${value}"
)
@Value
(
"${value}"
)
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/SpringApplicationWebIntegrationTestTests.java
View file @
f6a32a1d
...
@@ -23,6 +23,7 @@ import org.junit.runner.RunWith;
...
@@ -23,6 +23,7 @@ import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.bind.LocalServerPort
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.test.SpringApplicationWebIntegrationTestTests.Config
;
import
org.springframework.boot.test.SpringApplicationWebIntegrationTestTests.Config
;
...
@@ -52,7 +53,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -52,7 +53,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebIntegrationTest
({
"server.port=0"
,
"value=123"
})
@WebIntegrationTest
({
"server.port=0"
,
"value=123"
})
public
class
SpringApplicationWebIntegrationTestTests
{
public
class
SpringApplicationWebIntegrationTestTests
{
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
=
0
;
private
int
port
=
0
;
@Value
(
"${value}"
)
@Value
(
"${value}"
)
...
...
spring-boot/src/main/java/org/springframework/boot/bind/LocalServerPort.java
0 → 100644
View file @
f6a32a1d
/*
* Copyright 2012-2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
bind
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
org.springframework.beans.factory.annotation.Value
;
/**
* Meta annotation for replacement of property local.server.port. Can be used instead of
* <code>@Value("${local.server.port}")</code>
*
* @author Anand Shah
*/
@Value
(
"${local.server.port}"
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
LocalServerPort
{
}
spring-boot/src/test/java/org/springframework/boot/bind/LocalServerPortTests.java
0 → 100644
View file @
f6a32a1d
/*
* Copyright 2012-2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
bind
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.bind.PropertySourcesBindingTests.TestConfig
;
import
org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests for {@link LocalServerPort} annotation based injection of local.server.port
* property.
*
* @author Anand Shah
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
TestConfig
.
class
)
public
class
LocalServerPortTests
{
private
ConfigurableApplicationContext
context
;
@Value
(
"${local.server.port:}"
)
private
String
localServerPortFromValue
;
@LocalServerPort
private
String
localServerPortFromAnnotation
;
@Test
public
void
testLocalServerPortAnnotation
()
{
SpringApplication
application
=
new
SpringApplication
(
LocalServerPortTests
.
class
);
application
.
setWebEnvironment
(
true
);
this
.
context
=
application
.
run
();
assertThat
(
this
.
localServerPortFromAnnotation
).
isNotNull
().
isNotEmpty
()
.
isEqualTo
(
this
.
localServerPortFromValue
).
isEqualTo
(
this
.
context
.
getEnvironment
().
getProperty
(
"local.server.port"
));
}
@Bean
public
JettyEmbeddedServletContainerFactory
container
()
{
return
new
JettyEmbeddedServletContainerFactory
(
8081
);
}
}
spring-boot/src/test/resources/some.properties
View file @
f6a32a1d
...
@@ -2,3 +2,4 @@ foo=spam
...
@@ -2,3 +2,4 @@ foo=spam
bar
=
some
bar
=
some
spam
=
bucket
spam
=
bucket
the-name
=
name
the-name
=
name
local.server.port
=
8081
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment