Add @LocalServerPort

Closes gh-5262
This commit is contained in:
Anand Shah
2016-03-01 16:02:41 +00:00
committed by Stephane Nicoll
parent a3a38c6bbc
commit f6a32a1d5a
19 changed files with 134 additions and 22 deletions

View File

@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterContextPathTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
@@ -62,7 +63,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
public class JerseyAutoConfigurationCustomFilterContextPathTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate restTemplate = new TestRestTemplate();

View File

@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterPathTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
@@ -61,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
public class JerseyAutoConfigurationCustomFilterPathTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate restTemplate = new TestRestTemplate();

View File

@@ -30,13 +30,13 @@ import org.glassfish.jersey.server.ResourceConfig;
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.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
@@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
public class JerseyAutoConfigurationCustomObjectMapperProviderTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate restTemplate = new TestRestTemplate();

View File

@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletContextPathTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
@@ -61,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
public class JerseyAutoConfigurationCustomServletContextPathTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate restTemplate = new TestRestTemplate();

View File

@@ -36,6 +36,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
@@ -61,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
public class JerseyAutoConfigurationCustomServletPathTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate restTemplate = new TestRestTemplate();

View File

@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultFilterPathTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
@@ -60,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
public class JerseyAutoConfigurationDefaultFilterPathTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate restTemplate = new TestRestTemplate();

View File

@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultServletPathTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
@@ -60,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
public class JerseyAutoConfigurationDefaultServletPathTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate restTemplate = new TestRestTemplate();

View File

@@ -30,13 +30,13 @@ import org.glassfish.jersey.server.ResourceConfig;
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.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
@@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
public class JerseyAutoConfigurationObjectMapperProviderTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate restTemplate = new TestRestTemplate();

View File

@@ -33,6 +33,7 @@ import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationServ
import org.springframework.boot.autoconfigure.test.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
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.test.IntegrationTest;
import org.springframework.boot.test.OutputCapture;
@@ -62,7 +63,7 @@ public class JerseyAutoConfigurationServletContainerTests {
@ClassRule
public static OutputCapture output = new OutputCapture();
@Value("${local.server.port}")
@LocalServerPort
private int port;
@Test

View File

@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
@@ -60,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@WebAppConfiguration
public class JerseyAutoConfigurationWithoutApplicationPathTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate restTemplate = new TestRestTemplate();

View File

@@ -24,7 +24,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServicesRefreshTokenTests.Application;
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
@@ -32,6 +31,7 @@ import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoCo
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.WebIntegrationTest;
import org.springframework.context.annotation.Configuration;
@@ -71,7 +71,7 @@ public class UserInfoTokenServicesRefreshTokenTests {
@Rule
public ExpectedException expected = ExpectedException.none();
@Value("${local.server.port}")
@LocalServerPort
private int port;
private UserInfoTokenServices services;

View File

@@ -19,9 +19,9 @@ package org.springframework.boot.autoconfigure.web;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.RemappedErrorViewIntegrationTests.TestConfiguration;
import org.springframework.boot.bind.LocalServerPort;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@DirtiesContext
public class RemappedErrorViewIntegrationTests {
@Value("${local.server.port}")
@LocalServerPort
private int port;
private RestTemplate template = new TestRestTemplate();