|
|
@ -37,6 +37,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
|
|
|
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
|
|
|
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
|
|
|
|
|
|
|
import org.springframework.boot.test.context.FilteredClassLoader;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
@ -53,6 +54,7 @@ import static org.mockito.Mockito.mock;
|
|
|
|
* Tests for {@link HibernateMetricsAutoConfiguration}.
|
|
|
|
* Tests for {@link HibernateMetricsAutoConfiguration}.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Rui Figueira
|
|
|
|
* @author Rui Figueira
|
|
|
|
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class HibernateMetricsAutoConfigurationTests {
|
|
|
|
public class HibernateMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
@ -137,6 +139,19 @@ public class HibernateMetricsAutoConfigurationTests {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void entityManagerFactoryInstrumentationIsDisabledIfHibernateIsNotAvailable() {
|
|
|
|
|
|
|
|
this.contextRunner.withClassLoader(new FilteredClassLoader(SessionFactory.class))
|
|
|
|
|
|
|
|
.withUserConfiguration(
|
|
|
|
|
|
|
|
NonHibernateEntityManagerFactoryConfiguration.class)
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
|
|
|
assertThat(context)
|
|
|
|
|
|
|
|
.doesNotHaveBean(HibernateMetricsAutoConfiguration.class);
|
|
|
|
|
|
|
|
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
|
|
|
|
|
|
|
assertThat(registry.find("hibernate.statements").meter()).isNull();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
|
static class BaseConfiguration {
|
|
|
|
static class BaseConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|