From e2b15c3f2acd1846111dabcb88cd53d6a9390597 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Fri, 3 May 2019 12:32:06 -0700 Subject: [PATCH] Fix tests See gh-15039 --- .../JmxEndpointIntegrationTests.java | 14 ++++++++++++++ .../WebMvcEndpointExposureIntegrationTests.java | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java index 603a6769d8..8c93f3c688 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java @@ -30,9 +30,12 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfi import org.springframework.boot.actuate.autoconfigure.endpoint.jmx.JmxEndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.trace.http.HttpTraceAutoConfiguration; +import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -50,6 +53,7 @@ public class JmxEndpointIntegrationTests { EndpointAutoConfiguration.class, JmxEndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class, HttpTraceAutoConfiguration.class)) + .withUserConfiguration(HttpTraceRepositoryConfiguration.class) .withPropertyValues("spring.jmx.enabled=true").withConfiguration( AutoConfigurations.of(EndpointAutoConfigurationClasses.ALL)); @@ -138,4 +142,14 @@ public class JmxEndpointIntegrationTests { } + @Configuration(proxyBeanMethods = false) + public static class HttpTraceRepositoryConfiguration { + + @Bean + public InMemoryHttpTraceRepository httpTraceRepository() { + return new InMemoryHttpTraceRepository(); + } + + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java index 3d997d1579..b2a908b26a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java @@ -35,6 +35,7 @@ import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagem import org.springframework.boot.actuate.endpoint.web.EndpointServlet; import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint; import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint; +import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; @@ -45,6 +46,8 @@ import org.springframework.boot.test.context.assertj.AssertableWebApplicationCon import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext; import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.test.web.reactive.server.EntityExchangeResult; @@ -79,7 +82,8 @@ public class WebMvcEndpointExposureIntegrationTests { .withConfiguration( AutoConfigurations.of(EndpointAutoConfigurationClasses.ALL)) .withUserConfiguration(CustomMvcEndpoint.class, - CustomServletEndpoint.class) + CustomServletEndpoint.class, + HttpTraceRepositoryConfiguration.class) .withPropertyValues("server.port:0"); @Test @@ -215,4 +219,14 @@ public class WebMvcEndpointExposureIntegrationTests { } + @Configuration(proxyBeanMethods = false) + public static class HttpTraceRepositoryConfiguration { + + @Bean + public InMemoryHttpTraceRepository httpTraceRepository() { + return new InMemoryHttpTraceRepository(); + } + + } + }