use of com.codahale.metrics.jvm.ThreadDeadlockDetector in project metrics by dropwizard.
the class ThreadDeadlockHealthCheckTest method isUnhealthyIfThreadsAreDeadlocked.
@Test
public void isUnhealthyIfThreadsAreDeadlocked() throws Exception {
final Set<String> threads = new TreeSet<String>();
threads.add("one");
threads.add("two");
final ThreadDeadlockDetector detector = mock(ThreadDeadlockDetector.class);
final ThreadDeadlockHealthCheck healthCheck = new ThreadDeadlockHealthCheck(detector);
when(detector.getDeadlockedThreads()).thenReturn(threads);
final HealthCheck.Result result = healthCheck.execute();
assertThat(result.isHealthy()).isFalse();
assertThat(result.getMessage()).isEqualTo("[one, two]");
}
use of com.codahale.metrics.jvm.ThreadDeadlockDetector in project metrics by dropwizard.
the class ThreadDeadlockHealthCheckTest method isHealthyIfNoThreadsAreDeadlocked.
@Test
public void isHealthyIfNoThreadsAreDeadlocked() throws Exception {
final ThreadDeadlockDetector detector = mock(ThreadDeadlockDetector.class);
final ThreadDeadlockHealthCheck healthCheck = new ThreadDeadlockHealthCheck(detector);
when(detector.getDeadlockedThreads()).thenReturn(Collections.<String>emptySet());
assertThat(healthCheck.execute().isHealthy()).isTrue();
}
Aggregations