Search in sources :

Example 51 with ApplicationContextRunner

use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot by spring-projects.

the class MetricsAutoConfigurationIntegrationTests method compositeCreatedWithMultipleRegistries.

@Test
void compositeCreatedWithMultipleRegistries() {
    new ApplicationContextRunner().with(MetricsRun.limitedTo(GraphiteMetricsExportAutoConfiguration.class, JmxMetricsExportAutoConfiguration.class)).run((context) -> {
        MeterRegistry registry = context.getBean(MeterRegistry.class);
        assertThat(registry).isInstanceOf(CompositeMeterRegistry.class);
        assertThat(((CompositeMeterRegistry) registry).getRegistries()).hasAtLeastOneElementOfType(GraphiteMeterRegistry.class).hasAtLeastOneElementOfType(JmxMeterRegistry.class);
    });
}
Also used : GraphiteMeterRegistry(io.micrometer.graphite.GraphiteMeterRegistry) ApplicationContextRunner(org.springframework.boot.test.context.runner.ApplicationContextRunner) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) GraphiteMeterRegistry(io.micrometer.graphite.GraphiteMeterRegistry) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) JmxMeterRegistry(io.micrometer.jmx.JmxMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 52 with ApplicationContextRunner

use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot by spring-projects.

the class MetricsAutoConfigurationIntegrationTests method userConfiguredCompositeHasMeterFiltersApplied.

@Test
void userConfiguredCompositeHasMeterFiltersApplied() {
    new ApplicationContextRunner().with(MetricsRun.limitedTo()).withUserConfiguration(CompositeMeterRegistryConfiguration.class).run((context) -> {
        MeterRegistry composite = context.getBean(MeterRegistry.class);
        assertThat(composite).extracting("filters", InstanceOfAssertFactories.ARRAY).hasSize(1);
        assertThat(composite).isInstanceOf(CompositeMeterRegistry.class);
        Set<MeterRegistry> registries = ((CompositeMeterRegistry) composite).getRegistries();
        assertThat(registries).hasSize(2);
        assertThat(registries).hasOnlyElementsOfTypes(SimpleMeterRegistry.class);
    });
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) ApplicationContextRunner(org.springframework.boot.test.context.runner.ApplicationContextRunner) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) GraphiteMeterRegistry(io.micrometer.graphite.GraphiteMeterRegistry) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) JmxMeterRegistry(io.micrometer.jmx.JmxMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 53 with ApplicationContextRunner

use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot by spring-projects.

the class NoDslContextBeanFailureAnalyzerTests method noAnalysisWithoutR2dbcAutoConfiguration.

@Test
void noAnalysisWithoutR2dbcAutoConfiguration() {
    new ApplicationContextRunner().run((context) -> {
        NoDslContextBeanFailureAnalyzer failureAnalyzer = new NoDslContextBeanFailureAnalyzer(context.getBeanFactory());
        assertThat(failureAnalyzer.analyze(new NoSuchBeanDefinitionException(DSLContext.class))).isNull();
    });
}
Also used : ApplicationContextRunner(org.springframework.boot.test.context.runner.ApplicationContextRunner) DSLContext(org.jooq.DSLContext) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) Test(org.junit.jupiter.api.Test)

Aggregations

ApplicationContextRunner (org.springframework.boot.test.context.runner.ApplicationContextRunner)53 Test (org.junit.jupiter.api.Test)49 ApplicationConfigurationProperties (org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties)21 ConfigurationPropertiesBeanDescriptor (org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor)16 Map (java.util.Map)7 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)6 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)6 HashMap (java.util.HashMap)6 List (java.util.List)6 ArrayList (java.util.ArrayList)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 ContextConfigurationProperties (org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties)5 Bean (org.springframework.context.annotation.Bean)5 Configuration (org.springframework.context.annotation.Configuration)5 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)4 GraphiteMeterRegistry (io.micrometer.graphite.GraphiteMeterRegistry)4 JmxMeterRegistry (io.micrometer.jmx.JmxMeterRegistry)4 ApplicationBeans (org.springframework.boot.actuate.beans.BeansEndpoint.ApplicationBeans)4 Test (org.junit.Test)3 ContextBeans (org.springframework.boot.actuate.beans.BeansEndpoint.ContextBeans)3