pull/11378/head
Phillip Webb 7 years ago
parent e29ce3f70b
commit 6a55623910

@ -87,7 +87,7 @@ public class AuditEvent implements Serializable {
Assert.notNull(timestamp, "Timestamp must not be null"); Assert.notNull(timestamp, "Timestamp must not be null");
Assert.notNull(type, "Type must not be null"); Assert.notNull(type, "Type must not be null");
this.timestamp = timestamp; this.timestamp = timestamp;
this.principal = principal != null ? principal : ""; this.principal = (principal != null ? principal : "");
this.type = type; this.type = type;
this.data = Collections.unmodifiableMap(data); this.data = Collections.unmodifiableMap(data);
} }

@ -69,9 +69,10 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source; EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
Map<String, Object> properties = new LinkedHashMap<String, Object>(); Map<String, Object> properties = new LinkedHashMap<String, Object>();
for (String name : enumerable.getPropertyNames()) { for (String name : enumerable.getPropertyNames()) {
Object property = source.getProperty(name); Object resolved = source.getProperty(name);
Object resolved = property instanceof String if (resolved instanceof String) {
? resolver.resolvePlaceholders((String) property) : property; resolved = resolver.resolvePlaceholders((String) resolved);
}
properties.put(name, sanitize(name, resolved)); properties.put(name, sanitize(name, resolved));
} }
properties = postProcessSourceProperties(sourceName, properties); properties = postProcessSourceProperties(sourceName, properties);

