Merge branch '1.5.x'
This commit is contained in:
@@ -38,6 +38,7 @@ import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
import org.springframework.core.env.PropertySources;
|
||||
import org.springframework.core.env.PropertySourcesPropertyResolver;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
@@ -160,15 +161,21 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
}
|
||||
|
||||
private boolean hasCustomServerPort(List<String> properties) {
|
||||
Map<String, Object> props = TestPropertySourceUtils.convertInlinedPropertiesToMap(
|
||||
properties.toArray(new String[properties.size()]));
|
||||
MutablePropertySources sources = new MutablePropertySources();
|
||||
sources.addFirst(new MapPropertySource("inline", props));
|
||||
PropertySources sources = convertToPropertySources(properties);
|
||||
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
|
||||
new PropertySourcesPropertyResolver(sources), "server.");
|
||||
return resolver.containsProperty("port");
|
||||
}
|
||||
|
||||
private PropertySources convertToPropertySources(List<String> properties) {
|
||||
Map<String, Object> source = TestPropertySourceUtils
|
||||
.convertInlinedPropertiesToMap(
|
||||
properties.toArray(new String[properties.size()]));
|
||||
MutablePropertySources sources = new MutablePropertySources();
|
||||
sources.addFirst(new MapPropertySource("inline", source));
|
||||
return sources;
|
||||
}
|
||||
|
||||
private List<ApplicationContextInitializer<?>> getInitializers(
|
||||
MergedContextConfiguration config, SpringApplication application) {
|
||||
List<ApplicationContextInitializer<?>> initializers = new ArrayList<ApplicationContextInitializer<?>>();
|
||||
|
||||
@@ -27,8 +27,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link SpringBootTest} with a custom inline server.port in a non-embedded
|
||||
* web environment.
|
||||
* Test for {@link SpringBootTest} with a custom inline server.port in a non-embedded web
|
||||
* environment.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
||||
@@ -38,7 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@DirtiesContext
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "server.port=12345" })
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
|
||||
"server.port=12345" })
|
||||
public class SpringBootTestWebEnvironmentRandomPortCustomPortTests {
|
||||
|
||||
@Autowired
|
||||
@@ -55,4 +56,5 @@ public class SpringBootTestWebEnvironmentRandomPortCustomPortTests {
|
||||
protected static class Config extends AbstractConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user