Search in sources :

Example 1 with Timer

use of org.apache.sling.commons.metrics.Timer in project sling by apache.

the class MetricServiceTest method timer.

@Test
public void timer() throws Exception {
    activate();
    Timer timer = service.timer("test");
    assertNotNull(timer);
    assertTrue(getRegistry().getTimers().containsKey("test"));
    assertSame(timer, service.timer("test"));
}
Also used : Timer(org.apache.sling.commons.metrics.Timer) Test(org.junit.Test)

Example 2 with Timer

use of org.apache.sling.commons.metrics.Timer in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class AdaptiveImageServletMetricsTest method setup.

@BeforeEach
void setup() {
    MetricsService s = mock(MetricsService.class);
    Timer timer = mock(Timer.class);
    when(timer.time()).thenReturn(mock(Timer.Context.class));
    when(s.timer(Mockito.anyString())).thenReturn(timer);
    when(s.counter(Mockito.anyString())).thenReturn(mock(Counter.class));
    context.registerService(MetricsService.class, s);
}
Also used : AemContext(io.wcm.testing.mock.aem.junit5.AemContext) Counter(org.apache.sling.commons.metrics.Counter) Timer(org.apache.sling.commons.metrics.Timer) MetricsService(org.apache.sling.commons.metrics.MetricsService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Timer (org.apache.sling.commons.metrics.Timer)2 AemContext (io.wcm.testing.mock.aem.junit5.AemContext)1 Counter (org.apache.sling.commons.metrics.Counter)1 MetricsService (org.apache.sling.commons.metrics.MetricsService)1 Test (org.junit.Test)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1