@@ -0,0 +1,2121 @@
+/*%0A * Copyright %C2%A9 2015 by Frank W. Rahn. Alle Rechte vorbehalten. All rights reserved.%0A */%0Apackage de.rahn.finances.commons.metrics;%0A%0Aimport static org.hamcrest.Matchers.empty;%0Aimport static org.hamcrest.Matchers.notNullValue;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.mockito.Matchers.anyString;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport java.util.SortedMap;%0Aimport java.util.TreeMap;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.InjectMocks;%0Aimport org.mockito.Mock;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0A%0Aimport com.codahale.metrics.Counter;%0Aimport com.codahale.metrics.Histogram;%0Aimport com.codahale.metrics.Meter;%0Aimport com.codahale.metrics.MetricRegistry;%0Aimport com.codahale.metrics.Timer;%0Aimport com.codahale.metrics.UniformReservoir;%0A%0A/**%0A * Test, des Exporters.%0A * @author Frank W. Rahn%0A */%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class MetricsExporterServiceTest %7B%0A%0A%09@Mock%0A%09private MetricRegistry registry;%0A%0A%09@InjectMocks%0A%09private MetricsExporterService exporter = new MetricsExporterService();%0A%0A%09private %3CV%3E SortedMap%3CString, V%3E singletonMap(String name, V value) %7B%0A%09%09TreeMap%3CString, V%3E map = new TreeMap%3C%3E();%0A%09%09map.put(name, value);%0A%0A%09%09return map;%0A%09%7D%0A%0A%09/**%0A%09 * @throws java.lang.Exception%0A%09 */%0A%09@Before%0A%09public void setUp() throws Exception %7B%0A%09%09when(registry.remove(anyString())).thenReturn(true);%0A%09%09when(registry.getGauges()).thenReturn(singletonMap(%22gauges%22, () -%3E 4711));%0A%09%09when(registry.getCounters()).thenReturn(singletonMap(%22counter%22, new Counter()));%0A%09%09when(registry.getHistograms()).thenReturn(singletonMap(%22histogram%22, new Histogram(new UniformReservoir())));%0A%09%09when(registry.getMeters()).thenReturn(singletonMap(%22meter%22, new Meter()));%0A%09%09when(registry.getTimers()).thenReturn(singletonMap(%22timer%22, new Timer()));%0A%0A%09%09exporter.initialize();%0A%09%7D%0A%0A%09/**%0A%09 * Test method for %7B@link MetricsExporterService#exportMetrics()%7D.%0A%09 */%0A%09@Test%0A%09public void testExportMetrics() %7B%0A%09%09exporter.exportMetrics();%0A%0A%09%09assertThat(registry.getMetrics(), notNullValue());%0A%09%09assertThat(registry.getMetrics().keySet(), empty());%0A%09%7D%0A%0A%7D

Test für den Exporter