pull/12098/head
Phillip Webb 7 years ago
parent d2039128b5
commit 9e75680e6f

@ -33,9 +33,8 @@ public class WavefrontProperties extends StepRegistryProperties {
/**
* URI to which metrics are published. May represent a Wavefront sidecar or the
* Wavefront API host. This host could also represent an internal proxy set up in your
* environment that forwards metrics data to the Wavefront API host.
*
* If publishing metrics to a Wavefront proxy (as described in
* environment that forwards metrics data to the Wavefront API host. If publishing
* metrics to a Wavefront proxy (as described in
* https://docs.wavefront.com/proxies_installing.html), the host must be in the
* proxy://HOST:PORT format.
*/

@ -38,12 +38,12 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class ServletEndpointManagementContextConfigurationTests {
private WebApplicationContextRunner runner = new WebApplicationContextRunner()
private WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
.withUserConfiguration(TestConfig.class);
@Test
public void contextShouldContainServletEndpointRegistrar() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(ServletEndpointRegistrar.class));
}

@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class JolokiaEndpointAutoConfigurationTests {
private final WebApplicationContextRunner runner = new WebApplicationContextRunner()
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(
ManagementContextAutoConfiguration.class,
ServletManagementContextAutoConfiguration.class,
@ -57,7 +57,7 @@ public class JolokiaEndpointAutoConfigurationTests {
@Test
public void jolokiaServletShouldBeEnabledByDefault() {
this.runner.run((context) -> {
this.contextRunner.run((context) -> {
ExposableServletEndpoint endpoint = getEndpoint(context);
assertThat(endpoint.getRootPath()).isEqualTo("jolokia");
Object servlet = ReflectionTestUtils.getField(endpoint.getEndpointServlet(),
@ -68,7 +68,7 @@ public class JolokiaEndpointAutoConfigurationTests {
@Test
public void jolokiaServletWhenDisabledShouldNotBeDiscovered() {
this.runner.withPropertyValues("management.endpoint.jolokia.enabled=false")
this.contextRunner.withPropertyValues("management.endpoint.jolokia.enabled=false")
.run((context) -> {
Collection<ExposableServletEndpoint> endpoints = context
.getBean(ServletEndpointsSupplier.class).getEndpoints();
@ -78,7 +78,8 @@ public class JolokiaEndpointAutoConfigurationTests {
@Test
public void jolokiaServletWhenHasCustomConfigShouldApplyInitParams() {
this.runner.withPropertyValues("management.endpoint.jolokia.config.debug=true")
this.contextRunner
.withPropertyValues("management.endpoint.jolokia.config.debug=true")
.run((context) -> {
ExposableServletEndpoint endpoint = getEndpoint(context);
assertThat(endpoint.getEndpointServlet()).extracting("initParameters")

@ -52,24 +52,24 @@ import static org.mockito.Mockito.verify;
*/
public class MetricsAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class));
@Test
public void autoConfiguresAClock() {
this.runner.run((context) -> assertThat(context).hasSingleBean(Clock.class));
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(Clock.class));
}
@Test
public void allowsACustomClockToBeUsed() {
this.runner.withUserConfiguration(CustomClockConfiguration.class)
this.contextRunner.withUserConfiguration(CustomClockConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(Clock.class)
.hasBean("customClock"));
}
@Test
public void autoConfiguresACompositeMeterRegistry() {
this.runner.run((context) -> {
this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(CompositeMeterRegistry.class);
assertThat(context.getBean(CompositeMeterRegistry.class).getRegistries())
.isEmpty();
@ -79,7 +79,7 @@ public class MetricsAutoConfigurationTests {
@SuppressWarnings("unchecked")
@Test
public void configuresMeterRegistries() {
this.runner.withUserConfiguration(MeterRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(MeterRegistryConfiguration.class)
.run((context) -> {
MeterRegistry meterRegistry = context.getBean(MeterRegistry.class);
List<MeterFilter> filters = (List<MeterFilter>) ReflectionTestUtils
@ -94,7 +94,7 @@ public class MetricsAutoConfigurationTests {
@Test
public void autoConfiguresJvmMetrics() {
this.runner.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasSingleBean(JvmMemoryMetrics.class)
.hasSingleBean(JvmThreadMetrics.class)
.hasSingleBean(ClassLoaderMetrics.class));
@ -102,7 +102,7 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsJvmMetricsToBeDisabled() {
this.runner.withPropertyValues("management.metrics.binders.jvm.enabled=false")
this.contextRunner.withPropertyValues("management.metrics.binders.jvm.enabled=false")
.run((context) -> assertThat(context).doesNotHaveBean(JvmGcMetrics.class)
.doesNotHaveBean(JvmMemoryMetrics.class)
.doesNotHaveBean(JvmThreadMetrics.class)
@ -111,7 +111,7 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsCustomJvmGcMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomJvmGcMetricsConfiguration.class)
this.contextRunner.withUserConfiguration(CustomJvmGcMetricsConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasBean("customJvmGcMetrics")
.hasSingleBean(JvmMemoryMetrics.class)
@ -121,7 +121,7 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsCustomJvmMemoryMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomJvmMemoryMetricsConfiguration.class)
this.contextRunner.withUserConfiguration(CustomJvmMemoryMetricsConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasSingleBean(JvmMemoryMetrics.class)
.hasBean("customJvmMemoryMetrics")
@ -131,7 +131,7 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsCustomJvmThreadMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomJvmThreadMetricsConfiguration.class)
this.contextRunner.withUserConfiguration(CustomJvmThreadMetricsConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasSingleBean(JvmMemoryMetrics.class)
.hasSingleBean(JvmThreadMetrics.class)
@ -141,7 +141,7 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsCustomClassLoaderMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomClassLoaderMetricsConfiguration.class)
this.contextRunner.withUserConfiguration(CustomClassLoaderMetricsConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class)
.hasSingleBean(JvmMemoryMetrics.class)
.hasSingleBean(JvmThreadMetrics.class)
@ -151,53 +151,53 @@ public class MetricsAutoConfigurationTests {
@Test
public void autoConfiguresLogbackMetrics() {
this.runner.run(
this.contextRunner.run(
(context) -> assertThat(context).hasSingleBean(LogbackMetrics.class));
}
@Test
public void allowsLogbackMetricsToBeDisabled() {
this.runner.withPropertyValues("management.metrics.binders.logback.enabled=false")
this.contextRunner.withPropertyValues("management.metrics.binders.logback.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(LogbackMetrics.class));
}
@Test
public void allowsCustomLogbackMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomLogbackMetricsConfiguration.class)
this.contextRunner.withUserConfiguration(CustomLogbackMetricsConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(LogbackMetrics.class)
.hasBean("customLogbackMetrics"));
}
@Test
public void autoConfiguresUptimeMetrics() {
this.runner
this.contextRunner
.run((context) -> assertThat(context).hasSingleBean(UptimeMetrics.class));
}
@Test
public void allowsUptimeMetricsToBeDisabled() {
this.runner.withPropertyValues("management.metrics.binders.uptime.enabled=false")
this.contextRunner.withPropertyValues("management.metrics.binders.uptime.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(UptimeMetrics.class));
}
@Test
public void allowsCustomUptimeMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomUptimeMetricsConfiguration.class)
this.contextRunner.withUserConfiguration(CustomUptimeMetricsConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(UptimeMetrics.class)
.hasBean("customUptimeMetrics"));
}
@Test
public void autoConfiguresProcessorMetrics() {
this.runner.run(
this.contextRunner.run(
(context) -> assertThat(context).hasSingleBean(ProcessorMetrics.class));
}
@Test
public void allowsProcessorMetricsToBeDisabled() {
this.runner
this.contextRunner
.withPropertyValues("management.metrics.binders.processor.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(ProcessorMetrics.class));
@ -205,7 +205,7 @@ public class MetricsAutoConfigurationTests {
@Test
public void allowsCustomProcessorMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomProcessorMetricsConfiguration.class)
this.contextRunner.withUserConfiguration(CustomProcessorMetricsConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(ProcessorMetrics.class)
.hasBean("customProcessorMetrics"));
@ -213,20 +213,20 @@ public class MetricsAutoConfigurationTests {
@Test
public void autoConfiguresFileDescriptorMetrics() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(FileDescriptorMetrics.class));
}
@Test
public void allowsFileDescriptorMetricsToBeDisabled() {
this.runner.withPropertyValues("management.metrics.binders.files.enabled=false")
this.contextRunner.withPropertyValues("management.metrics.binders.files.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(FileDescriptorMetrics.class));
}
@Test
public void allowsCustomFileDescriptorMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomFileDescriptorMetricsConfiguration.class)
this.contextRunner.withUserConfiguration(CustomFileDescriptorMetricsConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(FileDescriptorMetrics.class)
.hasBean("customFileDescriptorMetrics"));

@ -42,19 +42,19 @@ import static org.mockito.Mockito.verify;
*/
public class AtlasMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(AtlasMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(AtlasMeterRegistry.class));
}
@Test
public void autoConfiguresItsConfigAndMeterRegistry() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(AtlasMeterRegistry.class)
.hasSingleBean(AtlasConfig.class));
@ -62,7 +62,7 @@ public class AtlasMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.atlas.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(AtlasMeterRegistry.class)
@ -71,7 +71,7 @@ public class AtlasMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomConfigToBeUsed() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(AtlasMeterRegistry.class)
.hasSingleBean(AtlasConfig.class).hasBean("customConfig"));
@ -79,7 +79,7 @@ public class AtlasMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomRegistryToBeUsed() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(AtlasMeterRegistry.class).hasBean("customRegistry")
.hasSingleBean(AtlasConfig.class));
@ -87,9 +87,10 @@ public class AtlasMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
AtlasMeterRegistry registry = spyOnDisposableBean(AtlasMeterRegistry.class,
context);
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> {
AtlasMeterRegistry registry = spyOnDisposableBean(
AtlasMeterRegistry.class, context);
context.close();
verify(registry).stop();
});

@ -42,25 +42,25 @@ import static org.mockito.Mockito.verify;
*/
public class DatadogMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(DatadogMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(DatadogMeterRegistry.class));
}
@Test
public void failsWithoutAnApiKey() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context).hasFailed());
}
@Test
public void autoConfiguresConfigAndMeterRegistry() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.datadog.api-key=abcde")
.run((context) -> assertThat(context)
.hasSingleBean(DatadogMeterRegistry.class)
@ -69,7 +69,7 @@ public class DatadogMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.datadog.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(DatadogMeterRegistry.class)
@ -78,7 +78,7 @@ public class DatadogMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomConfigToBeUsed() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(DatadogMeterRegistry.class)
.hasSingleBean(DatadogConfig.class).hasBean("customConfig"));
@ -86,7 +86,7 @@ public class DatadogMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomRegistryToBeUsed() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.withPropertyValues("management.metrics.export.datadog.api-key=abcde")
.run((context) -> assertThat(context)
.hasSingleBean(DatadogMeterRegistry.class)
@ -95,7 +95,7 @@ public class DatadogMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.datadog.api-key=abcde")
.run((context) -> {
DatadogMeterRegistry registry = spyOnDisposableBean(

@ -42,19 +42,19 @@ import static org.mockito.Mockito.verify;
*/
public class GangliaMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(GangliaMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(GangliaMeterRegistry.class));
}
@Test
public void autoConfiguresItsConfigAndMeterRegistry() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(GangliaMeterRegistry.class)
.hasSingleBean(GangliaConfig.class));
@ -62,7 +62,7 @@ public class GangliaMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.ganglia.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(GangliaMeterRegistry.class)
@ -71,7 +71,7 @@ public class GangliaMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomConfigToBeUsed() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(GangliaMeterRegistry.class)
.hasSingleBean(GangliaConfig.class).hasBean("customConfig"));
@ -79,7 +79,7 @@ public class GangliaMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomRegistryToBeUsed() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(GangliaMeterRegistry.class)
.hasBean("customRegistry").hasSingleBean(GangliaConfig.class));
@ -87,7 +87,8 @@ public class GangliaMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> {
GangliaMeterRegistry registry = spyOnDisposableBean(
GangliaMeterRegistry.class, context);
context.close();

@ -42,19 +42,19 @@ import static org.mockito.Mockito.verify;
*/
public class GraphiteMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(GraphiteMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(GraphiteMeterRegistry.class));
}
@Test
public void autoConfiguresItsConfigAndMeterRegistry() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(GraphiteMeterRegistry.class)
.hasSingleBean(GraphiteConfig.class));
@ -62,7 +62,7 @@ public class GraphiteMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.graphite.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(GraphiteMeterRegistry.class)
@ -71,7 +71,7 @@ public class GraphiteMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomConfigToBeUsed() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(GraphiteMeterRegistry.class)
.hasSingleBean(GraphiteConfig.class).hasBean("customConfig"));
@ -79,7 +79,7 @@ public class GraphiteMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomRegistryToBeUsed() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(GraphiteMeterRegistry.class)
.hasBean("customRegistry").hasSingleBean(GraphiteConfig.class));
@ -87,7 +87,7 @@ public class GraphiteMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
GraphiteMeterRegistry registry = spyOnDisposableBean(
GraphiteMeterRegistry.class, context);
context.close();

@ -42,19 +42,19 @@ import static org.mockito.Mockito.verify;
*/
public class InfluxMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(InfluxMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(InfluxMeterRegistry.class));
}
@Test
public void autoConfiguresItsConfigAndMeterRegistry() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(InfluxMeterRegistry.class)
.hasSingleBean(InfluxConfig.class));
@ -62,7 +62,7 @@ public class InfluxMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.influx.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(InfluxMeterRegistry.class)
@ -71,7 +71,7 @@ public class InfluxMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomConfigToBeUsed() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(InfluxMeterRegistry.class)
.hasSingleBean(InfluxConfig.class).hasBean("customConfig"));
@ -79,7 +79,7 @@ public class InfluxMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomRegistryToBeUsed() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(InfluxMeterRegistry.class)
.hasBean("customRegistry").hasSingleBean(InfluxConfig.class));
@ -87,9 +87,10 @@ public class InfluxMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
InfluxMeterRegistry registry = spyOnDisposableBean(InfluxMeterRegistry.class,
context);
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> {
InfluxMeterRegistry registry = spyOnDisposableBean(
InfluxMeterRegistry.class, context);
context.close();
verify(registry).stop();
});

@ -45,19 +45,19 @@ import static org.mockito.Mockito.verify;
*/
public class JmxMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(JmxMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run(
this.contextRunner.run(
(context) -> assertThat(context).doesNotHaveBean(JmxMeterRegistry.class));
}
@Test
public void autoConfiguresItsConfigMeterRegistryAndNameMapper() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(JmxMeterRegistry.class)
.hasSingleBean(JmxConfig.class)
@ -66,7 +66,7 @@ public class JmxMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.jmx.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(JmxMeterRegistry.class)
@ -76,7 +76,7 @@ public class JmxMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomConfigToBeUsed() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(JmxMeterRegistry.class)
.hasSingleBean(JmxConfig.class).hasBean("customConfig")
@ -85,7 +85,7 @@ public class JmxMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomRegistryToBeUsed() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(JmxMeterRegistry.class).hasBean("customRegistry")
.hasSingleBean(JmxConfig.class)
@ -94,7 +94,7 @@ public class JmxMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomHierarchicalNameMapperToBeUsed() {
this.runner.withUserConfiguration(CustomNameMapperConfiguration.class)
this.contextRunner.withUserConfiguration(CustomNameMapperConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(JmxMeterRegistry.class)
.hasSingleBean(JmxConfig.class).hasBean("customNameMapper")
@ -103,7 +103,7 @@ public class JmxMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
JmxMeterRegistry registry = spyOnDisposableBean(JmxMeterRegistry.class,
context);
context.close();

@ -43,33 +43,33 @@ import static org.mockito.Mockito.verify;
*/
public class NewRelicMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(NewRelicMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(NewRelicMeterRegistry.class));
}
@Test
public void failsWithoutAnApiKey() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.newrelic.account-id=12345")
.run((context) -> assertThat(context).hasFailed());
}
@Test
public void failsWithoutAnAccountId() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.newrelic.api-key=abcde")
.run((context) -> assertThat(context).hasFailed());
}
@Test
public void autoConfiguresWithAccountIdAndApiKey() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.newrelic.api-key=abcde",
"management.metrics.export.newrelic.account-id=12345")
.run((context) -> assertThat(context)
@ -79,7 +79,7 @@ public class NewRelicMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.newrelic.enabled=false",
"management.metrics.export.newrelic.api-key=abcde",
"management.metrics.export.newrelic.account-id=12345")
@ -90,7 +90,7 @@ public class NewRelicMetricsExportAutoConfigurationTests {
@Test
public void allowsConfigToBeCustomized() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.withPropertyValues("management.metrics.export.newrelic.api-key=abcde",
"management.metrics.export.newrelic.account-id=12345")
.run((context) -> assertThat(context).hasSingleBean(NewRelicConfig.class)
@ -99,7 +99,7 @@ public class NewRelicMetricsExportAutoConfigurationTests {
@Test
public void allowsRegistryToBeCustomized() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.withPropertyValues("management.metrics.export.newrelic.api-key=abcde",
"management.metrics.export.newrelic.account-id=12345")
.run((context) -> assertThat(context)
@ -109,7 +109,7 @@ public class NewRelicMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner
this.contextRunner
.withPropertyValues("management.metrics.export.newrelic.api-key=abcde",
"management.metrics.export.newrelic.account-id=abcde")
.withUserConfiguration(BaseConfiguration.class).run((context) -> {

@ -39,19 +39,19 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class PrometheusMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations
.of(PrometheusMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(PrometheusMeterRegistry.class));
}
@Test
public void autoConfiguresItsConfigCollectorRegistryAndMeterRegistry() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(PrometheusMeterRegistry.class)
.hasSingleBean(CollectorRegistry.class)
@ -60,7 +60,7 @@ public class PrometheusMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner
this.contextRunner
.withPropertyValues("management.metrics.export.prometheus.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(PrometheusMeterRegistry.class)
@ -70,7 +70,7 @@ public class PrometheusMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomConfigToBeUsed() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(PrometheusMeterRegistry.class)
.hasSingleBean(CollectorRegistry.class)
@ -79,7 +79,7 @@ public class PrometheusMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomRegistryToBeUsed() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(PrometheusMeterRegistry.class)
.hasBean("customRegistry").hasSingleBean(CollectorRegistry.class)
@ -88,7 +88,7 @@ public class PrometheusMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomCollectorRegistryToBeUsed() {
this.runner.withUserConfiguration(CustomCollectorRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomCollectorRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(PrometheusMeterRegistry.class)
.hasBean("customCollectorRegistry")
@ -98,7 +98,7 @@ public class PrometheusMetricsExportAutoConfigurationTests {
@Test
public void addsScrapeEndpointToManagementContext() {
this.runner
this.contextRunner
.withConfiguration(
AutoConfigurations.of(ManagementContextAutoConfiguration.class))
.withUserConfiguration(BaseConfiguration.class)
@ -108,7 +108,7 @@ public class PrometheusMetricsExportAutoConfigurationTests {
@Test
public void scrapeEndpointCanBeDisabled() {
this.runner
this.contextRunner
.withConfiguration(
AutoConfigurations.of(ManagementContextAutoConfiguration.class))
.withPropertyValues("management.endpoint.prometheus.enabled=false")
@ -119,7 +119,7 @@ public class PrometheusMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomScrapeEndpointToBeUsed() {
this.runner
this.contextRunner
.withConfiguration(
AutoConfigurations.of(ManagementContextAutoConfiguration.class))
.withUserConfiguration(CustomEndpointConfiguration.class)

@ -42,25 +42,25 @@ import static org.mockito.Mockito.verify;
*/
public class SignalFxMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(SignalFxMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(SignalFxMeterRegistry.class));
}
@Test
public void failsWithoutAnAccessToken() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context).hasFailed());
}
@Test
public void autoConfiguresWithAnAccessToken() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues(
"management.metrics.export.signalfx.access-token=abcde")
.run((context) -> assertThat(context)
@ -70,7 +70,7 @@ public class SignalFxMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues(
"management.metrics.export.signalfx.access-token=abcde",
"management.metrics.export.signalfx.enabled=false")
@ -81,7 +81,7 @@ public class SignalFxMetricsExportAutoConfigurationTests {
@Test
public void allowsConfigToBeCustomized() {
this.runner
this.contextRunner
.withPropertyValues(
"management.metrics.export.signalfx.access-token=abcde")
.withUserConfiguration(CustomConfigConfiguration.class)
@ -92,7 +92,7 @@ public class SignalFxMetricsExportAutoConfigurationTests {
@Test
public void allowsRegistryToBeCustomized() {
this.runner
this.contextRunner
.withPropertyValues(
"management.metrics.export.signalfx.access-token=abcde")
.withUserConfiguration(CustomRegistryConfiguration.class)
@ -104,7 +104,7 @@ public class SignalFxMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner
this.contextRunner
.withPropertyValues(
"management.metrics.export.signalfx.access-token=abcde")
.withUserConfiguration(BaseConfiguration.class).run((context) -> {

@ -39,13 +39,13 @@ import static org.mockito.Mockito.mock;
*/
public class SimpleMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(SimpleMetricsExportAutoConfiguration.class));
@Test
public void autoConfiguresConfigAndMeterRegistry() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(SimpleMeterRegistry.class)
.hasSingleBean(Clock.class).hasSingleBean(SimpleConfig.class));
@ -53,14 +53,14 @@ public class SimpleMetricsExportAutoConfigurationTests {
@Test
public void allowsConfigToBeCustomized() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(SimpleConfig.class)
.hasBean("customConfig"));
}
@Test
public void backsOffEntirelyWithCustomMeterRegistry() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(MeterRegistry.class)
.hasBean("customRegistry").doesNotHaveBean(SimpleConfig.class));
}

@ -45,19 +45,19 @@ import static org.mockito.Mockito.verify;
*/
public class StatsdMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(StatsdMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(StatsdMeterRegistry.class));
}
@Test
public void autoConfiguresItsConfigMeterRegistryAndNameMapper() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(StatsdMeterRegistry.class)
.hasSingleBean(StatsdConfig.class)
@ -66,7 +66,7 @@ public class StatsdMetricsExportAutoConfigurationTests {
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withPropertyValues("management.metrics.export.statsd.enabled=false")
this.contextRunner.withPropertyValues("management.metrics.export.statsd.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(StatsdMeterRegistry.class)
.doesNotHaveBean(StatsdConfig.class)
@ -75,7 +75,7 @@ public class StatsdMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomConfigToBeUsed() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(StatsdMeterRegistry.class)
.hasSingleBean(StatsdConfig.class).hasBean("customConfig")
@ -84,7 +84,7 @@ public class StatsdMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomRegistryToBeUsed() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(StatsdMeterRegistry.class)
.hasBean("customRegistry").hasSingleBean(StatsdConfig.class)
@ -93,7 +93,7 @@ public class StatsdMetricsExportAutoConfigurationTests {
@Test
public void allowsCustomHierarchicalNameMapperToBeUsed() {
this.runner.withUserConfiguration(CustomNameMapperConfiguration.class)
this.contextRunner.withUserConfiguration(CustomNameMapperConfiguration.class)
.run((context) -> assertThat(context)
.hasSingleBean(StatsdMeterRegistry.class)
.hasSingleBean(StatsdConfig.class).hasBean("customNameMapper")
@ -102,7 +102,7 @@ public class StatsdMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> {
StatsdMeterRegistry registry = spyOnDisposableBean(StatsdMeterRegistry.class,
context);
context.close();

@ -42,25 +42,25 @@ import static org.mockito.Mockito.verify;
*/
public class WavefrontMetricsExportAutoConfigurationTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(WavefrontMetricsExportAutoConfiguration.class));
@Test
public void backsOffWithoutAClock() {
this.runner.run((context) -> assertThat(context)
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(WavefrontMeterRegistry.class));
}
@Test
public void failsWithoutAnApiTokenWhenPublishingDirectly() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context).hasFailed());
}
@Test
public void autoConfigurationCanBeDisabled() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.wavefront.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(WavefrontMeterRegistry.class)
@ -69,7 +69,7 @@ public class WavefrontMetricsExportAutoConfigurationTests {
@Test
public void allowsConfigToBeCustomized() {
this.runner.withUserConfiguration(CustomConfigConfiguration.class)
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(Clock.class)
.hasSingleBean(WavefrontMeterRegistry.class)
.hasSingleBean(WavefrontConfig.class).hasBean("customConfig"));
@ -77,7 +77,7 @@ public class WavefrontMetricsExportAutoConfigurationTests {
@Test
public void allowsRegistryToBeCustomized() {
this.runner.withUserConfiguration(CustomRegistryConfiguration.class)
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.withPropertyValues("management.metrics.export.wavefront.api-token=abcde")
.run((context) -> assertThat(context).hasSingleBean(Clock.class)
.hasSingleBean(WavefrontConfig.class)
@ -87,7 +87,7 @@ public class WavefrontMetricsExportAutoConfigurationTests {
@Test
public void stopsMeterRegistryWhenContextIsClosed() {
this.runner.withUserConfiguration(BaseConfiguration.class)
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.wavefront.api-token=abcde")
.run((context) -> {
WavefrontMeterRegistry registry = spyOnDisposableBean(

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.

@ -51,11 +51,12 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class HttpTraceWebFilterIntegrationTests {
private ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner()
.withUserConfiguration(Config.class);
@Test
public void traceForNotFoundResponseHas404Status() {
ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner()
.withUserConfiguration(Config.class);
runner.run((context) -> {
this.contextRunner.run((context) -> {
WebTestClient.bindToApplicationContext(context).build().get().uri("/")
.exchange().expectStatus().isNotFound();
HttpTraceRepository repository = context.getBean(HttpTraceRepository.class);
@ -67,9 +68,7 @@ public class HttpTraceWebFilterIntegrationTests {
@Test
public void traceForMonoErrorWithRuntimeExceptionHas500Status() {
ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner()
.withUserConfiguration(Config.class);
runner.run((context) -> {
this.contextRunner.run((context) -> {
WebTestClient.bindToApplicationContext(context).build().get()
.uri("/mono-error").exchange().expectStatus()
.isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
@ -82,9 +81,7 @@ public class HttpTraceWebFilterIntegrationTests {
@Test
public void traceForThrownRuntimeExceptionHas500Status() {
ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner()
.withUserConfiguration(Config.class);
runner.run((context) -> {
this.contextRunner.run((context) -> {
WebTestClient.bindToApplicationContext(context).build().get().uri("/thrown")
.exchange().expectStatus()
.isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.

@ -74,7 +74,8 @@ public class DefaultServletWebServerFactoryCustomizer
map.from(this.serverProperties::getAddress).to(factory::setAddress);
map.from(this.serverProperties.getServlet()::getContextPath)
.to(factory::setContextPath);
map.from(this.serverProperties.getServlet()::getApplicationDisplayName).to(factory::setDisplayName);
map.from(this.serverProperties.getServlet()::getApplicationDisplayName)
.to(factory::setDisplayName);
map.from(this.serverProperties.getServlet()::getSession).to(factory::setSession);
map.from(this.serverProperties::getSsl).to(factory::setSsl);
map.from(this.serverProperties::getServlet).as(ServerProperties.Servlet::getJsp)

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.

@ -295,7 +295,8 @@ public class CacheAutoConfigurationTests {
.isEqualTo(java.time.Duration.ofSeconds(15));
assertThat(redisCacheConfiguration.getAllowCacheNullValues())
.isFalse();
assertThat(redisCacheConfiguration.getKeyPrefixFor("keyName")).isEqualTo("prefix");
assertThat(redisCacheConfiguration.getKeyPrefixFor("keyName"))
.isEqualTo("prefix");
assertThat(redisCacheConfiguration.usePrefix()).isTrue();
});
}
@ -342,7 +343,8 @@ public class CacheAutoConfigurationTests {
.isEqualTo(java.time.Duration.ofMinutes(0));
assertThat(redisCacheConfiguration.getAllowCacheNullValues())
.isTrue();
assertThat(redisCacheConfiguration.getKeyPrefixFor("test")).isEqualTo("test::");
assertThat(redisCacheConfiguration.getKeyPrefixFor("test"))
.isEqualTo("test::");
assertThat(redisCacheConfiguration.usePrefix()).isTrue();
});
}

@ -42,12 +42,12 @@ import static org.assertj.core.api.Assertions.assertThat;
@ClassPathExclusions("lettuce-core-*.jar")
public class RedisAutoConfigurationJedisTests {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class));
@Test
public void testOverrideRedisConfiguration() {
this.runner.withPropertyValues("spring.redis.host:foo", "spring.redis.database:1")
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.database:1")
.run((context) -> {
JedisConnectionFactory cf = context
.getBean(JedisConnectionFactory.class);
@ -60,7 +60,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testCustomizeRedisConfiguration() {
this.runner.withUserConfiguration(CustomConfiguration.class).run((context) -> {
this.contextRunner.withUserConfiguration(CustomConfiguration.class).run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.isUseSsl()).isTrue();
});
@ -68,7 +68,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testRedisUrlConfiguration() {
this.runner
this.contextRunner
.withPropertyValues("spring.redis.host:foo",
"spring.redis.url:redis://user:password@example:33")
.run((context) -> {
@ -83,7 +83,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testOverrideUrlRedisConfiguration() {
this.runner
this.contextRunner
.withPropertyValues("spring.redis.host:foo", "spring.redis.password:xyz",
"spring.redis.port:1000", "spring.redis.ssl:false",
"spring.redis.url:rediss://user:password@example:33")
@ -99,7 +99,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testPasswordInUrlWithColon() {
this.runner.withPropertyValues("spring.redis.url:redis://:pass:word@example:33")
this.contextRunner.withPropertyValues("spring.redis.url:redis://:pass:word@example:33")
.run((context) -> {
assertThat(
context.getBean(JedisConnectionFactory.class).getHostName())
@ -114,7 +114,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testPasswordInUrlStartsWithColon() {
this.runner
this.contextRunner
.withPropertyValues("spring.redis.url:redis://user::pass:word@example:33")
.run((context) -> {
assertThat(
@ -130,7 +130,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testRedisConfigurationWithPool() {
this.runner.withPropertyValues("spring.redis.host:foo",
this.contextRunner.withPropertyValues("spring.redis.host:foo",
"spring.redis.jedis.pool.min-idle:1",
"spring.redis.jedis.pool.max-idle:4",
"spring.redis.jedis.pool.max-active:16",
@ -147,7 +147,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testRedisConfigurationWithTimeout() {
this.runner
this.contextRunner
.withPropertyValues("spring.redis.host:foo", "spring.redis.timeout:100")
.run((context) -> {
JedisConnectionFactory cf = context
@ -159,7 +159,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testRedisConfigurationWithSentinel() {
this.runner
this.contextRunner
.withPropertyValues("spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
.withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class)
@ -172,7 +172,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testRedisConfigurationWithSentinelAndPassword() {
this.runner
this.contextRunner
.withPropertyValues("spring.redis.password=password",
"spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
@ -189,7 +189,7 @@ public class RedisAutoConfigurationJedisTests {
@Test
public void testRedisConfigurationWithCluster() {
this.runner
this.contextRunner
.withPropertyValues(
"spring.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380")
.run((context) -> assertThat(context.getBean(JedisConnectionFactory.class)

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.

@ -256,6 +256,11 @@
<artifactId>micrometer-registry-statsd</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-wavefront</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.projectreactor.ipc</groupId>
<artifactId>reactor-netty</artifactId>

@ -3155,17 +3155,22 @@ NOTE: Before setting the `management.endpoints.web.exposure.include`, ensure tha
exposed actuators do not contain sensitive information and/or are secured by placing them
behind a firewall or by something like Spring Security.
[[boot-features-security-csrf]]
==== Cross Site Request Forgery Protection
Since Spring Boot relies on Spring Security's defaults, CSRF protection is turned on by
default. This means that the actuator endpoints that require a `POST` (shutdown and
loggers endpoints), `PUT` or `DELETE` will get a 403 forbidden error when the default
security configuration is in use.
Since Spring Boot relies on Spring Security's defaults, CSRF protection is turned on by default.
This means that the actuator endpoints that require a `POST` (shutdown and loggers endpoints), `PUT`
or `DELETE` will get a 403 forbidden error when the default security configuration is in use.
NOTE: We recommend disabling CSRF protection completely only if you are creating a service
that is used by non-browser clients.
Additional information about CSRF protection can be found in the
{spring-security-reference}#csrf[Spring Security Reference Guide].
NOTE: We recommend disabling CSRF protection completely only if you are creating a service that
is used by non-browser clients.
Additional information about CSRF protection can be found in the {spring-security-reference}#csrf[Spring
Security Reference Guide].
[[boot-features-sql]]
== Working with SQL Databases
@ -6130,6 +6135,7 @@ include::{code-examples}/test/web/RandomPortTestRestTemplateExampleTests.java[ta
----
[[boot-features-testing-spring-boot-applications-mocking-beans]]
==== Mocking and Spying Beans
When running tests, it is sometimes necessary to mock certain components within your

@ -130,22 +130,16 @@ public class TestRestTemplate {
*/
public TestRestTemplate(RestTemplateBuilder restTemplateBuilder, String username,
String password, HttpClientOption... httpClientOptions) {
this(buildRestTemplate(restTemplateBuilder), username, password,
httpClientOptions);
}
private static RestTemplate buildRestTemplate(
RestTemplateBuilder restTemplateBuilder) {
Assert.notNull(restTemplateBuilder, "RestTemplateBuilder must not be null");
return restTemplateBuilder.build();
this(restTemplateBuilder == null ? null : restTemplateBuilder.build(), username,
password, httpClientOptions);
}
private TestRestTemplate(RestTemplate restTemplate, String username, String password,
HttpClientOption... httpClientOptions) {
Assert.notNull(restTemplate, "RestTemplate must not be null");
this.httpClientOptions = httpClientOptions;
if (getRequestFactoryClass(restTemplate).getName()
.equals("org.springframework.http.client.HttpComponentsClientHttpRequestFactory")) {
if (getRequestFactoryClass(restTemplate).getName().equals(
"org.springframework.http.client.HttpComponentsClientHttpRequestFactory")) {
restTemplate.setRequestFactory(
new CustomHttpComponentsClientHttpRequestFactory(httpClientOptions));
}
@ -154,14 +148,16 @@ public class TestRestTemplate {
this.restTemplate = restTemplate;
}
private Class<? extends ClientHttpRequestFactory> getRequestFactoryClass(RestTemplate restTemplate) {
private Class<? extends ClientHttpRequestFactory> getRequestFactoryClass(
RestTemplate restTemplate) {
ClientHttpRequestFactory requestFactory = restTemplate.getRequestFactory();
if (InterceptingClientHttpRequestFactory.class.isAssignableFrom(requestFactory.getClass())) {
Field requestFactoryField = ReflectionUtils
.findField(RestTemplate.class, "requestFactory");
if (InterceptingClientHttpRequestFactory.class
.isAssignableFrom(requestFactory.getClass())) {
Field requestFactoryField = ReflectionUtils.findField(RestTemplate.class,
"requestFactory");
ReflectionUtils.makeAccessible(requestFactoryField);
requestFactory = (ClientHttpRequestFactory)
ReflectionUtils.getField(requestFactoryField, restTemplate);
requestFactory = (ClientHttpRequestFactory) ReflectionUtils
.getField(requestFactoryField, restTemplate);
}
return requestFactory.getClass();
}
@ -1037,8 +1033,7 @@ public class TestRestTemplate {
RestTemplate restTemplate = new RestTemplateBuilder()
.messageConverters(getRestTemplate().getMessageConverters())
.interceptors(getRestTemplate().getInterceptors())
.uriTemplateHandler(getRestTemplate().getUriTemplateHandler())
.build();
.uriTemplateHandler(getRestTemplate().getUriTemplateHandler()).build();
TestRestTemplate testRestTemplate = new TestRestTemplate(restTemplate, username,
password, this.httpClientOptions);
testRestTemplate.getRestTemplate()

@ -136,7 +136,8 @@ public class TestRestTemplateTests {
@Test
public void restOperationsAreAvailable() {
RestTemplate delegate = mock(RestTemplate.class);
given(delegate.getRequestFactory()).willReturn(new SimpleClientHttpRequestFactory());
given(delegate.getRequestFactory())
.willReturn(new SimpleClientHttpRequestFactory());
given(delegate.getUriTemplateHandler())
.willReturn(new DefaultUriBuilderFactory());
RestTemplateBuilder builder = mock(RestTemplateBuilder.class);

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.
@ -41,9 +41,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ShutdownSampleActuatorApplicationTests.SecurityConfiguration.class,
SampleActuatorApplication.class },
webEnvironment = WebEnvironment.RANDOM_PORT)
@SpringBootTest(classes = {
ShutdownSampleActuatorApplicationTests.SecurityConfiguration.class,
SampleActuatorApplication.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
public class ShutdownSampleActuatorApplicationTests {
@Autowired

Loading…
Cancel
Save