parent
f6a32a1d5a
commit
2526a54e31
|
|
@ -47,7 +47,7 @@ import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
|||
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.bind.LocalServerPort;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.junit.runner.RunWith;
|
|||
|
||||
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpointServerContextPathIntegrationTests.SpringBootHypermediaApplication;
|
||||
import org.springframework.boot.bind.LocalServerPort;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -36,7 +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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -36,7 +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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ 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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -36,7 +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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -36,7 +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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -35,7 +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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -35,7 +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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ 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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ 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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.OutputCapture;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
|
|
|
|||
|
|
@ -35,7 +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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -31,7 +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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ import org.junit.runner.RunWith;
|
|||
|
||||
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;
|
||||
import org.springframework.boot.context.embedded.ErrorPage;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ that and be sure that it has initialized is to add a `@Bean` of type
|
|||
out of the event when it is published.
|
||||
|
||||
A useful practice for use with `@WebIntegrationTest` is to set `server.port=0`
|
||||
and then inject the actual ('`local`') port as a `@Value`. For example:
|
||||
and then inject the actual port. For example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
|
|
@ -466,7 +466,7 @@ and then inject the actual ('`local`') port as a `@Value`. For example:
|
|||
@Autowired
|
||||
EmbeddedWebApplicationContext server;
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
// ...
|
||||
|
|
@ -476,9 +476,10 @@ and then inject the actual ('`local`') port as a `@Value`. For example:
|
|||
|
||||
[NOTE]
|
||||
====
|
||||
Don't try to inject the port with `@Value` in a regular application. As we just saw, the
|
||||
value is only set once the container has initialized; contrary to a test, application code
|
||||
callbacks are processed early (i.e. before the value is actually available).
|
||||
`@LocalServerPort` is a meta-annotation for `@Value("${local.server.port}")`. Don't try
|
||||
to inject the port in a regular application. As we just saw, the value is only set once
|
||||
the container has initialized; contrary to a test, application code callbacks are
|
||||
processed early (i.e. before the value is actually available).
|
||||
====
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleActuatorLog4J2ApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -43,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleActuatorUiApplicationPortTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 9010;
|
||||
|
||||
@Value("${local.management.port}")
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleActuatorUiApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -50,7 +50,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
|
|||
@Autowired
|
||||
private SecurityProperties security;
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -49,7 +50,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
|
|||
@Autowired
|
||||
private SecurityProperties security;
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 9010;
|
||||
|
||||
@Value("${local.management.port}")
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@ActiveProfiles("unsecure-management")
|
||||
public class InsecureManagementSampleActuatorApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class InsecureSampleActuatorApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -44,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class ManagementAddressActuatorApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 9010;
|
||||
|
||||
@Value("${local.management.port}")
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class ManagementPathSampleActuatorApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -49,7 +50,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
|||
@Autowired
|
||||
private SecurityProperties security;
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 9010;
|
||||
|
||||
@Value("${local.management.port}")
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -48,7 +49,7 @@ public class ManagementPortSampleActuatorApplicationTests {
|
|||
@Autowired
|
||||
private SecurityProperties security;
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 9010;
|
||||
|
||||
@Value("${local.management.port}")
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -48,7 +48,7 @@ public class NoManagementSampleActuatorApplicationTests {
|
|||
@Autowired
|
||||
private SecurityProperties security;
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package sample.actuator;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class NonSensitiveHealthTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -56,7 +56,7 @@ public class SampleActuatorApplicationTests {
|
|||
@Autowired
|
||||
private SecurityProperties security;
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class ServletPathInsecureSampleActuatorApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class ServletPathSampleActuatorApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -48,7 +48,7 @@ public class ShutdownSampleActuatorApplicationTests {
|
|||
@Autowired
|
||||
private SecurityProperties security;
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
|
@ -52,7 +53,7 @@ public class SampleAtmosphereApplicationTests {
|
|||
|
||||
private static Log logger = LogFactory.getLog(SampleAtmosphereApplicationTests.class);
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 1234;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.net.URI;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@WebIntegrationTest(randomPort = true)
|
||||
public class SampleHateoasApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.Arrays;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@WebIntegrationTest(value = { "management.context-path=" }, randomPort = true)
|
||||
public class SampleHypermediaUiApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.Arrays;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@WebIntegrationTest(randomPort = true)
|
||||
public class SampleHypermediaApplicationHomePageTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package sample.jersey;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@WebIntegrationTest(randomPort = true)
|
||||
public class SampleJerseyApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
private RestTemplate restTemplate = new TestRestTemplate();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package sample.jersey1;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@WebIntegrationTest(randomPort = true)
|
||||
public class SampleJersey1ApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.http.ssl.SSLContextBuilder;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleJettySslApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.zip.GZIPInputStream;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleJettyApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.http.ssl.SSLContextBuilder;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleJetty8SslApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.zip.GZIPInputStream;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleJetty8ApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.zip.GZIPInputStream;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleJetty93ApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleServletApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package sample.testng;
|
|||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleTestNGApplicationTests extends AbstractTestNGSpringContextTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package sample.tomcat.jsp;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebJspApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
|
@ -56,7 +56,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleTomcatTwoConnectorsApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private String port;
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@ import org.apache.http.impl.client.HttpClients;
|
|||
import org.apache.http.ssl.SSLContextBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import sample.tomcat.ssl.SampleTomcatSslApplication;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -43,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleTomcatSslApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import sample.tomcat.NonAutoConfigurationSampleTomcatApplicationTests.NonAutoCon
|
|||
import sample.tomcat.service.HelloWorldService;
|
||||
import sample.tomcat.web.SampleController;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||
|
|
@ -30,6 +29,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.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class NonAutoConfigurationSampleTomcatApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Configuration
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.zip.GZIPInputStream;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleTomcatApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package sample.tomcat7.jsp;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebJspApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package sample.traditional;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleTraditionalApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.http.ssl.SSLContextBuilder;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleUndertowSslApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.zip.GZIPInputStream;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleUndertowApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Arrays;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebFreeMarkerApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.net.URI;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleGroovyTemplateApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package sample.jsp;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebJspApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.regex.Pattern;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleMethodSecurityApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Arrays;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebMustacheApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,9 +22,8 @@ import java.util.regex.Pattern;
|
|||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import sample.web.secure.custom.SampleWebSecureCustomApplication;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -52,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebSecureCustomApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.net.URI;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleGithubApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.regex.Pattern;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebSecureCustomApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.regex.Pattern;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleSecureApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@ package sample.web.staticcontent;
|
|||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import sample.web.staticcontent.SampleWebStaticApplication;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -43,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebStaticApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 0;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -20,9 +20,8 @@ import java.net.URI;
|
|||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import sample.web.ui.SampleWebUiApplication;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -46,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebUiApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Arrays;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@DirtiesContext
|
||||
public class SampleWebVelocityApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
|
@ -52,7 +53,7 @@ public class SampleWebSocketsApplicationTests {
|
|||
|
||||
private static Log logger = LogFactory.getLog(SampleWebSocketsApplicationTests.class);
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 1234;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
|
@ -52,7 +53,7 @@ public class SampleWebSocketsApplicationTests {
|
|||
|
||||
private static Log logger = LogFactory.getLog(SampleWebSocketsApplicationTests.class);
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 1234;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
|
@ -53,7 +54,7 @@ public class SampleWebSocketsApplicationTests {
|
|||
|
||||
private static Log logger = LogFactory.getLog(SampleWebSocketsApplicationTests.class);
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int port = 1234;
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.ws;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
|
@ -25,7 +26,7 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.OutputCapture;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
|
|
@ -44,7 +45,7 @@ public class SampleWsApplicationTests {
|
|||
|
||||
private WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
|
||||
|
||||
@Value("${local.server.port}")
|
||||
@LocalServerPort
|
||||
private int serverPort;
|
||||
|
||||
@Before
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.BootstrapWith;
|
||||
|
||||
|
|
@ -56,8 +57,8 @@ public @interface WebIntegrationTest {
|
|||
/**
|
||||
* Convenience attribute that can be used to set a {@code server.port=0}
|
||||
* {@link Environment} property which usually triggers listening on a random port.
|
||||
* Often used in conjunction with a <code>@Value("${local.server.port}")</code>
|
||||
* injected field on the test.
|
||||
* Often used in conjunction with a {@link LocalServerPort} injected field on the
|
||||
* test.
|
||||
* @return if a random port should be used
|
||||
*/
|
||||
boolean randomPort() default false;
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ import org.junit.runner.RunWith;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.tomcat.TomcatEmbeddedServletContainerFactory;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationIntegrationTestTests.Config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ import org.junit.runner.RunWith;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.tomcat.TomcatEmbeddedServletContainerFactory;
|
||||
import org.springframework.boot.context.web.LocalServerPort;
|
||||
import org.springframework.boot.test.SpringApplicationWebIntegrationTestTests.Config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
|
|||
|
|
@ -14,20 +14,27 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.bind;
|
||||
package org.springframework.boot.context.web;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
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>
|
||||
* Annotation at the field or method/constructor parameter level
|
||||
* that injects the HTTP port that got allocated at runtime.
|
||||
* <p>
|
||||
* Convenient meta-annotation replacing {@code @LocalServerPort}.
|
||||
*
|
||||
* @author Anand Shah
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@Value("${local.server.port}")
|
||||
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LocalServerPort {
|
||||
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,4 +2,3 @@ foo=spam
|
|||
bar=some
|
||||
spam=bucket
|
||||
the-name=name
|
||||
local.server.port=8081
|
||||
|
|
|
|||
Loading…
Reference in New Issue