@ -183,7 +183,8 @@ public class EndpointWebMvcHypermediaManagementContextConfigurationTests {
static class DocsConfiguration { static class DocsConfiguration {
@Bean @Bean
public DocsMvcEndpoint testDocsMvcEndpoint(ManagementServletContext managementServletContext) { public DocsMvcEndpoint testDocsMvcEndpoint(
ManagementServletContext managementServletContext) {
return new TestDocsMvcEndpoint(managementServletContext); return new TestDocsMvcEndpoint(managementServletContext);
} }
@ -193,7 +194,8 @@ public class EndpointWebMvcHypermediaManagementContextConfigurationTests {
static class HalJsonConfiguration { static class HalJsonConfiguration {
@Bean @Bean
public HalJsonMvcEndpoint testHalJsonMvcEndpoint(ManagementServletContext managementServletContext) { public HalJsonMvcEndpoint testHalJsonMvcEndpoint(
ManagementServletContext managementServletContext) {
return new TestHalJsonMvcEndpoint(managementServletContext); return new TestHalJsonMvcEndpoint(managementServletContext);
} }

@ -111,13 +111,15 @@ public class EndpointWebMvcManagementContextConfigurationTests {
public void envMvcEndpointIsConditionalOnMissingBean() throws Exception { public void envMvcEndpointIsConditionalOnMissingBean() throws Exception {
this.context.register(EnvConfiguration.class, TestEndpointConfiguration.class); this.context.register(EnvConfiguration.class, TestEndpointConfiguration.class);
this.context.refresh(); this.context.refresh();
EnvironmentMvcEndpoint mvcEndpoint = this.context.getBean(EnvironmentMvcEndpoint.class); EnvironmentMvcEndpoint mvcEndpoint = this.context
.getBean(EnvironmentMvcEndpoint.class);
assertThat(mvcEndpoint).isInstanceOf(TestEnvMvcEndpoint.class); assertThat(mvcEndpoint).isInstanceOf(TestEnvMvcEndpoint.class);
} }
@Test @Test
public void metricsMvcEndpointIsConditionalOnMissingBean() throws Exception { public void metricsMvcEndpointIsConditionalOnMissingBean() throws Exception {
this.context.register(MetricsConfiguration.class, TestEndpointConfiguration.class); this.context.register(MetricsConfiguration.class,
TestEndpointConfiguration.class);
this.context.refresh(); this.context.refresh();
MetricsMvcEndpoint mvcEndpoint = this.context.getBean(MetricsMvcEndpoint.class); MetricsMvcEndpoint mvcEndpoint = this.context.getBean(MetricsMvcEndpoint.class);
assertThat(mvcEndpoint).isInstanceOf(TestMetricsMvcEndpoint.class); assertThat(mvcEndpoint).isInstanceOf(TestMetricsMvcEndpoint.class);
@ -125,7 +127,8 @@ public class EndpointWebMvcManagementContextConfigurationTests {
@Test @Test
public void logFileMvcEndpointIsConditionalOnMissingBean() throws Exception { public void logFileMvcEndpointIsConditionalOnMissingBean() throws Exception {
this.context.register(LogFileConfiguration.class, TestEndpointConfiguration.class); this.context.register(LogFileConfiguration.class,
TestEndpointConfiguration.class);
this.context.refresh(); this.context.refresh();
LogFileMvcEndpoint mvcEndpoint = this.context.getBean(LogFileMvcEndpoint.class); LogFileMvcEndpoint mvcEndpoint = this.context.getBean(LogFileMvcEndpoint.class);
assertThat(mvcEndpoint).isInstanceOf(TestLogFileMvcEndpoint.class); assertThat(mvcEndpoint).isInstanceOf(TestLogFileMvcEndpoint.class);
@ -133,7 +136,8 @@ public class EndpointWebMvcManagementContextConfigurationTests {
@Test @Test
public void shutdownEndpointIsConditionalOnMissingBean() throws Exception { public void shutdownEndpointIsConditionalOnMissingBean() throws Exception {
this.context.register(ShutdownConfiguration.class, TestEndpointConfiguration.class); this.context.register(ShutdownConfiguration.class,
TestEndpointConfiguration.class);
this.context.refresh(); this.context.refresh();
ShutdownMvcEndpoint mvcEndpoint = this.context.getBean(ShutdownMvcEndpoint.class); ShutdownMvcEndpoint mvcEndpoint = this.context.getBean(ShutdownMvcEndpoint.class);
assertThat(mvcEndpoint).isInstanceOf(TestShutdownMvcEndpoint.class); assertThat(mvcEndpoint).isInstanceOf(TestShutdownMvcEndpoint.class);
@ -141,15 +145,18 @@ public class EndpointWebMvcManagementContextConfigurationTests {
@Test @Test
public void auditEventsMvcEndpointIsConditionalOnMissingBean() throws Exception { public void auditEventsMvcEndpointIsConditionalOnMissingBean() throws Exception {
this.context.register(AuditEventsConfiguration.class, TestEndpointConfiguration.class); this.context.register(AuditEventsConfiguration.class,
TestEndpointConfiguration.class);
this.context.refresh(); this.context.refresh();
AuditEventsMvcEndpoint mvcEndpoint = this.context.getBean(AuditEventsMvcEndpoint.class); AuditEventsMvcEndpoint mvcEndpoint = this.context
.getBean(AuditEventsMvcEndpoint.class);
assertThat(mvcEndpoint).isInstanceOf(TestAuditEventsMvcEndpoint.class); assertThat(mvcEndpoint).isInstanceOf(TestAuditEventsMvcEndpoint.class);
} }
@Test @Test
public void loggersMvcEndpointIsConditionalOnMissingBean() throws Exception { public void loggersMvcEndpointIsConditionalOnMissingBean() throws Exception {
this.context.register(LoggersConfiguration.class, TestEndpointConfiguration.class); this.context.register(LoggersConfiguration.class,
TestEndpointConfiguration.class);
this.context.refresh(); this.context.refresh();
LoggersMvcEndpoint mvcEndpoint = this.context.getBean(LoggersMvcEndpoint.class); LoggersMvcEndpoint mvcEndpoint = this.context.getBean(LoggersMvcEndpoint.class);
assertThat(mvcEndpoint).isInstanceOf(TestLoggersMvcEndpoint.class); assertThat(mvcEndpoint).isInstanceOf(TestLoggersMvcEndpoint.class);
@ -157,7 +164,8 @@ public class EndpointWebMvcManagementContextConfigurationTests {
@Test @Test
public void heapdumpMvcEndpointIsConditionalOnMissingBean() throws Exception { public void heapdumpMvcEndpointIsConditionalOnMissingBean() throws Exception {
this.context.register(HeapdumpConfiguration.class, TestEndpointConfiguration.class); this.context.register(HeapdumpConfiguration.class,
TestEndpointConfiguration.class);
this.context.refresh(); this.context.refresh();
HeapdumpMvcEndpoint mvcEndpoint = this.context.getBean(HeapdumpMvcEndpoint.class); HeapdumpMvcEndpoint mvcEndpoint = this.context.getBean(HeapdumpMvcEndpoint.class);
assertThat(mvcEndpoint).isInstanceOf(TestHeapdumpMvcEndpoint.class); assertThat(mvcEndpoint).isInstanceOf(TestHeapdumpMvcEndpoint.class);
@ -171,11 +179,10 @@ public class EndpointWebMvcManagementContextConfigurationTests {
@Configuration @Configuration
@ImportAutoConfiguration({ SecurityAutoConfiguration.class, @ImportAutoConfiguration({ SecurityAutoConfiguration.class,
WebMvcAutoConfiguration.class, JacksonAutoConfiguration.class, WebMvcAutoConfiguration.class, JacksonAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class, ManagementServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, WebClientAutoConfiguration.class,
WebClientAutoConfiguration.class,
EndpointWebMvcManagementContextConfiguration.class }) EndpointWebMvcManagementContextConfiguration.class })
static class TestEndpointConfiguration { static class TestEndpointConfiguration {
@ -194,7 +201,8 @@ public class EndpointWebMvcManagementContextConfigurationTests {
static class EnvConfiguration { static class EnvConfiguration {
@Bean @Bean
public EnvironmentMvcEndpoint testEnvironmentMvcEndpoint(EnvironmentEndpoint endpoint) { public EnvironmentMvcEndpoint testEnvironmentMvcEndpoint(
EnvironmentEndpoint endpoint) {
return new TestEnvMvcEndpoint(endpoint); return new TestEnvMvcEndpoint(endpoint);
} }
@ -245,7 +253,8 @@ public class EndpointWebMvcManagementContextConfigurationTests {
} }
@Bean @Bean
public AuditEventsMvcEndpoint testAuditEventsMvcEndpoint(AuditEventRepository repository) { public AuditEventsMvcEndpoint testAuditEventsMvcEndpoint(
AuditEventRepository repository) {
return new TestAuditEventsMvcEndpoint(repository); return new TestAuditEventsMvcEndpoint(repository);
} }

@ -106,7 +106,7 @@ public enum EmbeddedDatabaseConnection {
*/ */
public String getUrl(String databaseName) { public String getUrl(String databaseName) {
Assert.hasText(databaseName, "DatabaseName must not be null."); Assert.hasText(databaseName, "DatabaseName must not be null.");
return this.url != null ? String.format(this.url, databaseName) : null; return (this.url != null ? String.format(this.url, databaseName) : null);
} }
/** /**

@ -68,7 +68,7 @@ public class ElasticsearchDataAutoConfigurationTests {
"spring.data.elasticsearch.properties.path.logs:target/logs"); "spring.data.elasticsearch.properties.path.logs:target/logs");
assertThat( assertThat(
this.context.getBeanNamesForType(SimpleElasticsearchMappingContext.class)) this.context.getBeanNamesForType(SimpleElasticsearchMappingContext.class))
.hasSize(1); .hasSize(1);
} }
@Test @Test
@ -80,13 +80,13 @@ public class ElasticsearchDataAutoConfigurationTests {
} }
private void load(String... environment) { private void load(String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(ctx, environment); EnvironmentTestUtils.addEnvironment(context, environment);
ctx.register(PropertyPlaceholderAutoConfiguration.class, context.register(PropertyPlaceholderAutoConfiguration.class,
ElasticsearchAutoConfiguration.class, ElasticsearchAutoConfiguration.class,
ElasticsearchDataAutoConfiguration.class); ElasticsearchDataAutoConfiguration.class);
ctx.refresh(); context.refresh();
this.context = ctx; this.context = context;
} }
} }

@ -65,8 +65,8 @@ public class DataSourcePropertiesTests {
@Test @Test
public void determineUrlWithNoEmbeddedSupport() throws Exception { public void determineUrlWithNoEmbeddedSupport() throws Exception {
DataSourceProperties properties = new DataSourceProperties(); DataSourceProperties properties = new DataSourceProperties();
properties.setBeanClassLoader(new HidePackagesClassLoader("org.h2", properties.setBeanClassLoader(
"org.apache.derby", "org.hsqldb")); new HidePackagesClassLoader("org.h2", "org.apache.derby", "org.hsqldb"));
properties.afterPropertiesSet(); properties.afterPropertiesSet();
this.thrown.expect(DataSourceProperties.DataSourceBeanCreationException.class); this.thrown.expect(DataSourceProperties.DataSourceBeanCreationException.class);
this.thrown.expectMessage("Cannot determine embedded database url"); this.thrown.expectMessage("Cannot determine embedded database url");

@ -55,7 +55,6 @@ public final class JsonContent<T> implements AssertProvider<JsonContentAssert> {
/** /**
* Use AssertJ's {@link org.assertj.core.api.Assertions#assertThat assertThat} * Use AssertJ's {@link org.assertj.core.api.Assertions#assertThat assertThat}
* instead. * instead.
*
* @deprecated in favor of AssertJ's {@link org.assertj.core.api.Assertions#assertThat * @deprecated in favor of AssertJ's {@link org.assertj.core.api.Assertions#assertThat
* assertThat} * assertThat}
*/ */

@ -177,7 +177,7 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
return result; return result;
} }
private Object processValue(Object value) { private Object processValue(Object value) {
if (value instanceof DeclaredType) { if (value instanceof DeclaredType) {
return getQualifiedName(((DeclaredType) value).asElement()); return getQualifiedName(((DeclaredType) value).asElement());
} }

Loading…
Cancel
Save