Merge branch '1.2.x'
This commit is contained in:
commit
3f44a6fc4d
|
|
@ -66,6 +66,7 @@ import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
|
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
|
||||||
|
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
|
@ -148,7 +149,9 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
|
||||||
ManagementServerPort managementPort = ManagementServerPort
|
ManagementServerPort managementPort = ManagementServerPort
|
||||||
.get(this.applicationContext);
|
.get(this.applicationContext);
|
||||||
if (managementPort == ManagementServerPort.DIFFERENT
|
if (managementPort == ManagementServerPort.DIFFERENT
|
||||||
&& this.applicationContext instanceof WebApplicationContext) {
|
&& this.applicationContext instanceof EmbeddedWebApplicationContext
|
||||||
|
&& ((EmbeddedWebApplicationContext) this.applicationContext)
|
||||||
|
.getEmbeddedServletContainer() != null) {
|
||||||
createChildManagementContext();
|
createChildManagementContext();
|
||||||
}
|
}
|
||||||
if (managementPort == ManagementServerPort.SAME
|
if (managementPort == ManagementServerPort.SAME
|
||||||
|
|
@ -375,8 +378,9 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
|
||||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||||
AnnotatedTypeMetadata metadata) {
|
AnnotatedTypeMetadata metadata) {
|
||||||
AnnotationAttributes annotationAttributes = AnnotationAttributes
|
AnnotationAttributes annotationAttributes = AnnotationAttributes
|
||||||
.fromMap(metadata.getAnnotationAttributes(ConditionalOnEnabledEndpoint.class
|
.fromMap(metadata
|
||||||
.getName()));
|
.getAnnotationAttributes(ConditionalOnEnabledEndpoint.class
|
||||||
|
.getName()));
|
||||||
String endpointName = annotationAttributes.getString("value");
|
String endpointName = annotationAttributes.getString("value");
|
||||||
boolean enabledByDefault = annotationAttributes
|
boolean enabledByDefault = annotationAttributes
|
||||||
.getBoolean("enabledByDefault");
|
.getBoolean("enabledByDefault");
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,9 @@ import java.net.SocketException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
|
@ -78,6 +80,8 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.BDDMockito.given;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link EndpointWebMvcAutoConfiguration}.
|
* Tests for {@link EndpointWebMvcAutoConfiguration}.
|
||||||
|
|
@ -150,6 +154,24 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
assertAllClosed();
|
assertAllClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onDifferentPortInServletContainer() throws Exception {
|
||||||
|
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||||
|
DifferentPortConfig.class, BaseConfiguration.class,
|
||||||
|
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||||
|
ServletContext servletContext = mock(ServletContext.class);
|
||||||
|
given(servletContext.getInitParameterNames()).willReturn(
|
||||||
|
new Vector<String>().elements());
|
||||||
|
given(servletContext.getAttributeNames()).willReturn(
|
||||||
|
new Vector<String>().elements());
|
||||||
|
this.applicationContext.setServletContext(servletContext);
|
||||||
|
this.applicationContext.refresh();
|
||||||
|
assertContent("/controller", ports.get().management, null);
|
||||||
|
assertContent("/endpoint", ports.get().management, null);
|
||||||
|
this.applicationContext.close();
|
||||||
|
assertAllClosed();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onRandomPort() throws Exception {
|
public void onRandomPort() throws Exception {
|
||||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue