Skip to content

Commit

Permalink
Merge branch '1.1.x' into 1.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Jan 4, 2020
2 parents 1850f6a + 2b0bc86 commit 0183713
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.hibernate.SessionFactory;
import org.hibernate.stat.Statistics;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import javax.persistence.EntityManagerFactory;
Expand All @@ -40,7 +39,9 @@
@SuppressWarnings("deprecation")
class HibernateMetricsTest {

private MeterRegistry registry;
private final MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
private final EntityManagerFactory entityManagerFactory = createMockEntityManagerFactory(true);
private final SessionFactory sessionFactory = createMockSessionFactory(true);

private static EntityManagerFactory createMockEntityManagerFactory(boolean statsEnabled) {
EntityManagerFactory emf = mock(EntityManagerFactory.class);
Expand All @@ -61,22 +62,15 @@ private static SessionFactory createMockSessionFactory(boolean statsEnabled) {
return sf;
}

@BeforeEach
void setup() {
registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
}

@SuppressWarnings("deprecation")
@Test
void deprecatedMonitorShouldExposeMetricsWhenStatsEnabled() {
EntityManagerFactory entityManagerFactory = createMockEntityManagerFactory(true);
HibernateMetrics.monitor(registry, entityManagerFactory, "entityManagerFactory");
assertThatMonitorShouldExposeMetricsWhenStatsEnabled();
}

@Test
void monitorShouldExposeMetricsWhenStatsEnabled() {
SessionFactory sessionFactory = createMockSessionFactory(true);
HibernateMetrics.monitor(registry, sessionFactory, "sessionFactory");
assertThatMonitorShouldExposeMetricsWhenStatsEnabled();
}
Expand Down

0 comments on commit 0183713

Please sign in to comment.