Polish
This commit is contained in:
@@ -65,7 +65,8 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
|
||||
/**
|
||||
* Adapts {@link ConditionEvaluationReport} to a JSON friendly structure.
|
||||
*/
|
||||
@JsonPropertyOrder({ "positiveMatches", "negativeMatches", "exclusions", "unconditionalClasses" })
|
||||
@JsonPropertyOrder({ "positiveMatches", "negativeMatches", "exclusions",
|
||||
"unconditionalClasses" })
|
||||
@JsonInclude(Include.NON_EMPTY)
|
||||
public static class Report {
|
||||
|
||||
|
||||
@@ -66,8 +66,7 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
|
||||
}
|
||||
|
||||
private Manager getManager(TomcatWebServer webServer) {
|
||||
for (Container container : webServer.getTomcat().getHost()
|
||||
.findChildren()) {
|
||||
for (Container container : webServer.getTomcat().getHost().findChildren()) {
|
||||
if (container instanceof Context) {
|
||||
return ((Context) container).getManager();
|
||||
}
|
||||
|
||||
@@ -49,8 +49,9 @@ public class BootCuriesHrefIntegrationTests {
|
||||
@Test
|
||||
public void basicCuriesHref() {
|
||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0");
|
||||
assertThat(getCurieHref("http://localhost:" + port + "/application")).isEqualTo(
|
||||
"http://localhost:" + port + "/application/docs/#spring_boot_actuator__{rel}");
|
||||
assertThat(getCurieHref("http://localhost:" + port + "/application"))
|
||||
.isEqualTo("http://localhost:" + port
|
||||
+ "/application/docs/#spring_boot_actuator__{rel}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,8 +76,8 @@ public class BootCuriesHrefIntegrationTests {
|
||||
public void curiesHrefWithCustomServletAndContextPaths() {
|
||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||
"server.servlet.context-path:/context", "server.servlet.path:/servlet");
|
||||
assertThat(getCurieHref("http://localhost:" + port + "/context/servlet/application"))
|
||||
.isEqualTo("http://localhost:" + port
|
||||
assertThat(getCurieHref("http://localhost:" + port
|
||||
+ "/context/servlet/application")).isEqualTo("http://localhost:" + port
|
||||
+ "/context/servlet/application/docs/#spring_boot_actuator__{rel}");
|
||||
}
|
||||
|
||||
@@ -95,8 +96,9 @@ public class BootCuriesHrefIntegrationTests {
|
||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||
"server.servlet.context-path:/context", "server.servlet.path:/servlet",
|
||||
"management.port:0");
|
||||
assertThat(getCurieHref("http://localhost:" + port + "/application/")).isEqualTo(
|
||||
"http://localhost:" + port + "/application/docs/#spring_boot_actuator__{rel}");
|
||||
assertThat(getCurieHref("http://localhost:" + port + "/application/"))
|
||||
.isEqualTo("http://localhost:" + port
|
||||
+ "/application/docs/#spring_boot_actuator__{rel}");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -186,7 +186,8 @@ public class EndpointAutoConfigurationTests {
|
||||
@Test
|
||||
public void testInfoEndpointNoGitProperties() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of("spring.info.git.location:classpath:nonexistent").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.info.git.location:classpath:nonexistent")
|
||||
.applyTo(this.context);
|
||||
this.context.register(InfoContributorAutoConfiguration.class,
|
||||
EndpointAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -124,9 +124,11 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
public void setUp() {
|
||||
Ports values = new Ports();
|
||||
ports.set(values);
|
||||
TestPropertyValues.of(
|
||||
"management.context-path=", "management.security.enabled=false",
|
||||
"server.servlet.context-path=", "server.port=" + ports.get().server).applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("management.context-path=", "management.security.enabled=false",
|
||||
"server.servlet.context-path=",
|
||||
"server.port=" + ports.get().server)
|
||||
.applyTo(this.applicationContext);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -137,8 +139,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onSamePort() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.security.enabled=false").applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.security.enabled=false")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class);
|
||||
this.applicationContext.refresh();
|
||||
@@ -154,8 +156,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onSamePortWithHeader() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.add-application-context-header:true").applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.add-application-context-header:true")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class);
|
||||
this.applicationContext.refresh();
|
||||
@@ -167,8 +169,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onDifferentPort() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management).applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.port=" + ports.get().management)
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
DifferentPortConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||
@@ -187,8 +189,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onDifferentPortWithSpecificServer() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management).applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.port=" + ports.get().management)
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(SpecificWebServerConfig.class, RootConfig.class,
|
||||
DifferentPortConfig.class, EndpointConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||
@@ -214,9 +216,10 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onDifferentPortAndContext() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management,
|
||||
"management.context-path=/admin").applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("management.port=" + ports.get().management,
|
||||
"management.context-path=/admin")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
DifferentPortConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||
@@ -228,10 +231,11 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onDifferentPortAndMainContext() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"server.servlet.context-path=/spring",
|
||||
"management.port=" + ports.get().management,
|
||||
"management.context-path=/admin").applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("server.servlet.context-path=/spring",
|
||||
"management.port=" + ports.get().management,
|
||||
"management.context-path=/admin")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
DifferentPortConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||
@@ -243,8 +247,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onDifferentPortWithoutErrorMvcAutoConfiguration() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management).applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.port=" + ports.get().management)
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
DifferentPortConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class);
|
||||
@@ -254,8 +258,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onDifferentPortInWebServer() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management).applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.port=" + ports.get().management)
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
DifferentPortConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||
@@ -272,8 +276,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onRandomPort() throws Exception {
|
||||
TestPropertyValues.of("management.port=0",
|
||||
"management.security.enabled=false").applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.port=0", "management.security.enabled=false")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
|
||||
ErrorMvcAutoConfiguration.class);
|
||||
@@ -291,8 +295,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void onDifferentPortWithPrimaryFailure() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management).applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.port=" + ports.get().management)
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
DifferentPortConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||
@@ -320,10 +324,11 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void specificPortsViaProperties() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"server.port:" + ports.get().server,
|
||||
"management.port:" + ports.get().management,
|
||||
"management.security.enabled:false").applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("server.port:" + ports.get().server,
|
||||
"management.port:" + ports.get().management,
|
||||
"management.security.enabled:false")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
|
||||
ErrorMvcAutoConfiguration.class);
|
||||
@@ -339,8 +344,10 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
int managementPort = ports.get().management;
|
||||
try (ServerSocket serverSocket = new ServerSocket()) {
|
||||
serverSocket.bind(new InetSocketAddress(managementPort));
|
||||
TestPropertyValues.of("server.port:" + ports.get().server,
|
||||
"management.port:" + ports.get().management).applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("server.port:" + ports.get().server,
|
||||
"management.port:" + ports.get().management)
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
|
||||
ErrorMvcAutoConfiguration.class);
|
||||
@@ -351,7 +358,9 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void contextPath() throws Exception {
|
||||
TestPropertyValues.of("management.context-path:/test", "management.security.enabled:false").applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("management.context-path:/test", "management.security.enabled:false")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
JacksonAutoConfiguration.class,
|
||||
@@ -366,8 +375,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void overrideServerProperties() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"server.displayName:foo").applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("server.displayName:foo").applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
JacksonAutoConfiguration.class,
|
||||
@@ -400,8 +408,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void portPropertiesOnDifferentPort() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management).applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.port=" + ports.get().management)
|
||||
.applyTo(this.applicationContext);
|
||||
new ServerPortInfoApplicationContextInitializer()
|
||||
.initialize(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, DifferentPortConfig.class,
|
||||
@@ -441,8 +449,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
public void endpointsAllDisabled() throws Exception {
|
||||
this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"endpoints.enabled:false").applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("endpoints.enabled:false").applyTo(this.applicationContext);
|
||||
this.applicationContext.refresh();
|
||||
assertThat(this.applicationContext.getBeansOfType(MvcEndpoint.class)).isEmpty();
|
||||
}
|
||||
@@ -491,8 +498,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
public void shutdownEndpointEnabled() {
|
||||
this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"endpoints.shutdown.enabled:true").applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("endpoints.shutdown.enabled:true")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.refresh();
|
||||
assertThat(this.applicationContext.getBeansOfType(ShutdownMvcEndpoint.class))
|
||||
.hasSize(1);
|
||||
@@ -502,7 +509,9 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
public void actuatorEndpointEnabledIndividually() {
|
||||
this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class);
|
||||
TestPropertyValues.of("endpoints.enabled:false", "endpoints.actuator.enabled:true").applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("endpoints.enabled:false", "endpoints.actuator.enabled:true")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.refresh();
|
||||
assertThat(this.applicationContext.getBeansOfType(HalJsonMvcEndpoint.class))
|
||||
.hasSize(1);
|
||||
@@ -510,10 +519,12 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void managementSpecificSslUsingDifferentPort() throws Exception {
|
||||
TestPropertyValues.of("management.port=" + ports.get().management,
|
||||
"management.ssl.enabled=true",
|
||||
"management.ssl.key-store=classpath:test.jks",
|
||||
"management.ssl.key-password=password").applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("management.port=" + ports.get().management,
|
||||
"management.ssl.enabled=true",
|
||||
"management.ssl.key-store=classpath:test.jks",
|
||||
"management.ssl.key-password=password")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
DifferentPortConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||
@@ -536,10 +547,11 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void managementSpecificSslUsingSamePortFails() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.ssl.enabled=true",
|
||||
"management.ssl.key-store=classpath:test.jks",
|
||||
"management.ssl.key-password=password").applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("management.ssl.enabled=true",
|
||||
"management.ssl.key-store=classpath:test.jks",
|
||||
"management.ssl.key-password=password")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
|
||||
ErrorMvcAutoConfiguration.class);
|
||||
@@ -551,10 +563,10 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void managementServerCanDisableSslWhenUsingADifferentPort() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management, "server.ssl.enabled=true",
|
||||
"server.ssl.key-store=classpath:test.jks",
|
||||
"server.ssl.key-password=password", "management.ssl.enabled=false").applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.port=" + ports.get().management,
|
||||
"server.ssl.enabled=true", "server.ssl.key-store=classpath:test.jks",
|
||||
"server.ssl.key-password=password", "management.ssl.enabled=false")
|
||||
.applyTo(this.applicationContext);
|
||||
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
DifferentPortConfig.class, BaseConfiguration.class,
|
||||
@@ -578,13 +590,13 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void tomcatManagementAccessLogUsesCustomPrefix() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management).applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("management.port=" + ports.get().management)
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(TomcatWebServerConfig.class, RootConfig.class,
|
||||
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"server.tomcat.accesslog.enabled: true").applyTo(this.applicationContext);
|
||||
TestPropertyValues.of("server.tomcat.accesslog.enabled: true")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.refresh();
|
||||
ApplicationContext managementContext = this.applicationContext
|
||||
.getBean(ManagementContextResolver.class).getApplicationContext();
|
||||
@@ -599,9 +611,10 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void undertowManagementAccessLogUsesCustomPrefix() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.port=" + ports.get().management,
|
||||
"server.undertow.accesslog.enabled: true").applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("management.port=" + ports.get().management,
|
||||
"server.undertow.accesslog.enabled: true")
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.register(UndertowWebServerConfig.class, RootConfig.class,
|
||||
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||
@@ -628,7 +641,8 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
private void endpointDisabled(String name, Class<? extends MvcEndpoint> type) {
|
||||
this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class);
|
||||
TestPropertyValues.of(String.format("endpoints.%s.enabled:false", name)).applyTo(this.applicationContext);
|
||||
TestPropertyValues.of(String.format("endpoints.%s.enabled:false", name))
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.refresh();
|
||||
assertThat(this.applicationContext.getBeansOfType(type)).isEmpty();
|
||||
}
|
||||
@@ -638,9 +652,10 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
this.applicationContext.register(LoggingConfig.class, RootConfig.class,
|
||||
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class);
|
||||
ConfigurationPropertySources.attach(this.applicationContext.getEnvironment());
|
||||
TestPropertyValues.of(
|
||||
"endpoints.enabled:false",
|
||||
String.format("endpoints.%s.enabled:true", name)).applyTo(this.applicationContext);
|
||||
TestPropertyValues
|
||||
.of("endpoints.enabled:false",
|
||||
String.format("endpoints.%s.enabled:true", name))
|
||||
.applyTo(this.applicationContext);
|
||||
this.applicationContext.refresh();
|
||||
assertThat(this.applicationContext.getBeansOfType(type)).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -79,37 +79,37 @@ public class EndpointWebMvcHypermediaManagementContextConfigurationTests {
|
||||
@Test
|
||||
public void curiesEnabledWithDefaultPorts() {
|
||||
load("endpoints.docs.curies.enabled:true");
|
||||
assertThat(getCurieHref())
|
||||
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
assertThat(getCurieHref()).isEqualTo(
|
||||
"http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void curiesEnabledWithRandomPorts() {
|
||||
load("endpoints.docs.curies.enabled:true", "server.port:0", "management.port:0");
|
||||
assertThat(getCurieHref())
|
||||
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
assertThat(getCurieHref()).isEqualTo(
|
||||
"http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void curiesEnabledWithSpecificServerPort() {
|
||||
load("endpoints.docs.curies.enabled:true", "server.port:8080");
|
||||
assertThat(getCurieHref())
|
||||
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
assertThat(getCurieHref()).isEqualTo(
|
||||
"http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void curiesEnabledWithSpecificManagementPort() {
|
||||
load("endpoints.docs.curies.enabled:true", "management.port:8081");
|
||||
assertThat(getCurieHref())
|
||||
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
assertThat(getCurieHref()).isEqualTo(
|
||||
"http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void curiesEnabledWithSpecificManagementAndServerPorts() {
|
||||
load("endpoints.docs.curies.enabled:true", "server.port:8080",
|
||||
"management.port:8081");
|
||||
assertThat(getCurieHref())
|
||||
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
assertThat(getCurieHref()).isEqualTo(
|
||||
"http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||
}
|
||||
|
||||
private void load(String... properties) {
|
||||
|
||||
@@ -68,9 +68,10 @@ public class EndpointWebMvcManagementContextConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void endpointHandlerMapping() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.security.enabled=false",
|
||||
"management.security.roles=my-role,your-role").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.security.enabled=false",
|
||||
"management.security.roles=my-role,your-role")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
EndpointHandlerMapping mapping = this.context.getBean("endpointHandlerMapping",
|
||||
EndpointHandlerMapping.class);
|
||||
|
||||
@@ -92,8 +92,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void defaultHealthIndicator() {
|
||||
this.context.register(HealthIndicatorAutoConfiguration.class,
|
||||
ManagementServerProperties.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -106,8 +106,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void defaultHealthIndicatorsDisabled() {
|
||||
this.context.register(HealthIndicatorAutoConfiguration.class,
|
||||
ManagementServerProperties.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.defaults.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.defaults.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -120,8 +120,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void defaultHealthIndicatorsDisabledWithCustomOne() {
|
||||
this.context.register(CustomHealthIndicator.class,
|
||||
HealthIndicatorAutoConfiguration.class, ManagementServerProperties.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.defaults.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.defaults.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -134,8 +134,7 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void defaultHealthIndicatorsDisabledButOne() {
|
||||
this.context.register(HealthIndicatorAutoConfiguration.class,
|
||||
ManagementServerProperties.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.defaults.enabled:false",
|
||||
TestPropertyValues.of("management.health.defaults.enabled:false",
|
||||
"management.health.diskspace.enabled:true").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
@@ -149,8 +148,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void redisHealthIndicator() {
|
||||
this.context.register(RedisAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -163,9 +162,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void notRedisHealthIndicator() {
|
||||
this.context.register(RedisAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.redis.enabled:false",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.health.redis.enabled:false",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -179,8 +179,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
this.context.register(MongoAutoConfiguration.class,
|
||||
ManagementServerProperties.class, MongoDataAutoConfiguration.class,
|
||||
HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -194,9 +194,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
this.context.register(MongoAutoConfiguration.class,
|
||||
ManagementServerProperties.class, MongoDataAutoConfiguration.class,
|
||||
HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.mongo.enabled:false",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.health.mongo.enabled:false",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -220,8 +221,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void dataSourceHealthIndicator() {
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -235,8 +236,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
DataSourceConfig.class, ManagementServerProperties.class,
|
||||
HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -252,8 +253,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
RoutingDatasourceConfig.class, ManagementServerProperties.class,
|
||||
HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -269,9 +270,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
DataSourceConfig.class,
|
||||
DataSourcePoolMetadataProvidersConfiguration.class,
|
||||
HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.test.validation-query:SELECT from FOOBAR",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.test.validation-query:SELECT from FOOBAR",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -286,9 +288,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void notDataSourceHealthIndicator() {
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.db.enabled:false",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.health.db.enabled:false",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -301,8 +304,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void rabbitHealthIndicator() {
|
||||
this.context.register(RabbitAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -315,9 +318,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void notRabbitHealthIndicator() {
|
||||
this.context.register(RabbitAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.rabbit.enabled:false",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.health.rabbit.enabled:false",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -330,8 +334,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void solrHealthIndicator() {
|
||||
this.context.register(SolrAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -344,9 +348,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
public void notSolrHealthIndicator() {
|
||||
this.context.register(SolrAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.health.solr.enabled:false",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.health.solr.enabled:false",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
@@ -368,9 +373,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void mailHealthIndicator() {
|
||||
TestPropertyValues.of(
|
||||
"spring.mail.host:smtp.acme.org",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.mail.host:smtp.acme.org",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(MailSenderAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -384,9 +390,11 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void notMailHealthIndicator() {
|
||||
TestPropertyValues.of(
|
||||
"spring.mail.host:smtp.acme.org", "management.health.mail.enabled:false",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.mail.host:smtp.acme.org",
|
||||
"management.health.mail.enabled:false",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(MailSenderAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -400,8 +408,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void jmsHealthIndicator() {
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(ActiveMQAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -415,9 +423,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void notJmsHealthIndicator() {
|
||||
TestPropertyValues.of(
|
||||
"management.health.jms.enabled:false",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.health.jms.enabled:false",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(ActiveMQAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -431,9 +440,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void elasticsearchHealthIndicator() {
|
||||
TestPropertyValues.of(
|
||||
"spring.data.elasticsearch.properties.path.home:target",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.data.elasticsearch.properties.path.home:target",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class, ManagementServerProperties.class,
|
||||
HealthIndicatorAutoConfiguration.class);
|
||||
@@ -448,8 +458,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void elasticsearchJestHealthIndicator() {
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -463,10 +473,11 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void notElasticsearchHealthIndicator() {
|
||||
TestPropertyValues.of(
|
||||
"management.health.elasticsearch.enabled:false",
|
||||
"spring.data.elasticsearch.properties.path.home:target",
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.health.elasticsearch.enabled:false",
|
||||
"spring.data.elasticsearch.properties.path.home:target",
|
||||
"management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class, ManagementServerProperties.class,
|
||||
HealthIndicatorAutoConfiguration.class);
|
||||
@@ -481,8 +492,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void cassandraHealthIndicator() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(CassandraConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -495,9 +506,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void notCassandraHealthIndicator() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false",
|
||||
"management.health.cassandra.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.health.diskspace.enabled:false",
|
||||
"management.health.cassandra.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(CassandraConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -510,8 +522,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void couchbaseHealthIndicator() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(CouchbaseConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -524,9 +536,10 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void notCouchbaseHealthIndicator() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false",
|
||||
"management.health.couchbase.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("management.health.diskspace.enabled:false",
|
||||
"management.health.couchbase.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(CouchbaseConfiguration.class,
|
||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -539,8 +552,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void ldapHealthIndicator() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(LdapConfiguration.class, ManagementServerProperties.class,
|
||||
HealthIndicatorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -553,8 +566,7 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void notLdapHealthIndicator() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.health.diskspace.enabled:false",
|
||||
TestPropertyValues.of("management.health.diskspace.enabled:false",
|
||||
"management.health.ldap.enabled:false").applyTo(this.context);
|
||||
this.context.register(LdapConfiguration.class, ManagementServerProperties.class,
|
||||
HealthIndicatorAutoConfiguration.class);
|
||||
|
||||
@@ -80,8 +80,7 @@ public class HealthMvcEndpointAutoConfigurationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(TestConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.security.enabled=false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.security.enabled=false").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
Health health = (Health) this.context.getBean(HealthMvcEndpoint.class)
|
||||
.invoke(null, null);
|
||||
@@ -96,8 +95,7 @@ public class HealthMvcEndpointAutoConfigurationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(TestConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.security.roles[0]=super").applyTo(this.context);
|
||||
TestPropertyValues.of("management.security.roles[0]=super").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
HealthMvcEndpoint health = this.context.getBean(HealthMvcEndpoint.class);
|
||||
assertThat(ReflectionTestUtils.getField(health, "roles"))
|
||||
|
||||
@@ -68,8 +68,9 @@ public class JolokiaAutoConfigurationTests {
|
||||
@Test
|
||||
public void agentServletRegisteredWithAppContext() throws Exception {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of("jolokia.config[key1]:value1",
|
||||
"jolokia.config[key2]:value2").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("jolokia.config[key1]:value1", "jolokia.config[key2]:value2")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
@@ -81,8 +82,7 @@ public class JolokiaAutoConfigurationTests {
|
||||
@Test
|
||||
public void agentServletWithCustomPath() throws Exception {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"endpoints.jolokia.path=/foo/bar").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.jolokia.path=/foo/bar").applyTo(this.context);
|
||||
this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
|
||||
@@ -100,7 +100,8 @@ public class ManagementWebSecurityAutoConfigurationTests {
|
||||
assertThat(filterChainProxy.getFilters("/application/beans")).isNotEmpty();
|
||||
assertThat(filterChainProxy.getFilters("/application/beans/")).isNotEmpty();
|
||||
assertThat(filterChainProxy.getFilters("/application/beans.foo")).isNotEmpty();
|
||||
assertThat(filterChainProxy.getFilters("/application/beans/foo/bar")).isNotEmpty();
|
||||
assertThat(filterChainProxy.getFilters("/application/beans/foo/bar"))
|
||||
.isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -148,8 +148,8 @@ public class MetricExportAutoConfigurationTests {
|
||||
@Test
|
||||
public void statsdWithHost() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.metrics.export.statsd.host=localhost").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.metrics.export.statsd.host=localhost")
|
||||
.applyTo(this.context);
|
||||
this.context.register(MetricEndpointConfiguration.class,
|
||||
MetricExportAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
|
||||
@@ -234,8 +234,7 @@ public class MetricFilterAutoConfigurationTests {
|
||||
@Test
|
||||
public void skipsFilterIfPropertyDisabled() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"endpoints.metrics.filter.enabled:false").applyTo(context);
|
||||
TestPropertyValues.of("endpoints.metrics.filter.enabled:false").applyTo(context);
|
||||
context.register(Config.class, MetricFilterAutoConfiguration.class);
|
||||
context.refresh();
|
||||
assertThat(context.getBeansOfType(Filter.class).size()).isEqualTo(0);
|
||||
@@ -355,9 +354,10 @@ public class MetricFilterAutoConfigurationTests {
|
||||
throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.register(Config.class, MetricFilterAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"endpoints.metrics.filter.gauge-submissions=merged,per-http-method",
|
||||
"endpoints.metrics.filter.counter-submissions=merged,per-http-method").applyTo(context);
|
||||
TestPropertyValues
|
||||
.of("endpoints.metrics.filter.gauge-submissions=merged,per-http-method",
|
||||
"endpoints.metrics.filter.counter-submissions=merged,per-http-method")
|
||||
.applyTo(context);
|
||||
context.refresh();
|
||||
Filter filter = context.getBean(Filter.class);
|
||||
final MockHttpServletRequest request = new MockHttpServletRequest("PUT",
|
||||
@@ -387,8 +387,7 @@ public class MetricFilterAutoConfigurationTests {
|
||||
public void doesNotRecordRolledUpMetricsIfConfigured() throws Exception {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.register(Config.class, MetricFilterAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"endpoints.metrics.filter.gauge-submissions=",
|
||||
TestPropertyValues.of("endpoints.metrics.filter.gauge-submissions=",
|
||||
"endpoints.metrics.filter.counter-submissions=").applyTo(context);
|
||||
context.refresh();
|
||||
Filter filter = context.getBean(Filter.class);
|
||||
|
||||
@@ -117,10 +117,11 @@ public class MvcEndpointPathConfigurationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(TestConfiguration.class);
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
TestPropertyValues.of(
|
||||
"endpoints." + this.endpointName + ".path" + ":/custom/path",
|
||||
"endpoints." + this.endpointName + ".enabled:true",
|
||||
"logging.file:target/test.log").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("endpoints." + this.endpointName + ".path" + ":/custom/path",
|
||||
"endpoints." + this.endpointName + ".enabled:true",
|
||||
"logging.file:target/test.log")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
assertThat(getConfiguredPath()).isEqualTo("/custom/path");
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void skipSslValidation() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"management.cloudfoundry.skipSslValidation:true").applyTo(this.context);
|
||||
TestPropertyValues.of("management.cloudfoundry.skipSslValidation:true")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.refresh();
|
||||
CloudFoundryEndpointHandlerMapping handlerMapping = getHandlerMapping();
|
||||
@@ -137,8 +137,9 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
||||
@Test
|
||||
public void cloudFoundryPlatformActiveAndCloudControllerUrlNotPresent()
|
||||
throws Exception {
|
||||
TestPropertyValues.of("VCAP_APPLICATION:---",
|
||||
"vcap.application.application_id:my-app-id").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
CloudFoundryEndpointHandlerMapping handlerMapping = this.context.getBean(
|
||||
"cloudFoundryEndpointHandlerMapping",
|
||||
@@ -152,8 +153,9 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPathsIgnoredBySpringSecurity() throws Exception {
|
||||
TestPropertyValues.of("VCAP_APPLICATION:---",
|
||||
"vcap.application.application_id:my-app-id").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
IgnoredRequestCustomizer customizer = (IgnoredRequestCustomizer) this.context
|
||||
.getBean("cloudFoundryIgnoredRequestCustomizer");
|
||||
@@ -179,17 +181,19 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void cloudFoundryManagementEndpointsDisabled() throws Exception {
|
||||
TestPropertyValues.of("VCAP_APPLICATION=---",
|
||||
"management.cloudfoundry.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION=---", "management.cloudfoundry.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.containsBean("cloudFoundryEndpointHandlerMapping"))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
private CloudFoundryEndpointHandlerMapping getHandlerMapping() {
|
||||
TestPropertyValues.of("VCAP_APPLICATION:---",
|
||||
"vcap.application.application_id:my-app-id",
|
||||
"vcap.application.cf_api:http://my-cloud-controller.com").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id",
|
||||
"vcap.application.cf_api:http://my-cloud-controller.com")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
return this.context.getBean("cloudFoundryEndpointHandlerMapping",
|
||||
CloudFoundryEndpointHandlerMapping.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -56,8 +56,7 @@ public class ConfigurationPropertiesReportEndpointMethodAnnotationsTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testNaming() throws Exception {
|
||||
this.context.register(Config.class);
|
||||
TestPropertyValues.of("other.name:foo",
|
||||
"first.name:bar").applyTo(this.context);
|
||||
TestPropertyValues.of("other.name:foo", "first.name:bar").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ConfigurationPropertiesReportEndpoint report = this.context
|
||||
.getBean(ConfigurationPropertiesReportEndpoint.class);
|
||||
|
||||
@@ -203,8 +203,8 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testInitializedMapAndList() throws Exception {
|
||||
this.context.register(InitializedMapAndListPropertiesConfig.class);
|
||||
TestPropertyValues.of("foo.map.entryOne:true",
|
||||
"foo.list[0]:abc").applyTo(this.context);
|
||||
TestPropertyValues.of("foo.map.entryOne:true", "foo.list[0]:abc")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ConfigurationPropertiesReportEndpoint report = this.context
|
||||
.getBean(ConfigurationPropertiesReportEndpoint.class);
|
||||
|
||||
@@ -130,8 +130,8 @@ public class ConfigurationPropertiesReportEndpointTests
|
||||
@Test
|
||||
public void testKeySanitizationWithCustomKeysByEnvironment() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"endpoints.configprops.keys-to-sanitize:property").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.configprops.keys-to-sanitize:property")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
ConfigurationPropertiesReportEndpoint report = getEndpointBean();
|
||||
@@ -147,8 +147,8 @@ public class ConfigurationPropertiesReportEndpointTests
|
||||
@Test
|
||||
public void testKeySanitizationWithCustomPatternByEnvironment() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"endpoints.configprops.keys-to-sanitize: .*pass.*").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.configprops.keys-to-sanitize: .*pass.*")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
ConfigurationPropertiesReportEndpoint report = getEndpointBean();
|
||||
@@ -165,8 +165,9 @@ public class ConfigurationPropertiesReportEndpointTests
|
||||
public void testKeySanitizationWithCustomPatternAndKeyByEnvironment()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"endpoints.configprops.keys-to-sanitize: .*pass.*, property").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("endpoints.configprops.keys-to-sanitize: .*pass.*, property")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
ConfigurationPropertiesReportEndpoint report = getEndpointBean();
|
||||
@@ -184,8 +185,9 @@ public class ConfigurationPropertiesReportEndpointTests
|
||||
throws Exception {
|
||||
// gh-4415
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"endpoints.configprops.keys-to-sanitize: .*\\.secrets\\..*, .*\\.hidden\\..*").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("endpoints.configprops.keys-to-sanitize: .*\\.secrets\\..*, .*\\.hidden\\..*")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
ConfigurationPropertiesReportEndpoint report = getEndpointBean();
|
||||
|
||||
@@ -151,8 +151,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||
@Test
|
||||
public void testKeySanitizationWithCustomKeysByEnvironment() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"endpoints.env.keys-to-sanitize: key").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.env.keys-to-sanitize: key")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
System.setProperty("dbPassword", "123456");
|
||||
@@ -170,8 +170,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||
@Test
|
||||
public void testKeySanitizationWithCustomPatternByEnvironment() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"endpoints.env.keys-to-sanitize: .*pass.*").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.env.keys-to-sanitize: .*pass.*")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
System.setProperty("dbPassword", "123456");
|
||||
@@ -190,8 +190,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||
public void testKeySanitizationWithCustomPatternAndKeyByEnvironment()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"endpoints.env.keys-to-sanitize: .*pass.*, key").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.env.keys-to-sanitize: .*pass.*, key")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
System.setProperty("dbPassword", "123456");
|
||||
@@ -209,8 +209,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||
@Test
|
||||
public void propertyWithPlaceholderResolved() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of("my.foo: ${bar.blah}",
|
||||
"bar.blah: hello").applyTo(this.context);
|
||||
TestPropertyValues.of("my.foo: ${bar.blah}", "bar.blah: hello")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
EnvironmentEndpoint report = getEndpointBean();
|
||||
@@ -236,8 +236,9 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||
@Test
|
||||
public void propertyWithSensitivePlaceholderResolved() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"my.foo: http://${bar.password}://hello", "bar.password: hello").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("my.foo: http://${bar.password}://hello", "bar.password: hello")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
EnvironmentEndpoint report = getEndpointBean();
|
||||
@@ -250,8 +251,8 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
||||
@Test
|
||||
public void propertyWithSensitivePlaceholderNotResolved() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"my.foo: http://${bar.password}://hello").applyTo(this.context);
|
||||
TestPropertyValues.of("my.foo: http://${bar.password}://hello")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class);
|
||||
this.context.refresh();
|
||||
EnvironmentEndpoint report = getEndpointBean();
|
||||
|
||||
@@ -76,8 +76,8 @@ public class EnvironmentMvcEndpointTests {
|
||||
public void setUp() {
|
||||
this.context.getBean(EnvironmentEndpoint.class).setEnabled(true);
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
TestPropertyValues.of(
|
||||
"foo:bar", "fool:baz").applyTo((ConfigurableApplicationContext) this.context);
|
||||
TestPropertyValues.of("foo:bar", "fool:baz")
|
||||
.applyTo((ConfigurableApplicationContext) this.context);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,9 +89,9 @@ public class EnvironmentMvcEndpointTests {
|
||||
|
||||
@Test
|
||||
public void homeContentTypeCanBeApplicationJson() throws Exception {
|
||||
this.mvc.perform(
|
||||
get("/application/env").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
|
||||
.andExpect(status().isOk()).andExpect(header().string("Content-Type",
|
||||
this.mvc.perform(get("/application/env").header(HttpHeaders.ACCEPT,
|
||||
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
||||
.andExpect(header().string("Content-Type",
|
||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,9 @@ public class HalBrowserMvcEndpointBrowserPathIntegrationTests {
|
||||
@Test
|
||||
public void requestWithTrailingSlashIsRedirectedToBrowserHtml() throws Exception {
|
||||
this.mockMvc.perform(get("/application/actuator/").accept(MediaType.TEXT_HTML))
|
||||
.andExpect(status().isFound()).andExpect(header().string(
|
||||
HttpHeaders.LOCATION, "http://localhost/application/actuator/browser.html"));
|
||||
.andExpect(status().isFound())
|
||||
.andExpect(header().string(HttpHeaders.LOCATION,
|
||||
"http://localhost/application/actuator/browser.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -75,8 +75,9 @@ public class HalBrowserMvcEndpointDisabledIntegrationTests {
|
||||
@Test
|
||||
public void browserRedirect() throws Exception {
|
||||
this.mockMvc.perform(get("/application/").accept(MediaType.TEXT_HTML))
|
||||
.andExpect(status().isFound()).andExpect(header().string(
|
||||
HttpHeaders.LOCATION, "http://localhost/application/browser.html"));
|
||||
.andExpect(status().isFound())
|
||||
.andExpect(header().string(HttpHeaders.LOCATION,
|
||||
"http://localhost/application/browser.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -90,8 +90,8 @@ public class HalBrowserMvcEndpointServerPortIntegrationTests {
|
||||
"http://localhost:" + this.port + "/application/", HttpMethod.GET,
|
||||
new HttpEntity<Void>(null, headers), String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
|
||||
assertThat(entity.getHeaders().getLocation()).isEqualTo(
|
||||
URI.create("http://localhost:" + this.port + "/application/browser.html"));
|
||||
assertThat(entity.getHeaders().getLocation()).isEqualTo(URI
|
||||
.create("http://localhost:" + this.port + "/application/browser.html"));
|
||||
}
|
||||
|
||||
@MinimalActuatorHypermediaApplication
|
||||
|
||||
@@ -85,8 +85,9 @@ public class HalBrowserMvcEndpointVanillaIntegrationTests {
|
||||
@Test
|
||||
public void browser() throws Exception {
|
||||
this.mockMvc.perform(get("/application/").accept(MediaType.TEXT_HTML))
|
||||
.andExpect(status().isFound()).andExpect(header().string(
|
||||
HttpHeaders.LOCATION, "http://localhost/application/browser.html"));
|
||||
.andExpect(status().isFound())
|
||||
.andExpect(header().string(HttpHeaders.LOCATION,
|
||||
"http://localhost/application/browser.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,7 +99,9 @@ public class HalBrowserMvcEndpointVanillaIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void envValue() throws Exception {
|
||||
this.mockMvc.perform(get("/application/env/user.home").accept(MediaType.APPLICATION_JSON))
|
||||
this.mockMvc
|
||||
.perform(get("/application/env/user.home")
|
||||
.accept(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._links").doesNotExist());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.actuate.endpoint.mvc;
|
||||
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
@@ -43,14 +42,17 @@ public class HalJsonMvcEndpointTests {
|
||||
@Test
|
||||
public void halJsonEndpointPathWhenManagementContextPathPresent() throws Exception {
|
||||
Mockito.when(this.managementServletContext.getContextPath()).thenReturn("my-app");
|
||||
HalJsonMvcEndpoint endpoint = new HalJsonMvcEndpoint(this.managementServletContext);
|
||||
HalJsonMvcEndpoint endpoint = new HalJsonMvcEndpoint(
|
||||
this.managementServletContext);
|
||||
assertThat(endpoint.getPath()).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void halJsonEndpointPathWhenManagementContextPathNotPresent() throws Exception {
|
||||
public void halJsonEndpointPathWhenManagementContextPathNotPresent()
|
||||
throws Exception {
|
||||
Mockito.when(this.managementServletContext.getContextPath()).thenReturn("");
|
||||
HalJsonMvcEndpoint endpoint = new HalJsonMvcEndpoint(this.managementServletContext);
|
||||
HalJsonMvcEndpoint endpoint = new HalJsonMvcEndpoint(
|
||||
this.managementServletContext);
|
||||
assertThat(endpoint.getPath()).isEqualTo("/application");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,20 +89,22 @@ public class HeapdumpMvcEndpointTests {
|
||||
public void invokeWhenNotAvailableShouldReturnServiceUnavailableStatus()
|
||||
throws Exception {
|
||||
this.endpoint.setAvailable(false);
|
||||
this.mvc.perform(get("/application/heapdump")).andExpect(status().isServiceUnavailable());
|
||||
this.mvc.perform(get("/application/heapdump"))
|
||||
.andExpect(status().isServiceUnavailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokeWhenLockedShouldReturnTooManyRequestsStatus() throws Exception {
|
||||
this.endpoint.setLocked(true);
|
||||
this.mvc.perform(get("/application/heapdump")).andExpect(status().isTooManyRequests());
|
||||
this.mvc.perform(get("/application/heapdump"))
|
||||
.andExpect(status().isTooManyRequests());
|
||||
assertThat(Thread.interrupted()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokeShouldReturnGzipContent() throws Exception {
|
||||
MvcResult result = this.mvc.perform(get("/application/heapdump")).andExpect(status().isOk())
|
||||
.andReturn();
|
||||
MvcResult result = this.mvc.perform(get("/application/heapdump"))
|
||||
.andExpect(status().isOk()).andReturn();
|
||||
byte[] bytes = result.getResponse().getContentAsByteArray();
|
||||
GZIPInputStream stream = new GZIPInputStream(new ByteArrayInputStream(bytes));
|
||||
byte[] uncompressed = FileCopyUtils.copyToByteArray(stream);
|
||||
|
||||
@@ -91,9 +91,9 @@ public class InfoMvcEndpointTests {
|
||||
|
||||
@Test
|
||||
public void contentTypeCanBeApplicationJson() throws Exception {
|
||||
this.mvc.perform(
|
||||
get("/application/info").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
|
||||
.andExpect(status().isOk()).andExpect(header().string("Content-Type",
|
||||
this.mvc.perform(get("/application/info").header(HttpHeaders.ACCEPT,
|
||||
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
||||
.andExpect(header().string("Content-Type",
|
||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ public class JolokiaMvcEndpointContextPathTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
TestPropertyValues.of("foo:bar").applyTo((ConfigurableApplicationContext) this.context);
|
||||
TestPropertyValues.of("foo:bar")
|
||||
.applyTo((ConfigurableApplicationContext) this.context);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -67,7 +67,8 @@ public class JolokiaMvcEndpointIntegrationTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
TestPropertyValues.of("foo:bar").applyTo((ConfigurableApplicationContext) this.context);
|
||||
TestPropertyValues.of("foo:bar")
|
||||
.applyTo((ConfigurableApplicationContext) this.context);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +79,8 @@ public class JolokiaMvcEndpointIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void search() throws Exception {
|
||||
this.mvc.perform(get("/application/jolokia/search/java.lang:*")).andExpect(status().isOk())
|
||||
this.mvc.perform(get("/application/jolokia/search/java.lang:*"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("GarbageCollector")));
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,8 @@ public class MvcEndpointCorsIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void settingAllowedOriginsEnablesCors() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.cors.allowed-origins:foo.example.com")
|
||||
.applyTo(this.context);
|
||||
createMockMvc()
|
||||
.perform(options("/application/beans").header("Origin", "bar.example.com")
|
||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
|
||||
@@ -81,16 +81,15 @@ public class MvcEndpointCorsIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void maxAgeDefaultsTo30Minutes() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.cors.allowed-origins:foo.example.com")
|
||||
.applyTo(this.context);
|
||||
performAcceptedCorsRequest()
|
||||
.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "1800"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maxAgeCanBeConfigured() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com",
|
||||
TestPropertyValues.of("endpoints.cors.allowed-origins:foo.example.com",
|
||||
"endpoints.cors.max-age: 2400").applyTo(this.context);
|
||||
performAcceptedCorsRequest()
|
||||
.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "2400"));
|
||||
@@ -98,8 +97,8 @@ public class MvcEndpointCorsIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void requestsWithDisallowedHeadersAreRejected() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.cors.allowed-origins:foo.example.com")
|
||||
.applyTo(this.context);
|
||||
createMockMvc()
|
||||
.perform(options("/application/beans").header("Origin", "foo.example.com")
|
||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
|
||||
@@ -109,9 +108,10 @@ public class MvcEndpointCorsIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void allowedHeadersCanBeConfigured() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com",
|
||||
"endpoints.cors.allowed-headers:Alpha,Bravo").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("endpoints.cors.allowed-origins:foo.example.com",
|
||||
"endpoints.cors.allowed-headers:Alpha,Bravo")
|
||||
.applyTo(this.context);
|
||||
createMockMvc()
|
||||
.perform(options("/application/beans").header("Origin", "foo.example.com")
|
||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
|
||||
@@ -122,21 +122,22 @@ public class MvcEndpointCorsIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void requestsWithDisallowedMethodsAreRejected() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.cors.allowed-origins:foo.example.com")
|
||||
.applyTo(this.context);
|
||||
createMockMvc()
|
||||
.perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com")
|
||||
.perform(options("/application/health")
|
||||
.header(HttpHeaders.ORIGIN, "foo.example.com")
|
||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "PATCH"))
|
||||
.andExpect(status().isForbidden());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowedMethodsCanBeConfigured() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com",
|
||||
TestPropertyValues.of("endpoints.cors.allowed-origins:foo.example.com",
|
||||
"endpoints.cors.allowed-methods:GET,HEAD").applyTo(this.context);
|
||||
createMockMvc()
|
||||
.perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com")
|
||||
.perform(options("/application/health")
|
||||
.header(HttpHeaders.ORIGIN, "foo.example.com")
|
||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "HEAD"))
|
||||
.andExpect(status().isOk()).andExpect(header()
|
||||
.string(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET,HEAD"));
|
||||
@@ -144,8 +145,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void credentialsCanBeAllowed() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com",
|
||||
TestPropertyValues.of("endpoints.cors.allowed-origins:foo.example.com",
|
||||
"endpoints.cors.allow-credentials:true").applyTo(this.context);
|
||||
performAcceptedCorsRequest().andExpect(
|
||||
header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"));
|
||||
@@ -153,8 +153,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void credentialsCanBeDisabled() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com",
|
||||
TestPropertyValues.of("endpoints.cors.allowed-origins:foo.example.com",
|
||||
"endpoints.cors.allow-credentials:false").applyTo(this.context);
|
||||
performAcceptedCorsRequest().andExpect(
|
||||
header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS));
|
||||
@@ -162,10 +161,11 @@ public class MvcEndpointCorsIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void jolokiaEndpointUsesGlobalCorsConfiguration() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.cors.allowed-origins:foo.example.com").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.cors.allowed-origins:foo.example.com")
|
||||
.applyTo(this.context);
|
||||
createMockMvc()
|
||||
.perform(options("/application/jolokia").header("Origin", "bar.example.com")
|
||||
.perform(options("/application/jolokia")
|
||||
.header("Origin", "bar.example.com")
|
||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
|
||||
.andExpect(status().isForbidden());
|
||||
performAcceptedCorsRequest("/application/jolokia");
|
||||
|
||||
@@ -72,7 +72,8 @@ public class MvcEndpointIntegrationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(SecureConfiguration.class);
|
||||
MockMvc mockMvc = createSecureMockMvc();
|
||||
mockMvc.perform(get("/application/mappings")).andExpect(content().string(startsWith("{\"")));
|
||||
mockMvc.perform(get("/application/mappings"))
|
||||
.andExpect(content().string(startsWith("{\"")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,8 +125,8 @@ public class MvcEndpointIntegrationTests {
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(SecureConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.context-path:/management").applyTo(this.context);
|
||||
TestPropertyValues.of("management.context-path:/management")
|
||||
.applyTo(this.context);
|
||||
MockMvc mockMvc = createSecureMockMvc();
|
||||
mockMvc.perform(get("/management/info")).andExpect(status().isOk());
|
||||
mockMvc.perform(get("/management")).andExpect(status().isOk());
|
||||
@@ -144,8 +145,8 @@ public class MvcEndpointIntegrationTests {
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(SecureConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.context-path:/management").applyTo(this.context);
|
||||
TestPropertyValues.of("management.context-path:/management")
|
||||
.applyTo(this.context);
|
||||
MockMvc mockMvc = createSecureMockMvc();
|
||||
mockMvc.perform(get("/management/beans")).andExpect(status().isUnauthorized());
|
||||
}
|
||||
@@ -157,8 +158,8 @@ public class MvcEndpointIntegrationTests {
|
||||
new TestingAuthenticationToken("user", "N/A", "ROLE_USER"));
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(SecureConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.context-path:/management").applyTo(this.context);
|
||||
TestPropertyValues.of("management.context-path:/management")
|
||||
.applyTo(this.context);
|
||||
MockMvc mockMvc = createSecureMockMvc();
|
||||
mockMvc.perform(get("/management/beans")).andExpect(status().isForbidden());
|
||||
}
|
||||
@@ -170,8 +171,8 @@ public class MvcEndpointIntegrationTests {
|
||||
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(SecureConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.context-path:/management").applyTo(this.context);
|
||||
TestPropertyValues.of("management.context-path:/management")
|
||||
.applyTo(this.context);
|
||||
MockMvc mockMvc = createSecureMockMvc();
|
||||
mockMvc.perform(get("/management/beans")).andExpect(status().isOk());
|
||||
}
|
||||
@@ -180,8 +181,7 @@ public class MvcEndpointIntegrationTests {
|
||||
public void endpointSecurityCanBeDisabledWithCustomContextPath() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(SecureConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.context-path:/management",
|
||||
TestPropertyValues.of("management.context-path:/management",
|
||||
"management.security.enabled:false").applyTo(this.context);
|
||||
MockMvc mockMvc = createSecureMockMvc();
|
||||
mockMvc.perform(get("/management/beans")).andExpect(status().isOk());
|
||||
@@ -191,8 +191,7 @@ public class MvcEndpointIntegrationTests {
|
||||
public void endpointSecurityCanBeDisabled() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(SecureConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.security.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.security.enabled:false").applyTo(this.context);
|
||||
MockMvc mockMvc = createSecureMockMvc();
|
||||
mockMvc.perform(get("/application/beans")).andExpect(status().isOk());
|
||||
}
|
||||
@@ -202,8 +201,8 @@ public class MvcEndpointIntegrationTests {
|
||||
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(configuration);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.serialization.indent-output:true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.serialization.indent-output:true")
|
||||
.applyTo(this.context);
|
||||
MockMvc mockMvc = createSecureMockMvc();
|
||||
mockMvc.perform(get("/application/mappings"))
|
||||
.andExpect(content().string(startsWith("{" + LINE_SEPARATOR)));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -68,8 +68,7 @@ public class MvcEndpointsTests {
|
||||
|
||||
@Test
|
||||
public void changesPath() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"endpoints.test.path=/foo/bar/").applyTo(this.context);
|
||||
TestPropertyValues.of("endpoints.test.path=/foo/bar/").applyTo(this.context);
|
||||
this.context.getDefaultListableBeanFactory().registerSingleton("endpoint",
|
||||
new TestEndpoint());
|
||||
this.endpoints.setApplicationContext(this.context);
|
||||
|
||||
@@ -84,8 +84,7 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(TestConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"management.security.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("management.security.enabled:false").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
mockMvc.perform(get("/application/health")).andExpect(status().isOk())
|
||||
|
||||
@@ -38,8 +38,8 @@ public class EnvironmentInfoContributorTests {
|
||||
|
||||
@Test
|
||||
public void extractOnlyInfoProperty() {
|
||||
TestPropertyValues.of("info.app=my app",
|
||||
"info.version=1.0.0", "foo=bar").applyTo(this.environment);
|
||||
TestPropertyValues.of("info.app=my app", "info.version=1.0.0", "foo=bar")
|
||||
.applyTo(this.environment);
|
||||
Info actual = contributeFrom(this.environment);
|
||||
assertThat(actual.get("app", String.class)).isEqualTo("my app");
|
||||
assertThat(actual.get("version", String.class)).isEqualTo("1.0.0");
|
||||
@@ -56,7 +56,8 @@ public class EnvironmentInfoContributorTests {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void propertiesFromEnvironmentShouldBindCorrectly() throws Exception {
|
||||
TestPropertyValues.of("INFO_ENVIRONMENT_FOO=green").applyTo(this.environment, Type.SYSTEM);
|
||||
TestPropertyValues.of("INFO_ENVIRONMENT_FOO=green").applyTo(this.environment,
|
||||
Type.SYSTEM);
|
||||
Info actual = contributeFrom(this.environment);
|
||||
assertThat(actual.get("environment", Map.class)).containsEntry("foo", "green");
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ public class MetricCopyExporterTests {
|
||||
@Test
|
||||
public void counterWithGaugeWriter() throws Exception {
|
||||
SimpleGaugeWriter writer = new SimpleGaugeWriter();
|
||||
try (MetricCopyExporter customExporter = new MetricCopyExporter(this.reader, writer)) {
|
||||
try (MetricCopyExporter customExporter = new MetricCopyExporter(this.reader,
|
||||
writer)) {
|
||||
this.reader.increment(new Delta<Number>("counter.foo", 2));
|
||||
customExporter.export();
|
||||
this.reader.increment(new Delta<Number>("counter.foo", 3));
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
/**
|
||||
* Provide a {@link BatchConfigurer} according to the current environment.
|
||||
* Provide a {@link BatchConfigurer} according to the current environment.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@@ -68,4 +68,3 @@ class BatchConfigurerConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -101,8 +101,7 @@ public class JooqAutoConfiguration {
|
||||
private final VisitListenerProvider[] visitListenerProviders;
|
||||
|
||||
public DslContextConfiguration(JooqProperties properties,
|
||||
ConnectionProvider connectionProvider,
|
||||
DataSource dataSource,
|
||||
ConnectionProvider connectionProvider, DataSource dataSource,
|
||||
ObjectProvider<TransactionProvider> transactionProvider,
|
||||
ObjectProvider<RecordMapperProvider> recordMapperProvider,
|
||||
ObjectProvider<Settings> settings,
|
||||
|
||||
@@ -77,8 +77,7 @@ public class QuartzAutoConfiguration {
|
||||
ObjectProvider<List<SchedulerFactoryBeanCustomizer>> customizers,
|
||||
ObjectProvider<Executor> taskExecutor, ObjectProvider<JobDetail[]> jobDetails,
|
||||
ObjectProvider<Map<String, Calendar>> calendars,
|
||||
ObjectProvider<Trigger[]> triggers,
|
||||
ApplicationContext applicationContext) {
|
||||
ObjectProvider<Trigger[]> triggers, ApplicationContext applicationContext) {
|
||||
this.properties = properties;
|
||||
this.customizers = customizers.getIfAvailable();
|
||||
this.taskExecutor = taskExecutor.getIfAvailable();
|
||||
@@ -147,8 +146,8 @@ public class QuartzAutoConfiguration {
|
||||
return schedulerFactoryBean -> {
|
||||
if (properties.getJobStoreType() == JobStoreType.JDBC) {
|
||||
schedulerFactoryBean.setDataSource(dataSource);
|
||||
PlatformTransactionManager txManager =
|
||||
transactionManager.getIfUnique();
|
||||
PlatformTransactionManager txManager = transactionManager
|
||||
.getIfUnique();
|
||||
if (txManager != null) {
|
||||
schedulerFactoryBean.setTransactionManager(txManager);
|
||||
}
|
||||
|
||||
@@ -95,8 +95,9 @@ public class ValidatorAdapter implements SmartValidator, ApplicationContextAware
|
||||
/**
|
||||
* Return a {@link Validator} that only implements the {@link Validator} interface,
|
||||
* wrapping it if necessary.
|
||||
* <p>If the specified {@link Validator} is not {@code null}, it is wrapped. If not,
|
||||
* a {@link javax.validation.Validator} is retrieved from the context and wrapped.
|
||||
* <p>
|
||||
* If the specified {@link Validator} is not {@code null}, it is wrapped. If not, a
|
||||
* {@link javax.validation.Validator} is retrieved from the context and wrapped.
|
||||
* Otherwise, a new default validator is created.
|
||||
* @param applicationContext the application context
|
||||
* @param validator an existing validator to use or {@code null}
|
||||
|
||||
@@ -56,7 +56,8 @@ public class HttpHandlerAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public HttpHandler httpHandler() {
|
||||
return WebHttpHandlerBuilder.applicationContext(this.applicationContext).build();
|
||||
return WebHttpHandlerBuilder.applicationContext(this.applicationContext)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.springframework.util.ObjectUtils;
|
||||
ReactiveWebServerConfiguration.TomcatAutoConfiguration.class,
|
||||
ReactiveWebServerConfiguration.JettyAutoConfiguration.class,
|
||||
ReactiveWebServerConfiguration.UndertowAutoConfiguration.class,
|
||||
ReactiveWebServerConfiguration.ReactorNettyAutoConfiguration.class})
|
||||
ReactiveWebServerConfiguration.ReactorNettyAutoConfiguration.class })
|
||||
public class ReactiveWebServerAutoConfiguration {
|
||||
|
||||
@ConditionalOnMissingBean
|
||||
|
||||
@@ -132,7 +132,7 @@ public class BatchAutoConfigurationTests {
|
||||
@Test
|
||||
public void testDefinesAndLaunchesNamedJob() throws Exception {
|
||||
load(new Class<?>[] { NamedJobConfigurationWithRegisteredJob.class,
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
"spring.batch.job.names:discreteRegisteredJob");
|
||||
JobRepository repository = this.context.getBean(JobRepository.class);
|
||||
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
|
||||
@@ -144,19 +144,19 @@ public class BatchAutoConfigurationTests {
|
||||
@Test
|
||||
public void testDefinesAndLaunchesLocalJob() throws Exception {
|
||||
load(new Class<?>[] { NamedJobConfigurationWithLocalJob.class,
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
"spring.batch.job.names:discreteLocalJob");
|
||||
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
|
||||
this.context.getBean(JobLauncherCommandLineRunner.class).run();
|
||||
assertThat(this.context.getBean(JobRepository.class)
|
||||
.getLastJobExecution("discreteLocalJob", new JobParameters()))
|
||||
.isNotNull();
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisableLaunchesJob() throws Exception {
|
||||
load(new Class<?>[] { JobConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
"spring.batch.job.enabled:false");
|
||||
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
|
||||
assertThat(this.context.getBeanNamesForType(CommandLineRunner.class).length)
|
||||
@@ -166,13 +166,13 @@ public class BatchAutoConfigurationTests {
|
||||
@Test
|
||||
public void testDisableSchemaLoader() throws Exception {
|
||||
load(new Class<?>[] { TestConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
"spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.initializer.enabled:false");
|
||||
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
|
||||
assertThat(
|
||||
this.context.getBean(BatchProperties.class).getInitializer().isEnabled())
|
||||
.isFalse();
|
||||
.isFalse();
|
||||
this.expected.expect(BadSqlGrammarException.class);
|
||||
new JdbcTemplate(this.context.getBean(DataSource.class))
|
||||
.queryForList("select * from BATCH_JOB_EXECUTION");
|
||||
@@ -197,8 +197,8 @@ public class BatchAutoConfigurationTests {
|
||||
@Test
|
||||
public void testRenamePrefix() throws Exception {
|
||||
load(new Class<?>[] { TestConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class },
|
||||
"spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
|
||||
"spring.batch.tablePrefix:PREFIX_");
|
||||
@@ -219,14 +219,14 @@ public class BatchAutoConfigurationTests {
|
||||
public void testCustomTablePrefixWithDefaultSchemaDisablesInitializer()
|
||||
throws Exception {
|
||||
load(new Class<?>[] { TestConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class },
|
||||
"spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.tablePrefix:PREFIX_");
|
||||
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
|
||||
assertThat(
|
||||
this.context.getBean(BatchProperties.class).getInitializer().isEnabled())
|
||||
.isFalse();
|
||||
.isFalse();
|
||||
this.expected.expect(BadSqlGrammarException.class);
|
||||
new JdbcTemplate(this.context.getBean(DataSource.class))
|
||||
.queryForList("select * from BATCH_JOB_EXECUTION");
|
||||
@@ -235,8 +235,8 @@ public class BatchAutoConfigurationTests {
|
||||
@Test
|
||||
public void testCustomizeJpaTransactionManagerUsingProperties() throws Exception {
|
||||
load(new Class<?>[] { TestConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class },
|
||||
"spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true");
|
||||
this.context.getBean(BatchConfigurer.class);
|
||||
@@ -250,7 +250,7 @@ public class BatchAutoConfigurationTests {
|
||||
public void testCustomizeDataSourceTransactionManagerUsingProperties()
|
||||
throws Exception {
|
||||
load(new Class<?>[] { TestConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
"spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true");
|
||||
this.context.getBean(BatchConfigurer.class);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class BatchAutoConfigurationWithoutJpaTests {
|
||||
@Test
|
||||
public void jdbcWithDefaultSettings() throws Exception {
|
||||
load(new Class<?>[] { DefaultConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
"spring.datasource.generate-unique-name=true");
|
||||
assertThat(this.context.getBeansOfType(JobLauncher.class)).hasSize(1);
|
||||
assertThat(this.context.getBeansOfType(JobExplorer.class)).hasSize(1);
|
||||
@@ -73,28 +73,30 @@ public class BatchAutoConfigurationWithoutJpaTests {
|
||||
.contains("DataSourceTransactionManager");
|
||||
assertThat(
|
||||
this.context.getBean(BatchProperties.class).getInitializer().isEnabled())
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(new JdbcTemplate(this.context.getBean(DataSource.class))
|
||||
.queryForList("select * from BATCH_JOB_EXECUTION")).isEmpty();
|
||||
assertThat(this.context.getBean(JobExplorer.class)
|
||||
.findRunningJobExecutions("test")).isEmpty();
|
||||
assertThat(this.context.getBean(JobRepository.class)
|
||||
.getLastJobExecution("test", new JobParameters())).isNull();
|
||||
assertThat(
|
||||
this.context.getBean(JobExplorer.class).findRunningJobExecutions("test"))
|
||||
.isEmpty();
|
||||
assertThat(this.context.getBean(JobRepository.class).getLastJobExecution("test",
|
||||
new JobParameters())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jdbcWithCustomPrefix() throws Exception {
|
||||
load(new Class<?>[] { DefaultConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
"spring.datasource.generate-unique-name=true",
|
||||
"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
|
||||
"spring.batch.tablePrefix:PREFIX_");
|
||||
assertThat(new JdbcTemplate(this.context.getBean(DataSource.class))
|
||||
.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
|
||||
assertThat(this.context.getBean(JobExplorer.class)
|
||||
.findRunningJobExecutions("test")).isEmpty();
|
||||
assertThat(this.context.getBean(JobRepository.class)
|
||||
.getLastJobExecution("test", new JobParameters())).isNull();
|
||||
assertThat(
|
||||
this.context.getBean(JobExplorer.class).findRunningJobExecutions("test"))
|
||||
.isEmpty();
|
||||
assertThat(this.context.getBean(JobRepository.class).getLastJobExecution("test",
|
||||
new JobParameters())).isNull();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -147,8 +147,8 @@ public class MessageSourceAutoConfigurationTests {
|
||||
parent.refresh();
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.setParent(parent);
|
||||
TestPropertyValues.of(
|
||||
"spring.messages.basename:test/messages").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.messages.basename:test/messages")
|
||||
.applyTo(this.context);
|
||||
this.context.register(MessageSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -66,8 +66,8 @@ public class PersistenceExceptionTranslationAutoConfigurationTests {
|
||||
@Test
|
||||
public void exceptionTranslationPostProcessorCanBeConfiguredToUseJdkProxy() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.aop.proxy-target-class=false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.aop.proxy-target-class=false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(PersistenceExceptionTranslationAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context
|
||||
@@ -79,8 +79,8 @@ public class PersistenceExceptionTranslationAutoConfigurationTests {
|
||||
@Test
|
||||
public void exceptionTranslationPostProcessorCanBeDisabled() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.dao.exceptiontranslation.enabled=false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.dao.exceptiontranslation.enabled=false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(PersistenceExceptionTranslationAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context
|
||||
|
||||
@@ -71,9 +71,10 @@ public class CassandraDataAutoConfigurationIntegrationTests {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
String cityPackage = City.class.getPackage().getName();
|
||||
AutoConfigurationPackages.register(this.context, cityPackage);
|
||||
TestPropertyValues.of(
|
||||
"spring.data.cassandra.schemaAction=recreate_drop_unused",
|
||||
"spring.data.cassandra.keyspaceName=boot_test").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.data.cassandra.schemaAction=recreate_drop_unused",
|
||||
"spring.data.cassandra.keyspaceName=boot_test")
|
||||
.applyTo(this.context);
|
||||
this.context.register(CassandraAutoConfiguration.class,
|
||||
CassandraDataAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -60,8 +60,8 @@ public class CassandraDataAutoConfigurationTests {
|
||||
@Test
|
||||
public void templateExists() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.cassandra.keyspaceName:boot_test").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.data.cassandra.keyspaceName:boot_test")
|
||||
.applyTo(this.context);
|
||||
this.context.register(TestExcludeConfiguration.class, TestConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);
|
||||
@@ -74,8 +74,7 @@ public class CassandraDataAutoConfigurationTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void entityScanShouldSetInitialEntitySet() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.cassandra.keyspaceName:boot_test");
|
||||
TestPropertyValues.of("spring.data.cassandra.keyspaceName:boot_test");
|
||||
this.context.register(TestConfiguration.class, EntityScanConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);
|
||||
@@ -90,8 +89,8 @@ public class CassandraDataAutoConfigurationTests {
|
||||
@Test
|
||||
public void userTypeResolverShouldBeSet() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.cassandra.keyspaceName:boot_test").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.data.cassandra.keyspaceName:boot_test")
|
||||
.applyTo(this.context);
|
||||
this.context.register(TestConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class);
|
||||
|
||||
@@ -55,9 +55,10 @@ public class ElasticsearchAutoConfigurationTests {
|
||||
@Test
|
||||
public void createNodeClientWithDefaults() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.elasticsearch.properties.foo.bar:baz",
|
||||
"spring.data.elasticsearch.properties.path.home:target").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.data.elasticsearch.properties.foo.bar:baz",
|
||||
"spring.data.elasticsearch.properties.path.home:target")
|
||||
.applyTo(this.context);
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -71,12 +72,13 @@ public class ElasticsearchAutoConfigurationTests {
|
||||
@Test
|
||||
public void createNodeClientWithOverrides() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.elasticsearch.properties.foo.bar:baz",
|
||||
"spring.data.elasticsearch.properties.path.home:target",
|
||||
"spring.data.elasticsearch.properties.node.local:false",
|
||||
"spring.data.elasticsearch.properties.node.data:true",
|
||||
"spring.data.elasticsearch.properties.http.enabled:true").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.data.elasticsearch.properties.foo.bar:baz",
|
||||
"spring.data.elasticsearch.properties.path.home:target",
|
||||
"spring.data.elasticsearch.properties.node.local:false",
|
||||
"spring.data.elasticsearch.properties.node.data:true",
|
||||
"spring.data.elasticsearch.properties.http.enabled:true")
|
||||
.applyTo(this.context);
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -105,9 +107,10 @@ public class ElasticsearchAutoConfigurationTests {
|
||||
// We don't have a local elasticsearch server so use an address that's missing
|
||||
// a port and check the exception
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.elasticsearch.cluster-nodes:localhost",
|
||||
"spring.data.elasticsearch.properties.path.home:target").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.data.elasticsearch.cluster-nodes:localhost",
|
||||
"spring.data.elasticsearch.properties.path.home:target")
|
||||
.applyTo(this.context);
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class);
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
|
||||
@@ -48,9 +48,9 @@ public class ElasticsearchDataAutoConfigurationTests {
|
||||
@Test
|
||||
public void templateExists() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs")
|
||||
TestPropertyValues
|
||||
.of("spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs")
|
||||
.applyTo(this.context);
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
@@ -63,9 +63,9 @@ public class ElasticsearchDataAutoConfigurationTests {
|
||||
@Test
|
||||
public void mappingContextExists() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs")
|
||||
TestPropertyValues
|
||||
.of("spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs")
|
||||
.applyTo(this.context);
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
@@ -79,9 +79,9 @@ public class ElasticsearchDataAutoConfigurationTests {
|
||||
@Test
|
||||
public void converterExists() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs")
|
||||
TestPropertyValues
|
||||
.of("spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs")
|
||||
.applyTo(this.context);
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
|
||||
@@ -88,8 +88,8 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||
}
|
||||
|
||||
private void addElasticsearchProperties(AnnotationConfigApplicationContext context) {
|
||||
TestPropertyValues.of(
|
||||
"spring.data.elasticsearch.properties.path.home:target").applyTo(context);
|
||||
TestPropertyValues.of("spring.data.elasticsearch.properties.path.home:target")
|
||||
.applyTo(context);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -46,8 +46,8 @@ public class LdapDataAutoConfigurationTests {
|
||||
@Test
|
||||
public void templateExists() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.ldap.urls:ldap://localhost:389").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.ldap.urls:ldap://localhost:389")
|
||||
.applyTo(this.context);
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
LdapAutoConfiguration.class, LdapDataAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -69,8 +69,8 @@ public class LdapRepositoriesAutoConfigurationTests {
|
||||
|
||||
private void load(Class<?>... configurationClasses) {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.ldap.urls:ldap://localhost:389").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.ldap.urls:ldap://localhost:389")
|
||||
.applyTo(this.context);
|
||||
this.context.register(configurationClasses);
|
||||
this.context.register(LdapAutoConfiguration.class,
|
||||
LdapDataAutoConfiguration.class, LdapRepositoriesAutoConfiguration.class,
|
||||
|
||||
@@ -62,8 +62,7 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:false").applyTo(this.context);
|
||||
this.context.register(TestConfiguration.class, BaseConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(CountryRepository.class)).isNotNull();
|
||||
@@ -72,8 +71,7 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void testMixedRepositoryConfiguration() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:false").applyTo(this.context);
|
||||
this.context.register(MixedConfiguration.class, BaseConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(CountryRepository.class)).isNotNull();
|
||||
@@ -83,8 +81,7 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void testJpaRepositoryConfigurationWithMongoTemplate() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:false").applyTo(this.context);
|
||||
this.context.register(JpaConfiguration.class, BaseConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
|
||||
@@ -93,8 +90,7 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void testJpaRepositoryConfigurationWithMongoOverlap() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:false").applyTo(this.context);
|
||||
this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
|
||||
@@ -104,9 +100,10 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
|
||||
public void testJpaRepositoryConfigurationWithMongoOverlapDisabled()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false",
|
||||
"spring.data.mongodb.repositories.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.initialize:false",
|
||||
"spring.data.mongodb.repositories.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
|
||||
|
||||
@@ -86,8 +86,7 @@ public class MongoDataAutoConfigurationTests {
|
||||
@Test
|
||||
public void gridFsTemplateExists() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.mongodb.gridFsDatabase:grid");
|
||||
TestPropertyValues.of("spring.data.mongodb.gridFsDatabase:grid");
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -180,8 +179,8 @@ public class MongoDataAutoConfigurationTests {
|
||||
Class<? extends FieldNamingStrategy> expectedType) {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
if (strategy != null) {
|
||||
TestPropertyValues.of(
|
||||
"spring.data.mongodb.field-naming-strategy:" + strategy).applyTo(this.context);
|
||||
TestPropertyValues.of("spring.data.mongodb.field-naming-strategy:" + strategy)
|
||||
.applyTo(this.context);
|
||||
}
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
|
||||
|
||||
@@ -58,8 +58,7 @@ public class MongoReactiveAndBlockingRepositoriesAutoConfigurationTests {
|
||||
public void shouldCreateInstancesForReactiveAndBlockingRepositories()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:false").applyTo(this.context);
|
||||
this.context.register(BlockingAndReactiveConfiguration.class,
|
||||
BaseConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -82,8 +82,8 @@ public class Neo4jRepositoriesAutoConfigurationTests {
|
||||
|
||||
private void prepareApplicationContext(Class<?>... configurationClasses) {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.neo4j.uri=http://localhost:9797").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.data.neo4j.uri=http://localhost:9797")
|
||||
.applyTo(this.context);
|
||||
this.context.register(configurationClasses);
|
||||
this.context.register(Neo4jDataAutoConfiguration.class,
|
||||
Neo4jRepositoriesAutoConfiguration.class,
|
||||
|
||||
@@ -99,8 +99,7 @@ public class SpringDataWebAutoConfigurationTests {
|
||||
}
|
||||
|
||||
private void load(String... environment) {
|
||||
AnnotationConfigWebApplicationContext ctx =
|
||||
new AnnotationConfigWebApplicationContext();
|
||||
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(environment).applyTo(ctx);
|
||||
ctx.register(SpringDataWebAutoConfiguration.class);
|
||||
ctx.refresh();
|
||||
|
||||
@@ -76,8 +76,7 @@ public class FlywayAutoConfigurationTests {
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.name:flywaytest").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.name:flywaytest").applyTo(this.context);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -96,8 +95,8 @@ public class FlywayAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void createDataSource() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"flyway.url:jdbc:hsqldb:mem:flywaytest", "flyway.user:sa").applyTo(this.context);
|
||||
TestPropertyValues.of("flyway.url:jdbc:hsqldb:mem:flywaytest", "flyway.user:sa")
|
||||
.applyTo(this.context);
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -126,8 +125,9 @@ public class FlywayAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void overrideLocations() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"flyway.locations:classpath:db/changelog,classpath:db/migration").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("flyway.locations:classpath:db/changelog,classpath:db/migration")
|
||||
.applyTo(this.context);
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -138,9 +138,10 @@ public class FlywayAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void overrideLocationsList() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"flyway.locations[0]:classpath:db/changelog",
|
||||
"flyway.locations[1]:classpath:db/migration").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("flyway.locations[0]:classpath:db/changelog",
|
||||
"flyway.locations[1]:classpath:db/migration")
|
||||
.applyTo(this.context);
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -161,8 +162,7 @@ public class FlywayAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void changeLogDoesNotExist() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"flyway.locations:file:no-such-dir").applyTo(this.context);
|
||||
TestPropertyValues.of("flyway.locations:file:no-such-dir").applyTo(this.context);
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
@@ -171,9 +171,10 @@ public class FlywayAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void checkLocationsAllMissing() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"flyway.locations:classpath:db/missing1,classpath:db/migration2",
|
||||
"flyway.check-location:true").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("flyway.locations:classpath:db/missing1,classpath:db/migration2",
|
||||
"flyway.check-location:true")
|
||||
.applyTo(this.context);
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
this.thrown.expectMessage("Cannot find migrations location in");
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
@@ -183,9 +184,10 @@ public class FlywayAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void checkLocationsAllExist() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"flyway.locations:classpath:db/changelog,classpath:db/migration",
|
||||
"flyway.check-location:true").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("flyway.locations:classpath:db/changelog,classpath:db/migration",
|
||||
"flyway.check-location:true")
|
||||
.applyTo(this.context);
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -245,8 +247,9 @@ public class FlywayAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void useVendorDirectory() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"flyway.locations=classpath:db/vendors/{vendor},classpath:db/changelog").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("flyway.locations=classpath:db/vendors/{vendor},classpath:db/changelog")
|
||||
.applyTo(this.context);
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -101,8 +101,8 @@ public class GroovyTemplateAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void disableViewResolution() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.groovy.template.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.groovy.template.enabled:false")
|
||||
.applyTo(this.context);
|
||||
registerAndRefreshContext();
|
||||
assertThat(this.context.getBeanNamesForType(ViewResolver.class)).isEmpty();
|
||||
}
|
||||
|
||||
@@ -66,8 +66,7 @@ public class H2ConsoleAutoConfigurationTests {
|
||||
@Test
|
||||
public void propertyCanEnableConsole() {
|
||||
this.context.register(H2ConsoleAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.h2.console.enabled:true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.h2.console.enabled:true").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
|
||||
ServletRegistrationBean<?> registrationBean = this.context
|
||||
@@ -83,16 +82,18 @@ public class H2ConsoleAutoConfigurationTests {
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
this.thrown.expectMessage("Failed to bind properties under 'spring.h2.console'");
|
||||
this.context.register(H2ConsoleAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.h2.console.enabled:true", "spring.h2.console.path:custom").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.h2.console.enabled:true", "spring.h2.console.path:custom")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customPathWithTrailingSlash() {
|
||||
this.context.register(H2ConsoleAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.h2.console.enabled:true", "spring.h2.console.path:/custom/").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.h2.console.enabled:true", "spring.h2.console.path:/custom/")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
|
||||
ServletRegistrationBean<?> servletRegistrationBean = this.context
|
||||
@@ -103,8 +104,9 @@ public class H2ConsoleAutoConfigurationTests {
|
||||
@Test
|
||||
public void customPath() {
|
||||
this.context.register(H2ConsoleAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.h2.console.enabled:true", "spring.h2.console.path:/custom").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.h2.console.enabled:true", "spring.h2.console.path:/custom")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
|
||||
ServletRegistrationBean<?> servletRegistrationBean = this.context
|
||||
@@ -115,9 +117,11 @@ public class H2ConsoleAutoConfigurationTests {
|
||||
@Test
|
||||
public void customInitParameters() {
|
||||
this.context.register(H2ConsoleAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.h2.console.enabled:true", "spring.h2.console.settings.trace=true",
|
||||
"spring.h2.console.settings.webAllowOthers=true").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.h2.console.enabled:true",
|
||||
"spring.h2.console.settings.trace=true",
|
||||
"spring.h2.console.settings.webAllowOthers=true")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
|
||||
ServletRegistrationBean<?> registrationBean = this.context
|
||||
|
||||
@@ -88,8 +88,8 @@ public class HypermediaAutoConfigurationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(EnableHypermediaSupportConfig.class, BaseConfig.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.serialization.INDENT_OUTPUT:true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.serialization.INDENT_OUTPUT:true")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean("_halObjectMapper",
|
||||
ObjectMapper.class);
|
||||
@@ -102,8 +102,8 @@ public class HypermediaAutoConfigurationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(BaseConfig.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.serialization.INDENT_OUTPUT:true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.serialization.INDENT_OUTPUT:true")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean("_halObjectMapper",
|
||||
ObjectMapper.class);
|
||||
@@ -132,8 +132,8 @@ public class HypermediaAutoConfigurationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(BaseConfig.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.hateoas.use-hal-as-default-json-media-type:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.hateoas.use-hal-as-default-json-media-type:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
RequestMappingHandlerAdapter handlerAdapter = this.context
|
||||
.getBean(RequestMappingHandlerAdapter.class);
|
||||
|
||||
@@ -153,8 +153,8 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||
public void gsonCanBePreferredWhenBothGsonAndJacksonAreAvailable() {
|
||||
this.context.register(GsonAutoConfiguration.class, JacksonAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.http.converters.preferred-json-mapper:gson").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.http.converters.preferred-json-mapper:gson")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
assertConverterBeanExists(GsonHttpMessageConverter.class,
|
||||
"gsonHttpMessageConverter");
|
||||
|
||||
@@ -126,8 +126,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customDateFormat() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.date-format:yyyyMMddHHmmss").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.date-format:yyyyMMddHHmmss")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
DateFormat dateFormat = mapper.getDateFormat();
|
||||
@@ -139,9 +139,10 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customJodaDateTimeFormat() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.date-format:yyyyMMddHHmmss",
|
||||
"spring.jackson.joda-date-time-format:yyyy-MM-dd HH:mm:ss").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jackson.date-format:yyyyMMddHHmmss",
|
||||
"spring.jackson.joda-date-time-format:yyyy-MM-dd HH:mm:ss")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
DateTime dateTime = new DateTime(1988, 6, 25, 20, 30, DateTimeZone.UTC);
|
||||
@@ -154,8 +155,9 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customDateFormatClass() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class);
|
||||
@@ -172,8 +174,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customPropertyNamingStrategyField() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.property-naming-strategy:SNAKE_CASE").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.property-naming-strategy:SNAKE_CASE")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(mapper.getPropertyNamingStrategy())
|
||||
@@ -183,8 +185,9 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customPropertyNamingStrategyClass() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(mapper.getPropertyNamingStrategy())
|
||||
@@ -194,8 +197,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void enableSerializationFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.serialization.indent_output:true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.serialization.indent_output:true")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(SerializationFeature.INDENT_OUTPUT.enabledByDefault()).isFalse();
|
||||
@@ -207,8 +210,9 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void disableSerializationFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.serialization.write_dates_as_timestamps:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jackson.serialization.write_dates_as_timestamps:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS.enabledByDefault())
|
||||
@@ -220,8 +224,9 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void enableDeserializationFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.deserialization.use_big_decimal_for_floats:true").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jackson.deserialization.use_big_decimal_for_floats:true")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS.enabledByDefault())
|
||||
@@ -233,8 +238,9 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void disableDeserializationFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.deserialization.fail-on-unknown-properties:false").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jackson.deserialization.fail-on-unknown-properties:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES.enabledByDefault())
|
||||
@@ -246,8 +252,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void enableMapperFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.mapper.require_setters_for_getters:true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.mapper.require_setters_for_getters:true")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.enabledByDefault())
|
||||
@@ -263,8 +269,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void disableMapperFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.mapper.use_annotations:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.mapper.use_annotations:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(MapperFeature.USE_ANNOTATIONS.enabledByDefault()).isTrue();
|
||||
@@ -277,8 +283,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void enableParserFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.parser.allow_single_quotes:true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.parser.allow_single_quotes:true")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(JsonParser.Feature.ALLOW_SINGLE_QUOTES.enabledByDefault()).isFalse();
|
||||
@@ -289,8 +295,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void disableParserFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.parser.auto_close_source:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.parser.auto_close_source:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(JsonParser.Feature.AUTO_CLOSE_SOURCE.enabledByDefault()).isTrue();
|
||||
@@ -301,8 +307,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void enableGeneratorFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.generator.write_numbers_as_strings:true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.generator.write_numbers_as_strings:true")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS.enabledByDefault())
|
||||
@@ -314,8 +320,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void disableGeneratorFeature() throws Exception {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.generator.auto_close_target:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.generator.auto_close_target:false")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
|
||||
assertThat(JsonGenerator.Feature.AUTO_CLOSE_TARGET.enabledByDefault()).isTrue();
|
||||
@@ -369,8 +375,8 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customSerializationInclusion() {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.default-property-inclusion:non_null").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.default-property-inclusion:non_null")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context
|
||||
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
||||
@@ -381,10 +387,9 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customTimeZoneFormattingADateTime() throws JsonProcessingException {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.time-zone:America/Los_Angeles").applyTo(this.context);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.date-format:zzzz").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.time-zone:America/Los_Angeles")
|
||||
.applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.date-format:zzzz").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.locale:en").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context
|
||||
@@ -397,8 +402,7 @@ public class JacksonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customTimeZoneFormattingADate() throws JsonProcessingException {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.time-zone:GMT+10").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.time-zone:GMT+10").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.date-format:z").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context
|
||||
@@ -411,8 +415,7 @@ public class JacksonAutoConfigurationTests {
|
||||
public void customLocale() throws JsonProcessingException {
|
||||
this.context.register(JacksonAutoConfiguration.class);
|
||||
TestPropertyValues.of("spring.jackson.locale:de").applyTo(this.context);
|
||||
TestPropertyValues.of(
|
||||
"spring.jackson.date-format:zzzz").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jackson.date-format:zzzz").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context
|
||||
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
||||
|
||||
@@ -58,9 +58,9 @@ public class DataSourceAutoConfigurationTests {
|
||||
@Before
|
||||
public void init() {
|
||||
EmbeddedDatabaseConnection.override = null;
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()).applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:false",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt())
|
||||
.applyTo(this.context);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -89,8 +89,8 @@ public class DataSourceAutoConfigurationTests {
|
||||
|
||||
@Test(expected = BeanCreationException.class)
|
||||
public void testBadUrl() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.url:jdbc:not-going-to-work").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.url:jdbc:not-going-to-work")
|
||||
.applyTo(this.context);
|
||||
EmbeddedDatabaseConnection.override = EmbeddedDatabaseConnection.NONE;
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -100,9 +100,10 @@ public class DataSourceAutoConfigurationTests {
|
||||
|
||||
@Test(expected = BeanCreationException.class)
|
||||
public void testBadDriverClass() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.driverClassName:org.none.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.driverClassName:org.none.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb")
|
||||
.applyTo(this.context);
|
||||
EmbeddedDatabaseConnection.override = EmbeddedDatabaseConnection.NONE;
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -152,9 +153,10 @@ public class DataSourceAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testEmbeddedTypeDefaultsUsername() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb")
|
||||
.applyTo(this.context);
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -172,10 +174,12 @@ public class DataSourceAutoConfigurationTests {
|
||||
*/
|
||||
@Test
|
||||
public void explicitTypeNoSupportedDataSource() {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb",
|
||||
"spring.datasource.type:" + SimpleDriverDataSource.class.getName()).applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb",
|
||||
"spring.datasource.type:"
|
||||
+ SimpleDriverDataSource.class.getName())
|
||||
.applyTo(this.context);
|
||||
this.context.setClassLoader(
|
||||
new HidePackagesClassLoader("org.apache.tomcat", "com.zaxxer.hikari",
|
||||
"org.apache.commons.dbcp", "org.apache.commons.dbcp2"));
|
||||
@@ -184,10 +188,12 @@ public class DataSourceAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void explicitTypeSupportedDataSource() {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb",
|
||||
"spring.datasource.type:" + SimpleDriverDataSource.class.getName()).applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb",
|
||||
"spring.datasource.type:"
|
||||
+ SimpleDriverDataSource.class.getName())
|
||||
.applyTo(this.context);
|
||||
testExplicitType();
|
||||
}
|
||||
|
||||
@@ -232,9 +238,10 @@ public class DataSourceAutoConfigurationTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends DataSource> T autoConfigureDataSource(Class<T> expectedType,
|
||||
final String... hiddenPackages) {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb")
|
||||
.applyTo(this.context);
|
||||
this.context.setClassLoader(new HidePackagesClassLoader(hiddenPackages));
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
|
||||
@@ -69,9 +69,9 @@ public class DataSourceInitializerTests {
|
||||
@Before
|
||||
public void init() {
|
||||
EmbeddedDatabaseConnection.override = null;
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()).applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:false",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt())
|
||||
.applyTo(this.context);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -93,8 +93,7 @@ public class DataSourceInitializerTests {
|
||||
|
||||
@Test
|
||||
public void testTwoDataSources() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"datasource.one.url=jdbc:hsqldb:mem:/one",
|
||||
TestPropertyValues.of("datasource.one.url=jdbc:hsqldb:mem:/one",
|
||||
"datasource.two.url=jdbc:hsqldb:mem:/two").applyTo(this.context);
|
||||
this.context.register(TwoDataSources.class, DataSourceInitializer.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, DataSourceProperties.class);
|
||||
@@ -105,8 +104,7 @@ public class DataSourceInitializerTests {
|
||||
|
||||
@Test
|
||||
public void testDataSourceInitialized() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:true").applyTo(this.context);
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -122,12 +120,13 @@ public class DataSourceInitializerTests {
|
||||
public void testDataSourceInitializedWithExplicitScript() throws Exception {
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "schema.sql"),
|
||||
"spring.datasource.data:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "data.sql")).applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "schema.sql"),
|
||||
"spring.datasource.data:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(), "data.sql"))
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertThat(dataSource).isInstanceOf(HikariDataSource.class);
|
||||
@@ -139,16 +138,17 @@ public class DataSourceInitializerTests {
|
||||
|
||||
@Test
|
||||
public void testDataSourceInitializedWithMultipleScripts() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"schema.sql")
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"schema.sql")
|
||||
+ ","
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"another.sql"),
|
||||
"spring.datasource.data:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "data.sql")).applyTo(this.context);
|
||||
"spring.datasource.data:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(), "data.sql"))
|
||||
.applyTo(this.context);
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -167,13 +167,13 @@ public class DataSourceInitializerTests {
|
||||
throws Exception {
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:true",
|
||||
TestPropertyValues.of("spring.datasource.initialize:true",
|
||||
"spring.datasource.sqlScriptEncoding:UTF-8",
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "encoding-schema.sql"),
|
||||
"spring.datasource.data:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "encoding-data.sql")).applyTo(this.context);
|
||||
.addResourcePathToPackagePath(getClass(), "encoding-data.sql"))
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertThat(dataSource).isInstanceOf(HikariDataSource.class);
|
||||
@@ -214,8 +214,7 @@ public class DataSourceInitializerTests {
|
||||
public void testDataSourceInitializedWithSchemaCredentials() {
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:true",
|
||||
TestPropertyValues.of("spring.datasource.initialize:true",
|
||||
"spring.datasource.sqlScriptEncoding:UTF-8",
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "encoding-schema.sql"),
|
||||
@@ -236,8 +235,7 @@ public class DataSourceInitializerTests {
|
||||
public void testDataSourceInitializedWithDataCredentials() {
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:true",
|
||||
TestPropertyValues.of("spring.datasource.initialize:true",
|
||||
"spring.datasource.sqlScriptEncoding:UTF-8",
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "encoding-schema.sql"),
|
||||
@@ -256,12 +254,12 @@ public class DataSourceInitializerTests {
|
||||
|
||||
@Test
|
||||
public void multipleScriptsAppliedInLexicalOrder() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:true",
|
||||
TestPropertyValues.of("spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "lexical-schema-*.sql"),
|
||||
"spring.datasource.data:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "data.sql")).applyTo(this.context);
|
||||
"spring.datasource.data:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(), "data.sql"))
|
||||
.applyTo(this.context);
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
ReverseOrderResourceLoader resourceLoader = new ReverseOrderResourceLoader(
|
||||
@@ -280,9 +278,10 @@ public class DataSourceInitializerTests {
|
||||
public void testDataSourceInitializedWithInvalidSchemaResource() {
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:classpath:does/not/exist.sql").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:classpath:does/not/exist.sql")
|
||||
.applyTo(this.context);
|
||||
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
this.thrown.expectMessage("does/not/exist.sql");
|
||||
@@ -294,11 +293,12 @@ public class DataSourceInitializerTests {
|
||||
public void testDataSourceInitializedWithInvalidDataResource() {
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "schema.sql"),
|
||||
"spring.datasource.data:classpath:does/not/exist.sql").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "schema.sql"),
|
||||
"spring.datasource.data:classpath:does/not/exist.sql")
|
||||
.applyTo(this.context);
|
||||
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
this.thrown.expectMessage("does/not/exist.sql");
|
||||
|
||||
@@ -110,9 +110,10 @@ public class DataSourceTransactionManagerAutoConfigurationTests {
|
||||
@Test
|
||||
public void testCustomizeDataSourceTransactionManagerUsingProperties()
|
||||
throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true")
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
DataSourceTransactionManagerAutoConfiguration.class,
|
||||
TransactionAutoConfiguration.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -61,8 +61,8 @@ public class HikariDataSourceConfigurationTests {
|
||||
@Test
|
||||
public void testDataSourcePropertiesOverridden() throws Exception {
|
||||
this.context.register(HikariDataSourceConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
PREFIX + "jdbcUrl:jdbc:foo//bar/spam").applyTo(this.context);
|
||||
TestPropertyValues.of(PREFIX + "jdbcUrl:jdbc:foo//bar/spam")
|
||||
.applyTo(this.context);
|
||||
TestPropertyValues.of(PREFIX + "maxLifetime:1234").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
HikariDataSource ds = this.context.getBean(HikariDataSource.class);
|
||||
@@ -74,8 +74,10 @@ public class HikariDataSourceConfigurationTests {
|
||||
@Test
|
||||
public void testDataSourceGenericPropertiesOverridden() throws Exception {
|
||||
this.context.register(HikariDataSourceConfiguration.class);
|
||||
TestPropertyValues.of(PREFIX
|
||||
+ "dataSourceProperties.dataSourceClassName:org.h2.JDBCDataSource").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of(PREFIX
|
||||
+ "dataSourceProperties.dataSourceClassName:org.h2.JDBCDataSource")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
HikariDataSource ds = this.context.getBean(HikariDataSource.class);
|
||||
assertThat(ds.getDataSourceProperties().getProperty("dataSourceClassName"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -61,9 +61,10 @@ public class HikariDriverConfigurationFailureAnalyzerTests {
|
||||
|
||||
private BeanCreationException createFailure(Class<?> configuration) {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.type=" + HikariDataSource.class.getName(),
|
||||
"spring.datasource.hikari.data-source-class-name=com.example.Foo").applyTo(context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.type=" + HikariDataSource.class.getName(),
|
||||
"spring.datasource.hikari.data-source-class-name=com.example.Foo")
|
||||
.applyTo(context);
|
||||
context.register(configuration);
|
||||
try {
|
||||
context.refresh();
|
||||
|
||||
@@ -52,9 +52,9 @@ public class JdbcTemplateAutoConfigurationTests {
|
||||
@Before
|
||||
public void init() {
|
||||
EmbeddedDatabaseConnection.override = null;
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt()).applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:false",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt())
|
||||
.applyTo(this.context);
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -88,8 +88,7 @@ public class JndiDataSourceAutoConfigurationTests {
|
||||
configureJndi("foo", dataSource);
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.jndi-name:foo").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.jndi-name:foo").applyTo(this.context);
|
||||
this.context.register(JndiDataSourceAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -104,8 +103,7 @@ public class JndiDataSourceAutoConfigurationTests {
|
||||
configureJndi("foo", dataSource);
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.jndi-name:foo").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.jndi-name:foo").applyTo(this.context);
|
||||
this.context.register(JndiDataSourceAutoConfiguration.class,
|
||||
MBeanExporterConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -125,8 +123,7 @@ public class JndiDataSourceAutoConfigurationTests {
|
||||
configureJndi("foo", dataSource);
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.jndi-name:foo").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.jndi-name:foo").applyTo(this.context);
|
||||
this.context.register(JndiDataSourceAutoConfiguration.class,
|
||||
MBeanExporterConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -64,8 +64,7 @@ public class TomcatDataSourceConfigurationTests {
|
||||
@Test
|
||||
public void testDataSourceExists() throws Exception {
|
||||
this.context.register(TomcatDataSourceConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
PREFIX + "url:jdbc:h2:mem:testdb").applyTo(this.context);
|
||||
TestPropertyValues.of(PREFIX + "url:jdbc:h2:mem:testdb").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(DataSource.class)).isNotNull();
|
||||
assertThat(this.context.getBean(org.apache.tomcat.jdbc.pool.DataSource.class))
|
||||
@@ -75,14 +74,11 @@ public class TomcatDataSourceConfigurationTests {
|
||||
@Test
|
||||
public void testDataSourcePropertiesOverridden() throws Exception {
|
||||
this.context.register(TomcatDataSourceConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
PREFIX + "url:jdbc:h2:mem:testdb",
|
||||
PREFIX + "testWhileIdle:true",
|
||||
PREFIX + "testOnBorrow:true",
|
||||
TestPropertyValues.of(PREFIX + "url:jdbc:h2:mem:testdb",
|
||||
PREFIX + "testWhileIdle:true", PREFIX + "testOnBorrow:true",
|
||||
PREFIX + "testOnReturn:true",
|
||||
PREFIX + "timeBetweenEvictionRunsMillis:10000",
|
||||
PREFIX + "minEvictableIdleTimeMillis:12345",
|
||||
PREFIX + "maxWait:1234",
|
||||
PREFIX + "minEvictableIdleTimeMillis:12345", PREFIX + "maxWait:1234",
|
||||
PREFIX + "jdbcInterceptors:SlowQueryReport",
|
||||
PREFIX + "validationInterval:9999").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
@@ -114,8 +110,7 @@ public class TomcatDataSourceConfigurationTests {
|
||||
@Test
|
||||
public void testDataSourceDefaultsPreserved() throws Exception {
|
||||
this.context.register(TomcatDataSourceConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
PREFIX + "url:jdbc:h2:mem:testdb").applyTo(this.context);
|
||||
TestPropertyValues.of(PREFIX + "url:jdbc:h2:mem:testdb").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
org.apache.tomcat.jdbc.pool.DataSource ds = this.context
|
||||
.getBean(org.apache.tomcat.jdbc.pool.DataSource.class);
|
||||
|
||||
@@ -147,7 +147,8 @@ public class JooqAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void relaxedBindingOfSqlDialect() {
|
||||
load(new Class<?>[] { JooqDataSourceConfiguration.class }, "spring.jooq.sql-dialect:PoSTGrES");
|
||||
load(new Class<?>[] { JooqDataSourceConfiguration.class },
|
||||
"spring.jooq.sql-dialect:PoSTGrES");
|
||||
assertThat(this.context.getBean(org.jooq.Configuration.class).dialect())
|
||||
.isEqualTo(SQLDialect.POSTGRES);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class JooqExceptionTranslatorTests {
|
||||
new Object[] { SQLDialect.POSTGRES_9_3, sqlException("03000") },
|
||||
new Object[] { SQLDialect.POSTGRES_9_4, sqlException("03000") },
|
||||
new Object[] { SQLDialect.POSTGRES_9_5, sqlException("03000") },
|
||||
new Object[] { SQLDialect.SQLITE, sqlException("21000") }};
|
||||
new Object[] { SQLDialect.SQLITE, sqlException("21000") } };
|
||||
}
|
||||
|
||||
private static SQLException sqlException(String sqlState) {
|
||||
|
||||
@@ -42,7 +42,8 @@ public class SqlDialectLookupTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSqlDialectWhenDataSourceIsUnknownShouldReturnDefault() throws Exception {
|
||||
public void getSqlDialectWhenDataSourceIsUnknownShouldReturnDefault()
|
||||
throws Exception {
|
||||
testGetSqlDialect("jdbc:idontexist:", SQLDialect.DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,8 @@ public class EmbeddedLdapAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testRandomPortWithValueAnnotation() throws LDAPException {
|
||||
TestPropertyValues.of(
|
||||
"spring.ldap.embedded.base-dn:dc=spring,dc=org").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.ldap.embedded.base-dn:dc=spring,dc=org")
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedLdapAutoConfiguration.class,
|
||||
LdapClientConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -119,8 +119,8 @@ public class EmbeddedLdapAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testQueryEmbeddedLdap() throws LDAPException {
|
||||
TestPropertyValues.of(
|
||||
"spring.ldap.embedded.base-dn:dc=spring,dc=org").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.ldap.embedded.base-dn:dc=spring,dc=org")
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedLdapAutoConfiguration.class,
|
||||
LdapAutoConfiguration.class, LdapDataAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
|
||||
@@ -69,8 +69,8 @@ public class LiquibaseAutoConfigurationTests {
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.name:liquibasetest").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.name:liquibasetest")
|
||||
.applyTo(this.context);
|
||||
new LiquibaseServiceLocatorApplicationListener().onApplicationEvent(null);
|
||||
}
|
||||
|
||||
@@ -106,8 +106,9 @@ public class LiquibaseAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testXmlChangeLog() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"liquibase.change-log:classpath:/db/changelog/db.changelog-override.xml").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("liquibase.change-log:classpath:/db/changelog/db.changelog-override.xml")
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -119,8 +120,9 @@ public class LiquibaseAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testJsonChangeLog() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"liquibase.change-log:classpath:/db/changelog/db.changelog-override.json").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("liquibase.change-log:classpath:/db/changelog/db.changelog-override.json")
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -132,8 +134,9 @@ public class LiquibaseAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testSqlChangeLog() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"liquibase.change-log:classpath:/db/changelog/db.changelog-override.sql").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("liquibase.change-log:classpath:/db/changelog/db.changelog-override.sql")
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -145,8 +148,8 @@ public class LiquibaseAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testOverrideContexts() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"liquibase.contexts:test, production").applyTo(this.context);
|
||||
TestPropertyValues.of("liquibase.contexts:test, production")
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -157,8 +160,7 @@ public class LiquibaseAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testOverrideDefaultSchema() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"liquibase.default-schema:public").applyTo(this.context);
|
||||
TestPropertyValues.of("liquibase.default-schema:public").applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -180,8 +182,9 @@ public class LiquibaseAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testOverrideDataSource() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"liquibase.url:jdbc:hsqldb:mem:liquibase", "liquibase.user:sa").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("liquibase.url:jdbc:hsqldb:mem:liquibase", "liquibase.user:sa")
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -195,8 +198,8 @@ public class LiquibaseAutoConfigurationTests {
|
||||
|
||||
@Test(expected = BeanCreationException.class)
|
||||
public void testChangeLogDoesNotExist() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"liquibase.change-log:classpath:/no-such-changelog.yaml").applyTo(this.context);
|
||||
TestPropertyValues.of("liquibase.change-log:classpath:/no-such-changelog.yaml")
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -217,8 +220,7 @@ public class LiquibaseAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testOverrideLabels() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"liquibase.labels:test, production").applyTo(this.context);
|
||||
TestPropertyValues.of("liquibase.labels:test, production").applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -245,8 +247,8 @@ public class LiquibaseAutoConfigurationTests {
|
||||
@Test
|
||||
public void testRollbackFile() throws Exception {
|
||||
File file = this.temp.newFile("rollback-file.sql");
|
||||
TestPropertyValues.of(
|
||||
"liquibase.rollbackFile:" + file.getAbsolutePath()).applyTo(this.context);
|
||||
TestPropertyValues.of("liquibase.rollbackFile:" + file.getAbsolutePath())
|
||||
.applyTo(this.context);
|
||||
this.context.register(EmbeddedDataSourceConfiguration.class,
|
||||
LiquibaseAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
|
||||
@@ -67,8 +67,7 @@ public class SitePreferenceAutoConfigurationTests {
|
||||
@Test
|
||||
public void sitePreferenceHandlerInterceptorEnabled() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.mobile.sitepreference.enabled:true");
|
||||
TestPropertyValues.of("spring.mobile.sitepreference.enabled:true");
|
||||
this.context.register(SitePreferenceAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(SitePreferenceHandlerInterceptor.class))
|
||||
@@ -78,8 +77,8 @@ public class SitePreferenceAutoConfigurationTests {
|
||||
@Test(expected = NoSuchBeanDefinitionException.class)
|
||||
public void sitePreferenceHandlerInterceptorDisabled() {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.mobile.sitepreference.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.mobile.sitepreference.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(SitePreferenceAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
this.context.getBean(SitePreferenceHandlerInterceptor.class);
|
||||
@@ -98,8 +97,7 @@ public class SitePreferenceAutoConfigurationTests {
|
||||
@Test
|
||||
public void sitePreferenceMethodArgumentResolverEnabled() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.mobile.sitepreference.enabled:true");
|
||||
TestPropertyValues.of("spring.mobile.sitepreference.enabled:true");
|
||||
this.context.register(SitePreferenceAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(
|
||||
@@ -110,8 +108,8 @@ public class SitePreferenceAutoConfigurationTests {
|
||||
@Test(expected = NoSuchBeanDefinitionException.class)
|
||||
public void sitePreferenceMethodArgumentResolverDisabled() {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.mobile.sitepreference.enabled:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.mobile.sitepreference.enabled:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(SitePreferenceAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
this.context.getBean(SitePreferenceHandlerMethodArgumentResolver.class);
|
||||
|
||||
@@ -60,8 +60,7 @@ public class MongoAutoConfigurationTests {
|
||||
@Test
|
||||
public void optionsAdded() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.mongodb.host:localhost");
|
||||
TestPropertyValues.of("spring.data.mongodb.host:localhost");
|
||||
this.context.register(OptionsConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -72,8 +71,7 @@ public class MongoAutoConfigurationTests {
|
||||
@Test
|
||||
public void optionsAddedButNoHost() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.mongodb.uri:mongodb://localhost/test");
|
||||
TestPropertyValues.of("spring.data.mongodb.uri:mongodb://localhost/test");
|
||||
this.context.register(OptionsConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -84,8 +82,8 @@ public class MongoAutoConfigurationTests {
|
||||
@Test
|
||||
public void optionsSslConfig() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.mongodb.uri:mongodb://localhost/test").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.data.mongodb.uri:mongodb://localhost/test")
|
||||
.applyTo(this.context);
|
||||
this.context.register(SslOptionsConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -66,8 +66,7 @@ public class MongoReactiveAutoConfigurationTests {
|
||||
@Test
|
||||
public void optionsAdded() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.mongodb.host:localhost").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.data.mongodb.host:localhost").applyTo(this.context);
|
||||
this.context.register(OptionsConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
MongoReactiveAutoConfiguration.class);
|
||||
@@ -79,8 +78,7 @@ public class MongoReactiveAutoConfigurationTests {
|
||||
@Test
|
||||
public void optionsAddedButNoHost() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.mongodb.uri:mongodb://localhost/test");
|
||||
TestPropertyValues.of("spring.data.mongodb.uri:mongodb://localhost/test");
|
||||
this.context.register(OptionsConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
MongoReactiveAutoConfiguration.class);
|
||||
@@ -93,8 +91,8 @@ public class MongoReactiveAutoConfigurationTests {
|
||||
@Test
|
||||
public void optionsSslConfig() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.mongodb.uri:mongodb://localhost/test").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.data.mongodb.uri:mongodb://localhost/test")
|
||||
.applyTo(this.context);
|
||||
this.context.register(SslOptionsConfig.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
MongoReactiveAutoConfiguration.class);
|
||||
|
||||
@@ -158,11 +158,11 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||
String expectedVersion) {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
int mongoPort = SocketUtils.findAvailableTcpPort();
|
||||
TestPropertyValues.of(
|
||||
"spring.data.mongodb.port=" + mongoPort).applyTo(this.context);
|
||||
TestPropertyValues.of("spring.data.mongodb.port=" + mongoPort)
|
||||
.applyTo(this.context);
|
||||
if (configuredVersion != null) {
|
||||
TestPropertyValues.of(
|
||||
"spring.mongodb.embedded.version=" + configuredVersion).applyTo(this.context);
|
||||
TestPropertyValues.of("spring.mongodb.embedded.version=" + configuredVersion)
|
||||
.applyTo(this.context);
|
||||
}
|
||||
this.context.register(MongoAutoConfiguration.class,
|
||||
MongoDataAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class);
|
||||
|
||||
@@ -44,47 +44,56 @@ public class MustacheAutoConfigurationTests {
|
||||
public void registerBeansForServletApp() {
|
||||
loadWithServlet(null);
|
||||
assertThat(this.webContext.getBeansOfType(Mustache.Compiler.class)).hasSize(1);
|
||||
assertThat(this.webContext.getBeansOfType(MustacheResourceTemplateLoader.class)).hasSize(1);
|
||||
assertThat(this.webContext.getBeansOfType(MustacheResourceTemplateLoader.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.webContext.getBeansOfType(MustacheViewResolver.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerCompilerForServletApp() {
|
||||
loadWithServlet(CustomCompilerConfiguration.class);
|
||||
assertThat(this.webContext.getBeansOfType(MustacheResourceTemplateLoader.class)).hasSize(1);
|
||||
assertThat(this.webContext.getBeansOfType(MustacheResourceTemplateLoader.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.webContext.getBeansOfType(MustacheViewResolver.class)).hasSize(1);
|
||||
assertThat(this.webContext.getBeansOfType(Mustache.Compiler.class)).hasSize(1);
|
||||
assertThat(this.webContext.getBean(Mustache.Compiler.class).standardsMode).isTrue();
|
||||
assertThat(this.webContext.getBean(Mustache.Compiler.class).standardsMode)
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerBeansForReactiveApp() {
|
||||
loadWithReactive(null);
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(Mustache.Compiler.class)).hasSize(1);
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(MustacheResourceTemplateLoader.class)).hasSize(1);
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(MustacheViewResolver.class)).isEmpty();
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(Mustache.Compiler.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.reactiveWebContext
|
||||
.getBeansOfType(org.springframework.boot.web.reactive.result.view.MustacheViewResolver.class)
|
||||
).hasSize(1);
|
||||
.getBeansOfType(MustacheResourceTemplateLoader.class)).hasSize(1);
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(MustacheViewResolver.class))
|
||||
.isEmpty();
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(
|
||||
org.springframework.boot.web.reactive.result.view.MustacheViewResolver.class))
|
||||
.hasSize(1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void registerCompilerForReactiveApp() {
|
||||
loadWithReactive(CustomCompilerConfiguration.class);
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(Mustache.Compiler.class)).hasSize(1);
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(MustacheResourceTemplateLoader.class)).hasSize(1);
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(MustacheViewResolver.class)).isEmpty();
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(Mustache.Compiler.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.reactiveWebContext
|
||||
.getBeansOfType(org.springframework.boot.web.reactive.result.view.MustacheViewResolver.class)
|
||||
).hasSize(1);
|
||||
assertThat(this.reactiveWebContext.getBean(Mustache.Compiler.class).standardsMode).isTrue();
|
||||
.getBeansOfType(MustacheResourceTemplateLoader.class)).hasSize(1);
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(MustacheViewResolver.class))
|
||||
.isEmpty();
|
||||
assertThat(this.reactiveWebContext.getBeansOfType(
|
||||
org.springframework.boot.web.reactive.result.view.MustacheViewResolver.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.reactiveWebContext.getBean(Mustache.Compiler.class).standardsMode)
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
private void loadWithServlet(Class<?> config) {
|
||||
this.webContext = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.mustache.prefix=classpath:/mustache-templates/").applyTo(this.webContext);
|
||||
TestPropertyValues.of("spring.mustache.prefix=classpath:/mustache-templates/")
|
||||
.applyTo(this.webContext);
|
||||
if (config != null) {
|
||||
this.webContext.register(config);
|
||||
}
|
||||
@@ -94,8 +103,8 @@ public class MustacheAutoConfigurationTests {
|
||||
|
||||
private void loadWithReactive(Class<?> config) {
|
||||
this.reactiveWebContext = new GenericReactiveWebApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.mustache.prefix=classpath:/mustache-templates/").applyTo(this.reactiveWebContext);
|
||||
TestPropertyValues.of("spring.mustache.prefix=classpath:/mustache-templates/")
|
||||
.applyTo(this.reactiveWebContext);
|
||||
if (config != null) {
|
||||
this.reactiveWebContext.register(config);
|
||||
}
|
||||
@@ -104,7 +113,7 @@ public class MustacheAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import({MustacheAutoConfiguration.class})
|
||||
@Import({ MustacheAutoConfiguration.class })
|
||||
protected static class BaseConfiguration {
|
||||
|
||||
}
|
||||
@@ -113,8 +122,10 @@ public class MustacheAutoConfigurationTests {
|
||||
protected static class CustomCompilerConfiguration {
|
||||
|
||||
@Bean
|
||||
public Mustache.Compiler compiler(Mustache.TemplateLoader mustacheTemplateLoader) {
|
||||
return Mustache.compiler().standardsMode(true).withLoader(mustacheTemplateLoader);
|
||||
public Mustache.Compiler compiler(
|
||||
Mustache.TemplateLoader mustacheTemplateLoader) {
|
||||
return Mustache.compiler().standardsMode(true)
|
||||
.withLoader(mustacheTemplateLoader);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,8 +140,8 @@ public abstract class AbstractJpaAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customJpaProperties() throws Exception {
|
||||
TestPropertyValues.of("spring.jpa.properties.a:b",
|
||||
"spring.jpa.properties.a.b:c", "spring.jpa.properties.c:d").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jpa.properties.a:b", "spring.jpa.properties.a.b:c",
|
||||
"spring.jpa.properties.c:d").applyTo(this.context);
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
LocalContainerEntityManagerFactoryBean bean = this.context
|
||||
@@ -154,8 +154,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void usesManuallyDefinedLocalContainerEntityManagerFactoryBeanIfAvailable() {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false");
|
||||
TestPropertyValues.of("spring.datasource.initialize:false");
|
||||
setupTestConfiguration(
|
||||
TestConfigurationWithLocalContainerEntityManagerFactoryBean.class);
|
||||
this.context.refresh();
|
||||
@@ -167,8 +166,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void usesManuallyDefinedEntityManagerFactoryIfAvailable() {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.initialize:false").applyTo(this.context);
|
||||
setupTestConfiguration(TestConfigurationWithEntityManagerFactory.class);
|
||||
this.context.refresh();
|
||||
EntityManagerFactory factoryBean = this.context
|
||||
|
||||
@@ -63,11 +63,13 @@ public class CustomHibernateJpaAutoConfigurationTests {
|
||||
public void testDefaultDdlAutoForMySql() throws Exception {
|
||||
// Set up environment so we get a MySQL database but don't require server to be
|
||||
// running...
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.type:" + org.apache.tomcat.jdbc.pool.DataSource.class.getName(),
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.type:"
|
||||
+ org.apache.tomcat.jdbc.pool.DataSource.class.getName(),
|
||||
"spring.datasource.database:mysql",
|
||||
"spring.datasource.url:jdbc:mysql://localhost/nonexistent",
|
||||
"spring.datasource.initialize:false", "spring.jpa.database:MYSQL").applyTo(this.context);
|
||||
"spring.datasource.initialize:false", "spring.jpa.database:MYSQL")
|
||||
.applyTo(this.context);
|
||||
this.context.register(TestConfiguration.class, DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class);
|
||||
@@ -82,8 +84,7 @@ public class CustomHibernateJpaAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultDdlAutoForEmbedded() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false");
|
||||
TestPropertyValues.of("spring.datasource.initialize:false");
|
||||
this.context.register(TestConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
@@ -98,8 +99,8 @@ public class CustomHibernateJpaAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testNamingStrategyDelegatorTakesPrecedence() {
|
||||
TestPropertyValues.of(
|
||||
"spring.jpa.properties.hibernate.ejb.naming_strategy_delegator:"
|
||||
TestPropertyValues
|
||||
.of("spring.jpa.properties.hibernate.ejb.naming_strategy_delegator:"
|
||||
+ "org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator");
|
||||
this.context.register(TestConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
@@ -114,8 +115,7 @@ public class CustomHibernateJpaAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultDatabaseForH2() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.url:jdbc:h2:mem:testdb",
|
||||
TestPropertyValues.of("spring.datasource.url:jdbc:h2:mem:testdb",
|
||||
"spring.datasource.initialize:false").applyTo(this.context);
|
||||
this.context.register(TestConfiguration.class, DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -64,10 +64,11 @@ public class HibernateJpaAutoConfigurationTests
|
||||
|
||||
@Test
|
||||
public void testDataScriptWithMissingDdl() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.data:classpath:/city.sql",
|
||||
// Missing:
|
||||
"spring.datasource.schema:classpath:/ddl.sql").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.data:classpath:/city.sql",
|
||||
// Missing:
|
||||
"spring.datasource.schema:classpath:/ddl.sql")
|
||||
.applyTo(this.context);
|
||||
setupTestConfiguration();
|
||||
this.thrown.expectMessage("ddl.sql");
|
||||
this.thrown.expectMessage("spring.datasource.schema");
|
||||
@@ -79,8 +80,8 @@ public class HibernateJpaAutoConfigurationTests
|
||||
// and Hibernate hasn't initialized yet at that point
|
||||
@Test(expected = BeanCreationException.class)
|
||||
public void testDataScript() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.data:classpath:/city.sql").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.datasource.data:classpath:/city.sql")
|
||||
.applyTo(this.context);
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
assertThat(new JdbcTemplate(this.context.getBean(DataSource.class))
|
||||
@@ -89,8 +90,7 @@ public class HibernateJpaAutoConfigurationTests
|
||||
|
||||
@Test
|
||||
public void testFlywayPlusValidation() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false",
|
||||
TestPropertyValues.of("spring.datasource.initialize:false",
|
||||
"flyway.locations:classpath:db/city",
|
||||
"spring.jpa.hibernate.ddl-auto:validate").applyTo(this.context);
|
||||
setupTestConfiguration();
|
||||
@@ -100,8 +100,7 @@ public class HibernateJpaAutoConfigurationTests
|
||||
|
||||
@Test
|
||||
public void testLiquibasePlusValidation() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false",
|
||||
TestPropertyValues.of("spring.datasource.initialize:false",
|
||||
"liquibase.changeLog:classpath:db/changelog/db.changelog-city.yaml",
|
||||
"spring.jpa.hibernate.ddl-auto:validate").applyTo(this.context);
|
||||
setupTestConfiguration();
|
||||
@@ -123,9 +122,8 @@ public class HibernateJpaAutoConfigurationTests
|
||||
|
||||
@Test
|
||||
public void testCustomJtaPlatform() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.jpa.properties.hibernate.transaction.jta.platform:"
|
||||
+ TestJtaPlatform.class.getName()).applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jpa.properties.hibernate.transaction.jta.platform:"
|
||||
+ TestJtaPlatform.class.getName()).applyTo(this.context);
|
||||
this.context.register(JtaAutoConfiguration.class);
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
@@ -138,9 +136,10 @@ public class HibernateJpaAutoConfigurationTests
|
||||
|
||||
@Test
|
||||
public void testCustomJpaTransactionManagerUsingProperties() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true")
|
||||
.applyTo(this.context);
|
||||
setupTestConfiguration();
|
||||
this.context.refresh();
|
||||
JpaTransactionManager transactionManager = this.context
|
||||
|
||||
@@ -105,8 +105,8 @@ public class QuartzAutoConfigurationTests {
|
||||
@Test
|
||||
public void withDataSource() throws Exception {
|
||||
load(new Class<?>[] { QuartzJobsConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
DataSourceTransactionManagerAutoConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class,
|
||||
DataSourceTransactionManagerAutoConfiguration.class },
|
||||
"spring.quartz.job-store-type=jdbc",
|
||||
"spring.quartz.jdbc.initialize-schema=true");
|
||||
testWithDataSource();
|
||||
@@ -115,7 +115,7 @@ public class QuartzAutoConfigurationTests {
|
||||
@Test
|
||||
public void withDataSourceNoTransactionManager() throws Exception {
|
||||
load(new Class<?>[] { QuartzJobsConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
EmbeddedDataSourceConfiguration.class },
|
||||
"spring.quartz.job-store-type=jdbc",
|
||||
"spring.quartz.jdbc.initialize-schema=true");
|
||||
testWithDataSource();
|
||||
@@ -130,8 +130,8 @@ public class QuartzAutoConfigurationTests {
|
||||
this.context.getBean(DataSource.class));
|
||||
assertThat(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM QRTZ_JOB_DETAILS",
|
||||
Integer.class)).isEqualTo(2);
|
||||
assertThat(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM QRTZ_SIMPLE_TRIGGERS",
|
||||
Integer.class)).isEqualTo(0);
|
||||
assertThat(jdbcTemplate.queryForObject(
|
||||
"SELECT COUNT(*) FROM QRTZ_SIMPLE_TRIGGERS", Integer.class)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -222,8 +222,7 @@ public class QuartzAutoConfigurationTests {
|
||||
@Bean
|
||||
public JobDetail fooJob() {
|
||||
return JobBuilder.newJob().ofType(FooJob.class).withIdentity("fooJob")
|
||||
.usingJobData("jobDataKey", "jobDataValue")
|
||||
.storeDurably().build();
|
||||
.usingJobData("jobDataKey", "jobDataValue").storeDurably().build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -113,7 +113,8 @@ public class SecurityAutoConfigurationTests {
|
||||
SecurityFilterAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
customContext.refresh();
|
||||
assertThat(customContext.containsBean("securityFilterChainRegistration")).isFalse();
|
||||
assertThat(customContext.containsBean("securityFilterChainRegistration"))
|
||||
.isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,10 +278,8 @@ public class SecurityAutoConfigurationTests {
|
||||
public void testJpaCoexistsHappily() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.initialize:false");
|
||||
TestPropertyValues.of("spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
|
||||
TestPropertyValues.of("spring.datasource.initialize:false");
|
||||
this.context.register(EntityConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
|
||||
@@ -370,8 +369,8 @@ public class SecurityAutoConfigurationTests {
|
||||
this.context.register(SecurityAutoConfiguration.class,
|
||||
SecurityFilterAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"security.filter-dispatcher-types:INCLUDE,ERROR").applyTo(this.context);
|
||||
TestPropertyValues.of("security.filter-dispatcher-types:INCLUDE,ERROR")
|
||||
.applyTo(this.context);
|
||||
this.context.refresh();
|
||||
DelegatingFilterProxyRegistrationBean bean = this.context.getBean(
|
||||
"securityFilterChainRegistration",
|
||||
|
||||
@@ -59,8 +59,8 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
|
||||
@Test
|
||||
public void testSecurityFilterDoesNotCauseEarlyInitialization() throws Exception {
|
||||
try (AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext()) {
|
||||
TestPropertyValues.of("server.port:0",
|
||||
"security.user.password:password").applyTo(context);
|
||||
TestPropertyValues.of("server.port:0", "security.user.password:password")
|
||||
.applyTo(context);
|
||||
context.register(Config.class);
|
||||
context.refresh();
|
||||
int port = context.getWebServer().getPort();
|
||||
|
||||
@@ -183,12 +183,13 @@ public class OAuth2AutoConfigurationTests {
|
||||
@Test
|
||||
public void testEnvironmentalOverrides() {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.client.clientId:myclientid",
|
||||
"security.oauth2.client.clientSecret:mysecret",
|
||||
"security.oauth2.client.autoApproveScopes:read,write",
|
||||
"security.oauth2.client.accessTokenValiditySeconds:40",
|
||||
"security.oauth2.client.refreshTokenValiditySeconds:80").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("security.oauth2.client.clientId:myclientid",
|
||||
"security.oauth2.client.clientSecret:mysecret",
|
||||
"security.oauth2.client.autoApproveScopes:read,write",
|
||||
"security.oauth2.client.accessTokenValiditySeconds:40",
|
||||
"security.oauth2.client.refreshTokenValiditySeconds:80")
|
||||
.applyTo(this.context);
|
||||
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
||||
MinimalSecureWebApplication.class);
|
||||
this.context.refresh();
|
||||
@@ -230,9 +231,10 @@ public class OAuth2AutoConfigurationTests {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
this.context.register(TestSecurityConfiguration.class,
|
||||
MinimalSecureWebApplication.class);
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.client.clientId=client",
|
||||
"security.oauth2.client.grantType=client_credentials").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("security.oauth2.client.clientId=client",
|
||||
"security.oauth2.client.grantType=client_credentials")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.refresh();
|
||||
OAuth2ClientContext bean = this.context.getBean(OAuth2ClientContext.class);
|
||||
@@ -246,9 +248,10 @@ public class OAuth2AutoConfigurationTests {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
this.context.register(ClientConfiguration.class,
|
||||
MinimalSecureWebApplication.class);
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.client.clientId=client",
|
||||
"security.oauth2.client.grantType=client_credentials").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("security.oauth2.client.clientId=client",
|
||||
"security.oauth2.client.grantType=client_credentials")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.refresh();
|
||||
// The primary context is fine (not session scoped):
|
||||
@@ -267,8 +270,7 @@ public class OAuth2AutoConfigurationTests {
|
||||
public void testClientIsNotAuthCode() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.register(MinimalSecureNonWebApplication.class);
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.client.clientId=client").applyTo(context);
|
||||
TestPropertyValues.of("security.oauth2.client.clientId=client").applyTo(context);
|
||||
context.refresh();
|
||||
assertThat(countBeans(context, ClientCredentialsResourceDetails.class))
|
||||
.isEqualTo(1);
|
||||
@@ -280,8 +282,8 @@ public class OAuth2AutoConfigurationTests {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
this.context.register(ResourceServerConfiguration.class,
|
||||
MinimalSecureWebApplication.class);
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.jwt.keyValue:DEADBEEF").applyTo(this.context);
|
||||
TestPropertyValues.of("security.oauth2.resource.jwt.keyValue:DEADBEEF")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.refresh();
|
||||
assertThat(countBeans(RESOURCE_SERVER_CONFIG)).isEqualTo(1);
|
||||
@@ -306,8 +308,8 @@ public class OAuth2AutoConfigurationTests {
|
||||
@Test
|
||||
public void testAuthorizationServerOverride() {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resourceId:resource-id").applyTo(this.context);
|
||||
TestPropertyValues.of("security.oauth2.resourceId:resource-id")
|
||||
.applyTo(this.context);
|
||||
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
||||
CustomAuthorizationServer.class, MinimalSecureWebApplication.class);
|
||||
this.context.refresh();
|
||||
@@ -396,8 +398,9 @@ public class OAuth2AutoConfigurationTests {
|
||||
public void resourceServerConditionWhenJwkConfigurationPresentShouldMatch()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.jwk.key-set-uri:http://my-auth-server/token_keys").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("security.oauth2.resource.jwk.key-set-uri:http://my-auth-server/token_keys")
|
||||
.applyTo(this.context);
|
||||
this.context.register(ResourceServerConfiguration.class,
|
||||
MinimalSecureWebApplication.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -55,8 +55,7 @@ public class MultipleResourceServerConfigurationTests {
|
||||
public void orderIsUnchangedWhenThereAreMultipleResourceServerConfigurations() {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(DoubleResourceConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.tokenInfoUri:http://example.com",
|
||||
TestPropertyValues.of("security.oauth2.resource.tokenInfoUri:http://example.com",
|
||||
"security.oauth2.client.clientId=acme").applyTo(this.context);
|
||||
this.context.refresh();
|
||||
assertThat(this.context
|
||||
|
||||
@@ -99,8 +99,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void useRemoteTokenServices() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.tokenInfoUri:http://example.com").applyTo(this.environment);
|
||||
TestPropertyValues.of("security.oauth2.resource.tokenInfoUri:http://example.com")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
RemoteTokenServices services = this.context.getBean(RemoteTokenServices.class);
|
||||
@@ -109,8 +109,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void switchToUserInfo() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.userInfoUri:http://example.com").applyTo(this.environment);
|
||||
TestPropertyValues.of("security.oauth2.resource.userInfoUri:http://example.com")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
UserInfoTokenServices services = this.context
|
||||
@@ -120,8 +120,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void userInfoWithAuthorities() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.userInfoUri:http://example.com").applyTo(this.environment);
|
||||
TestPropertyValues.of("security.oauth2.resource.userInfoUri:http://example.com")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(AuthoritiesConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
UserInfoTokenServices services = this.context
|
||||
@@ -133,8 +133,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void userInfoWithPrincipal() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.userInfoUri:http://example.com").applyTo(this.environment);
|
||||
TestPropertyValues.of("security.oauth2.resource.userInfoUri:http://example.com")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(PrincipalConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
UserInfoTokenServices services = this.context
|
||||
@@ -146,8 +146,7 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void userInfoWithClient() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.client.client-id=acme",
|
||||
TestPropertyValues.of("security.oauth2.client.client-id=acme",
|
||||
"security.oauth2.resource.userInfoUri:http://example.com",
|
||||
"server.port=-1", "debug=true").applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(ResourceNoClientConfiguration.class)
|
||||
@@ -159,10 +158,11 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void preferUserInfo() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.userInfoUri:http://example.com",
|
||||
"security.oauth2.resource.tokenInfoUri:http://example.com",
|
||||
"security.oauth2.resource.preferTokenInfo:false").applyTo(this.environment);
|
||||
TestPropertyValues
|
||||
.of("security.oauth2.resource.userInfoUri:http://example.com",
|
||||
"security.oauth2.resource.tokenInfoUri:http://example.com",
|
||||
"security.oauth2.resource.preferTokenInfo:false")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
UserInfoTokenServices services = this.context
|
||||
@@ -172,10 +172,11 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void userInfoWithCustomizer() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.userInfoUri:http://example.com",
|
||||
"security.oauth2.resource.tokenInfoUri:http://example.com",
|
||||
"security.oauth2.resource.preferTokenInfo:false").applyTo(this.environment);
|
||||
TestPropertyValues
|
||||
.of("security.oauth2.resource.userInfoUri:http://example.com",
|
||||
"security.oauth2.resource.tokenInfoUri:http://example.com",
|
||||
"security.oauth2.resource.preferTokenInfo:false")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class,
|
||||
Customizer.class).environment(this.environment)
|
||||
.web(WebApplicationType.NONE).run();
|
||||
@@ -186,8 +187,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void switchToJwt() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.jwt.keyValue=FOOBAR").applyTo(this.environment);
|
||||
TestPropertyValues.of("security.oauth2.resource.jwt.keyValue=FOOBAR")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
DefaultTokenServices services = this.context.getBean(DefaultTokenServices.class);
|
||||
@@ -198,8 +199,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void asymmetricJwt() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY).applyTo(this.environment);
|
||||
TestPropertyValues.of("security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY)
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
DefaultTokenServices services = this.context.getBean(DefaultTokenServices.class);
|
||||
@@ -208,8 +209,9 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void jwkConfiguration() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys").applyTo(this.environment);
|
||||
TestPropertyValues
|
||||
.of("security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
DefaultTokenServices services = this.context.getBean(DefaultTokenServices.class);
|
||||
@@ -220,10 +222,11 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void springSocialUserInfo() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.userInfoUri:http://example.com",
|
||||
"spring.social.facebook.app-id=foo",
|
||||
"spring.social.facebook.app-secret=bar").applyTo(this.environment);
|
||||
TestPropertyValues
|
||||
.of("security.oauth2.resource.userInfoUri:http://example.com",
|
||||
"spring.social.facebook.app-id=foo",
|
||||
"spring.social.facebook.app-secret=bar")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(SocialResourceConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.SERVLET).run();
|
||||
ConnectionFactoryLocator connectionFactory = this.context
|
||||
@@ -236,8 +239,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customUserInfoRestTemplateFactory() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.userInfoUri:http://example.com").applyTo(this.environment);
|
||||
TestPropertyValues.of("security.oauth2.resource.userInfoUri:http://example.com")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(
|
||||
CustomUserInfoRestTemplateFactory.class, ResourceConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
@@ -249,8 +252,9 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void jwtAccessTokenConverterIsConfiguredWhenKeyUriIsProvided() {
|
||||
TestPropertyValues.of(
|
||||
"security.oauth2.resource.jwt.key-uri=http://localhost:12345/banana").applyTo(this.environment);
|
||||
TestPropertyValues
|
||||
.of("security.oauth2.resource.jwt.key-uri=http://localhost:12345/banana")
|
||||
.applyTo(this.environment);
|
||||
this.context = new SpringApplicationBuilder(ResourceConfiguration.class,
|
||||
JwtAccessTokenConverterRestTemplateCustomizerConfiguration.class)
|
||||
.environment(this.environment).web(WebApplicationType.NONE).run();
|
||||
|
||||
@@ -35,10 +35,9 @@ public class FacebookAutoConfigurationTests extends AbstractSocialAutoConfigurat
|
||||
@Test
|
||||
public void expectedSocialBeansCreated() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.social.facebook.appId:12345").applyTo(this.context);
|
||||
TestPropertyValues.of(
|
||||
"spring.social.facebook.appSecret:secret").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.social.facebook.appId:12345").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.social.facebook.appSecret:secret")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.register(FacebookAutoConfiguration.class);
|
||||
this.context.register(SocialWebAutoConfiguration.class);
|
||||
|
||||
@@ -35,10 +35,9 @@ public class LinkedInAutoConfigurationTests extends AbstractSocialAutoConfigurat
|
||||
@Test
|
||||
public void expectedSocialBeansCreated() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.social.linkedin.appId:12345").applyTo(this.context);
|
||||
TestPropertyValues.of(
|
||||
"spring.social.linkedin.appSecret:secret").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.social.linkedin.appId:12345").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.social.linkedin.appSecret:secret")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.register(LinkedInAutoConfiguration.class);
|
||||
this.context.register(SocialWebAutoConfiguration.class);
|
||||
|
||||
@@ -35,10 +35,9 @@ public class TwitterAutoConfigurationTests extends AbstractSocialAutoConfigurati
|
||||
@Test
|
||||
public void expectedSocialBeansCreated() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.social.twitter.appId:12345").applyTo(this.context);
|
||||
TestPropertyValues.of(
|
||||
"spring.social.twitter.appSecret:secret").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.social.twitter.appId:12345").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.social.twitter.appSecret:secret")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.register(TwitterAutoConfiguration.class);
|
||||
this.context.register(SocialWebAutoConfiguration.class);
|
||||
|
||||
@@ -148,7 +148,8 @@ public class JtaAutoConfigurationTests {
|
||||
@Test
|
||||
public void customBitronixServerId() throws UnknownHostException {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of("spring.jta.transactionManagerId:custom").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jta.transactionManagerId:custom")
|
||||
.applyTo(this.context);
|
||||
this.context.register(JtaPropertiesConfiguration.class,
|
||||
BitronixJtaConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -160,7 +161,8 @@ public class JtaAutoConfigurationTests {
|
||||
@Test
|
||||
public void defaultAtomikosTransactionManagerName() throws UnknownHostException {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of("spring.jta.logDir:target/transaction-logs").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.jta.logDir:target/transaction-logs")
|
||||
.applyTo(this.context);
|
||||
this.context.register(JtaPropertiesConfiguration.class,
|
||||
AtomikosJtaConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -172,9 +174,10 @@ public class JtaAutoConfigurationTests {
|
||||
@Test
|
||||
public void atomikosConnectionFactoryPoolConfiguration() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.jta.atomikos.connectionfactory.minPoolSize:5",
|
||||
"spring.jta.atomikos.connectionfactory.maxPoolSize:10").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jta.atomikos.connectionfactory.minPoolSize:5",
|
||||
"spring.jta.atomikos.connectionfactory.maxPoolSize:10")
|
||||
.applyTo(this.context);
|
||||
this.context.register(JtaPropertiesConfiguration.class,
|
||||
AtomikosJtaConfiguration.class, PoolConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -187,9 +190,10 @@ public class JtaAutoConfigurationTests {
|
||||
@Test
|
||||
public void bitronixConnectionFactoryPoolConfiguration() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.jta.bitronix.connectionfactory.minPoolSize:5",
|
||||
"spring.jta.bitronix.connectionfactory.maxPoolSize:10").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jta.bitronix.connectionfactory.minPoolSize:5",
|
||||
"spring.jta.bitronix.connectionfactory.maxPoolSize:10")
|
||||
.applyTo(this.context);
|
||||
this.context.register(JtaPropertiesConfiguration.class,
|
||||
BitronixJtaConfiguration.class, PoolConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -202,9 +206,10 @@ public class JtaAutoConfigurationTests {
|
||||
@Test
|
||||
public void atomikosDataSourcePoolConfiguration() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.jta.atomikos.datasource.minPoolSize:5",
|
||||
"spring.jta.atomikos.datasource.maxPoolSize:10").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jta.atomikos.datasource.minPoolSize:5",
|
||||
"spring.jta.atomikos.datasource.maxPoolSize:10")
|
||||
.applyTo(this.context);
|
||||
this.context.register(JtaPropertiesConfiguration.class,
|
||||
AtomikosJtaConfiguration.class, PoolConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -217,9 +222,10 @@ public class JtaAutoConfigurationTests {
|
||||
@Test
|
||||
public void bitronixDataSourcePoolConfiguration() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.jta.bitronix.datasource.minPoolSize:5",
|
||||
"spring.jta.bitronix.datasource.maxPoolSize:10").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.jta.bitronix.datasource.minPoolSize:5",
|
||||
"spring.jta.bitronix.datasource.maxPoolSize:10")
|
||||
.applyTo(this.context);
|
||||
this.context.register(JtaPropertiesConfiguration.class,
|
||||
BitronixJtaConfiguration.class, PoolConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -232,9 +238,10 @@ public class JtaAutoConfigurationTests {
|
||||
@Test
|
||||
public void atomikosCustomizeJtaTransactionManagerUsingProperties() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true")
|
||||
.applyTo(this.context);
|
||||
this.context.register(AtomikosJtaConfiguration.class,
|
||||
TransactionAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -247,9 +254,10 @@ public class JtaAutoConfigurationTests {
|
||||
@Test
|
||||
public void bitronixCustomizeJtaTransactionManagerUsingProperties() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("spring.transaction.default-timeout:30",
|
||||
"spring.transaction.rollback-on-commit-failure:true")
|
||||
.applyTo(this.context);
|
||||
this.context.register(BitronixJtaConfiguration.class,
|
||||
TransactionAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.validation.MapBindingResult;
|
||||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -54,8 +54,7 @@ public class ValidatorAdapterTests {
|
||||
|
||||
@Test
|
||||
public void wrapLocalValidatorFactoryBean() {
|
||||
ValidatorAdapter wrapper = load(
|
||||
LocalValidatorFactoryBeanConfig.class);
|
||||
ValidatorAdapter wrapper = load(LocalValidatorFactoryBeanConfig.class);
|
||||
assertThat(wrapper.supports(SampleData.class)).isTrue();
|
||||
MapBindingResult errors = new MapBindingResult(new HashMap<String, Object>(),
|
||||
"test");
|
||||
|
||||
@@ -174,8 +174,7 @@ public class DispatcherServletAutoConfigurationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(DispatcherServletAutoConfiguration.class);
|
||||
TestPropertyValues.of(
|
||||
"spring.mvc.throw-exception-if-no-handler-found:true",
|
||||
TestPropertyValues.of("spring.mvc.throw-exception-if-no-handler-found:true",
|
||||
"spring.mvc.dispatch-options-request:false",
|
||||
"spring.mvc.dispatch-trace-request:true",
|
||||
"spring.mvc.servlet.load-on-startup=5").applyTo(this.context);
|
||||
|
||||
@@ -85,8 +85,7 @@ public class FilterOrderingIntegrationTests {
|
||||
|
||||
private void load() {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.session.store-type=hash-map").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.session.store-type=hash-map").applyTo(this.context);
|
||||
this.context.register(MockWebServerConfiguration.class,
|
||||
TestRedisConfiguration.class, WebMvcAutoConfiguration.class,
|
||||
SecurityAutoConfiguration.class, SessionAutoConfiguration.class,
|
||||
|
||||
@@ -171,8 +171,8 @@ public class MultipartAutoConfigurationTests {
|
||||
private void testWebServerWithCustomMultipartConfigEnabledSetting(
|
||||
final String propertyValue, int expectedNumberOfMultipartConfigElementBeans) {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.servlet.multipart.enabled=" + propertyValue).applyTo(this.context);
|
||||
TestPropertyValues.of("spring.servlet.multipart.enabled=" + propertyValue)
|
||||
.applyTo(this.context);
|
||||
this.context.register(WebServerWithNoMultipartTomcat.class,
|
||||
BaseConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -194,8 +194,8 @@ public class MultipartAutoConfigurationTests {
|
||||
@Test
|
||||
public void configureResolveLazily() {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.servlet.multipart.resolve-lazily=true").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.servlet.multipart.resolve-lazily=true")
|
||||
.applyTo(this.context);
|
||||
this.context.register(WebServerWithNothing.class, BaseConfiguration.class);
|
||||
this.context.refresh();
|
||||
StandardServletMultipartResolver multipartResolver = this.context
|
||||
|
||||
@@ -122,9 +122,10 @@ public class ServletWebServerFactoryAutoConfigurationTests {
|
||||
@Test
|
||||
public void initParametersAreConfiguredOnTheServletContext() {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"server.servlet.context-parameters.a:alpha",
|
||||
"server.servlet.context-parameters.b:bravo").applyTo(this.context);
|
||||
TestPropertyValues
|
||||
.of("server.servlet.context-parameters.a:alpha",
|
||||
"server.servlet.context-parameters.b:bravo")
|
||||
.applyTo(this.context);
|
||||
this.context.register(BaseConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
|
||||
@@ -415,8 +415,8 @@ public class WebMvcAutoConfigurationTests {
|
||||
@Test
|
||||
public void overrideIgnoreDefaultModelOnRedirect() throws Exception {
|
||||
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of(
|
||||
"spring.mvc.ignore-default-model-on-redirect:false").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.mvc.ignore-default-model-on-redirect:false")
|
||||
.applyTo(this.context);
|
||||
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
@@ -675,7 +675,8 @@ public class WebMvcAutoConfigurationTests {
|
||||
.getBeanNamesForType(javax.validation.Validator.class);
|
||||
String[] springValidatorBeans = this.context.getBeanNamesForType(Validator.class);
|
||||
assertThat(jsrValidatorBeans).containsExactly("defaultValidator");
|
||||
assertThat(springValidatorBeans).containsExactly("defaultValidator", "mvcValidator");
|
||||
assertThat(springValidatorBeans).containsExactly("defaultValidator",
|
||||
"mvcValidator");
|
||||
Validator validator = this.context.getBean("mvcValidator", Validator.class);
|
||||
assertThat(validator).isInstanceOf(ValidatorAdapter.class);
|
||||
Object defaultValidator = this.context.getBean("defaultValidator");
|
||||
@@ -698,7 +699,8 @@ public class WebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void validatorWithConfigurerDoesNotExposeJsr303() {
|
||||
load(MvcJsr303Validator.class, new Class<?>[] { ValidationAutoConfiguration.class });
|
||||
load(MvcJsr303Validator.class,
|
||||
new Class<?>[] { ValidationAutoConfiguration.class });
|
||||
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).isEmpty();
|
||||
assertThat(this.context.getBeansOfType(javax.validation.Validator.class))
|
||||
.isEmpty();
|
||||
@@ -717,7 +719,8 @@ public class WebMvcAutoConfigurationTests {
|
||||
assertThat(this.context.getBeansOfType(javax.validation.Validator.class))
|
||||
.hasSize(1);
|
||||
String[] springValidatorBeans = this.context.getBeanNamesForType(Validator.class);
|
||||
assertThat(springValidatorBeans).containsExactly("defaultValidator", "mvcValidator");
|
||||
assertThat(springValidatorBeans).containsExactly("defaultValidator",
|
||||
"mvcValidator");
|
||||
assertThat(this.context.getBean("mvcValidator"))
|
||||
.isSameAs(this.context.getBean(MvcValidator.class).validator);
|
||||
// Primary Spring validator is the auto-configured one as the MVC one has been
|
||||
@@ -733,13 +736,12 @@ public class WebMvcAutoConfigurationTests {
|
||||
.getBeanNamesForType(javax.validation.Validator.class);
|
||||
String[] springValidatorBeans = this.context.getBeanNamesForType(Validator.class);
|
||||
assertThat(jsrValidatorBeans).containsExactly("defaultValidator");
|
||||
assertThat(springValidatorBeans).containsExactly(
|
||||
"customSpringValidator", "defaultValidator", "mvcValidator");
|
||||
assertThat(springValidatorBeans).containsExactly("customSpringValidator",
|
||||
"defaultValidator", "mvcValidator");
|
||||
Validator validator = this.context.getBean("mvcValidator", Validator.class);
|
||||
assertThat(validator).isInstanceOf(ValidatorAdapter.class);
|
||||
Object defaultValidator = this.context.getBean("defaultValidator");
|
||||
assertThat(((ValidatorAdapter) validator).getTarget())
|
||||
.isSameAs(defaultValidator);
|
||||
assertThat(((ValidatorAdapter) validator).getTarget()).isSameAs(defaultValidator);
|
||||
// Primary Spring validator is the one used by MVC behind the scenes
|
||||
assertThat(this.context.getBean(Validator.class)).isEqualTo(defaultValidator);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user