Commit f134e960 authored by Dave Syer's avatar Dave Syer

Convert Actuator sample to dynamic ports

parent 559009b8
......@@ -53,7 +53,9 @@ import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoCo
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationListener;
......@@ -195,6 +197,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
}
try {
childContext.refresh();
registerContainer(this.applicationContext,
childContext.getEmbeddedServletContainer());
}
catch (RuntimeException e) {
// No support currently for deploying a war with management.port=<different>,
......@@ -207,6 +211,16 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
throw e;
}
}
};
private void registerContainer(ApplicationContext applicationContext,
EmbeddedServletContainer embeddedServletContainer) {
if (applicationContext instanceof EmbeddedWebApplicationContext) {
((EmbeddedWebApplicationContext) applicationContext)
.getEmbeddedServletContainers().put("management",
embeddedServletContainer);
// Maybe unregister it when it shuts down?
}
}
protected static enum ManagementServerPort {
......
......@@ -126,4 +126,5 @@ public class ManagementServerProperties implements SecurityPrequisite {
}
return null;
}
}
logging.file: /tmp/logs/app.log
management.port: 8080
management.address: 127.0.0.1
endpoints.shutdown.enabled: true
server.port: 8080
server.tomcat.basedir: target/tomcat
server.tomcat.access_log_pattern: %h %t "%r" %s %b
security.require_ssl: false
......
......@@ -20,6 +20,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.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
......@@ -40,16 +41,19 @@ import static org.junit.Assert.assertEquals;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
@WebAppConfiguration
@IntegrationTest
@IntegrationTest("server.port=0")
@DirtiesContext
@ActiveProfiles("endpoints")
public class EndpointsPropertiesSampleActuatorApplicationTests {
@Value("${local.server.port}")
private int port;
@Test
public void testCustomErrorPath() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate("user", "password")
.getForEntity("http://localhost:8080/oops", Map.class);
.getForEntity("http://localhost:" + port + "/oops", Map.class);
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......@@ -60,7 +64,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
@Test
public void testCustomContextPath() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:8080/admin/health", String.class);
"http://localhost:" + port + "/admin/health", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
String body = entity.getBody();
assertEquals("ok", body);
......
......@@ -16,6 +16,8 @@
package sample.actuator;
import static org.junit.Assert.assertEquals;
import java.util.Map;
import org.junit.Test;
......@@ -29,12 +31,9 @@ import org.springframework.boot.test.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import static org.junit.Assert.assertEquals;
/**
* Integration tests for separate management and main service ports.
*
......@@ -43,18 +42,17 @@ import static org.junit.Assert.assertEquals;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
@WebAppConfiguration
@IntegrationTest
@IntegrationTest({"server.port=0", "management.port=0", "management.address=127.0.0.1", "management.contextPath:/admin"})
@DirtiesContext
@ActiveProfiles("management-address")
public class ManagementAddressActuatorApplicationTests {
@Autowired
private SecurityProperties security;
@Value("${server.port}")
@Value("${local.server.port}")
private int port = 9010;
@Value("${management.port}")
@Value("${local.management.port}")
private int managementPort = 9011;
@Test
......
......@@ -16,6 +16,8 @@
package sample.actuator;
import static org.junit.Assert.assertEquals;
import java.util.Map;
import org.junit.Test;
......@@ -29,12 +31,9 @@ import org.springframework.boot.test.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import static org.junit.Assert.assertEquals;
/**
* Integration tests for separate management and main service ports.
*
......@@ -43,18 +42,17 @@ import static org.junit.Assert.assertEquals;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
@WebAppConfiguration
@IntegrationTest
@IntegrationTest({"server.port=0", "management.port=0"})
@DirtiesContext
@ActiveProfiles("management-port")
public class ManagementPortSampleActuatorApplicationTests {
@Autowired
private SecurityProperties security;
@Value("${server.port}")
@Value("${local.server.port}")
private int port = 9010;
@Value("${management.port}")
@Value("${local.management.port}")
private int managementPort = 9011;
@Test
......
......@@ -16,11 +16,14 @@
package sample.actuator;
import static org.junit.Assert.assertEquals;
import java.util.Map;
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.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
......@@ -28,12 +31,9 @@ import org.springframework.boot.test.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import static org.junit.Assert.assertEquals;
/**
* Integration tests for switching off management endpoints.
*
......@@ -42,19 +42,21 @@ import static org.junit.Assert.assertEquals;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
@WebAppConfiguration
@IntegrationTest
@IntegrationTest({"server.port=0", "management.port=-1"})
@DirtiesContext
@ActiveProfiles("nomanagement")
public class NoManagementSampleActuatorApplicationTests {
@Autowired
private SecurityProperties security;
@Value("${local.server.port}")
private int port = 0;
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080", Map.class);
.getForEntity("http://localhost:" + port, Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......@@ -66,7 +68,7 @@ public class NoManagementSampleActuatorApplicationTests {
testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080/metrics", Map.class);
.getForEntity("http://localhost:" + port + "/metrics", Map.class);
assertEquals(HttpStatus.NOT_FOUND, entity.getStatusCode());
}
......
......@@ -23,6 +23,7 @@ import java.util.Map;
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.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
......@@ -50,18 +51,21 @@ import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
@WebAppConfiguration
@IntegrationTest
@IntegrationTest("server.port=0")
@DirtiesContext
public class SampleActuatorApplicationTests {
@Autowired
private SecurityProperties security;
@Value("${local.server.port}")
private int port;
@Test
public void testHomeIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:8080", Map.class);
"http://localhost:" + port, Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......@@ -74,16 +78,16 @@ public class SampleActuatorApplicationTests {
public void testMetricsIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:8080/metrics", Map.class);
"http://localhost:" + port + "/metrics", Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
entity = new TestRestTemplate().getForEntity(
"http://localhost:8080/metrics/", Map.class);
entity = new TestRestTemplate().getForEntity("http://localhost:" + port + "/metrics/",
Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
entity = new TestRestTemplate().getForEntity(
"http://localhost:8080/metrics/foo", Map.class);
entity = new TestRestTemplate().getForEntity("http://localhost:" + port + "/metrics/foo",
Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
entity = new TestRestTemplate().getForEntity(
"http://localhost:8080/metrics.json", Map.class);
"http://localhost:" + port + "/metrics.json", Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
}
......@@ -91,7 +95,7 @@ public class SampleActuatorApplicationTests {
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080", Map.class);
.getForEntity("http://localhost:" + port, Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......@@ -103,7 +107,7 @@ public class SampleActuatorApplicationTests {
testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080/metrics", Map.class);
.getForEntity("http://localhost:" + port + "/metrics", Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......@@ -114,7 +118,7 @@ public class SampleActuatorApplicationTests {
public void testEnv() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080/env", Map.class);
.getForEntity("http://localhost:" + port + "/env", Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......@@ -124,7 +128,7 @@ public class SampleActuatorApplicationTests {
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:8080/health", String.class);
"http://localhost:" + port + "/health", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("ok", entity.getBody());
}
......@@ -132,7 +136,7 @@ public class SampleActuatorApplicationTests {
@Test
public void testErrorPage() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080/foo", String.class);
.getForEntity("http://localhost:" + port + "/foo", String.class);
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, entity.getStatusCode());
String body = entity.getBody();
assertNotNull(body);
......@@ -145,7 +149,7 @@ public class SampleActuatorApplicationTests {
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
HttpEntity<?> request = new HttpEntity<Void>(headers);
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
.exchange("http://localhost:8080/foo", HttpMethod.GET, request,
.exchange("http://localhost:" + port + "/foo", HttpMethod.GET, request,
String.class);
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, entity.getStatusCode());
String body = entity.getBody();
......@@ -156,10 +160,10 @@ public class SampleActuatorApplicationTests {
@Test
public void testTrace() throws Exception {
new TestRestTemplate().getForEntity("http://localhost:8080/health", String.class);
new TestRestTemplate().getForEntity("http://localhost:" + port + "/health", String.class);
@SuppressWarnings("rawtypes")
ResponseEntity<List> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080/trace", List.class);
.getForEntity("http://localhost:" + port + "/trace", List.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
List<Map<String, Object>> list = entity.getBody();
......@@ -174,7 +178,7 @@ public class SampleActuatorApplicationTests {
public void testErrorPageDirectAccess() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:8080/error", Map.class);
"http://localhost:" + port + "/error", Map.class);
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......@@ -186,7 +190,7 @@ public class SampleActuatorApplicationTests {
public void testBeans() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<List> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080/beans", List.class);
.getForEntity("http://localhost:" + port + "/beans", List.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals(1, entity.getBody().size());
@SuppressWarnings("unchecked")
......
......@@ -21,6 +21,7 @@ import java.util.Map;
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.test.IntegrationTest;
import org.springframework.boot.test.TestRestTemplate;
......@@ -42,18 +43,21 @@ import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
@WebAppConfiguration
@IntegrationTest
@IntegrationTest("server.port=0")
@DirtiesContext
public class ShutdownSampleActuatorApplicationTests {
@Autowired
private SecurityProperties security;
@Value("${local.server.port}")
private int port;
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
.getForEntity("http://localhost:8080", Map.class);
.getForEntity("http://localhost:" + port, Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......@@ -64,7 +68,7 @@ public class ShutdownSampleActuatorApplicationTests {
public void testShutdown() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
.postForEntity("http://localhost:8080/shutdown", null, Map.class);
.postForEntity("http://localhost:" + port + "/shutdown", null, Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......
......@@ -20,6 +20,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.test.IntegrationTest;
import org.springframework.boot.test.TestRestTemplate;
import org.springframework.boot.test.SpringApplicationConfiguration;
......@@ -43,16 +44,19 @@ import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
@WebAppConfiguration
@IntegrationTest
@IntegrationTest({"server.port:0", "management.security.enabled:false"})
@DirtiesContext
@ActiveProfiles("unsecure-management")
public class UnsecureManagementSampleActuatorApplicationTests {
@Value("${local.server.port}")
private int port;
@Test
public void testHomeIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:8080", Map.class);
"http://localhost:" + port, Map.class);
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......@@ -71,7 +75,7 @@ public class UnsecureManagementSampleActuatorApplicationTests {
}
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:8080/metrics", Map.class);
"http://localhost:" + port + "/metrics", Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......
......@@ -16,23 +16,23 @@
package sample.actuator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.TestRestTemplate;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Integration tests for unsecured service endpoints (even with Spring Security on
* classpath).
......@@ -42,16 +42,17 @@ import static org.junit.Assert.assertFalse;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
@WebAppConfiguration
@IntegrationTest
@IntegrationTest({"server.port:0", "security.basic.enabled:false"})
@DirtiesContext
@ActiveProfiles("unsecure")
public class UnsecureSampleActuatorApplicationTests {
@Value("${local.server.port}")
private int port;
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:8080", Map.class);
"http://localhost:" + port, Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
......
server.port: 9010
management.port: 9011
management.address: 127.0.0.1
management.contextPath: /admin
\ No newline at end of file
......@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.EventListener;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
......@@ -88,6 +89,11 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
*/
public class EmbeddedWebApplicationContext extends GenericWebApplicationContext {
/**
*
*/
private static final String SERVER = "server";
/**
* Constant value for the DispatcherServlet bean name. A Servlet bean with this name
* is deemed to be the "main" servlet and is automatically given a mapping of "/" by
......@@ -102,6 +108,8 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
private String namespace;
private Map<String, EmbeddedServletContainer> containers = new HashMap<String, EmbeddedServletContainer>();
/**
* Register ServletContextAwareProcessor.
* @see ServletContextAwareProcessor
......@@ -158,6 +166,7 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
EmbeddedServletContainerFactory containerFactory = getEmbeddedServletContainerFactory();
this.embeddedServletContainer = containerFactory
.getEmbeddedServletContainer(getSelfInitializer());
this.containers.put(SERVER, this.embeddedServletContainer);
}
else if (getServletContext() != null) {
try {
......@@ -382,6 +391,7 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
try {
this.embeddedServletContainer.stop();
this.embeddedServletContainer = null;
this.containers.remove(SERVER);
}
catch (Exception ex) {
throw new IllegalStateException(ex);
......@@ -425,4 +435,15 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
return this.embeddedServletContainer;
}
/**
* A registry of embedded containers by name. The
* {@link #getEmbeddedServletContainer() canonical container} is called "server".
* Anyone else who creates one can register it with whatever name they please.
*
* @return the containers
*/
public Map<String, EmbeddedServletContainer> getEmbeddedServletContainers() {
return this.containers;
}
}
......@@ -16,7 +16,10 @@
package org.springframework.boot.test;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.TestContext;
......@@ -37,7 +40,12 @@ public class EmbeddedServletContainerListener extends AbstractTestExecutionListe
return;
}
EmbeddedWebApplicationContext embedded = (EmbeddedWebApplicationContext) context;
final int port = embedded.getEmbeddedServletContainer().getPort();
EnvironmentTestUtils.addEnvironment(embedded, "local.server.port:" + port);
Map<String, EmbeddedServletContainer> containers = embedded
.getEmbeddedServletContainers();
for (String name : containers.keySet()) {
int port = containers.get(name).getPort();
EnvironmentTestUtils.addEnvironment(embedded, "local." + name + ".port:"
+ port);
}
}
}
......@@ -143,6 +143,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
if (annotation == null) {
// Not running an embedded server, just setting up web context
args.put("server.port", "-1");
args.put("management.port", "-1");
}
else {
args.putAll(extractProperties(annotation.value()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment