package org.stagemonitor.logging;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.stagemonitor.core.metrics.metrics2.MetricName.name;

import java.util.Map;

import com.codahale.metrics.Meter;
import org.junit.AfterClass;
import com.codahale.metrics.SharedMetricRegistries;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.stagemonitor.core.Stagemonitor;
import org.stagemonitor.core.metrics.metrics2.MetricName;
import org.stagemonitor.junit.ConditionalTravisTestRunner;
import org.stagemonitor.junit.ExcludeOnTravis;

@RunWith(ConditionalTravisTestRunner.class)
public class MeterLoggingInstrumenterTest {

	private Logger logger;

	@BeforeClass
	public static void attachProfiler() {
		Stagemonitor.init();
	}

	@Before
	public void reinit() throws Exception {
		Stagemonitor.reset();
		SharedMetricRegistries.clear();
		logger = LoggerFactory.getLogger(getClass());
	}

	@AfterClass
	public static void clear() {
		Stagemonitor.reset();
	}

	@Test
	@ExcludeOnTravis
	public void testLogging() throws Exception {
		logger.error("test");
		final Map<MetricName, Meter> meters = Stagemonitor.getMetric2Registry().getMeters();
		assertNotNull(meters.get(name("logging").tag("log_level", "error").build()));
		assertEquals(1, meters.get(name("logging").tag("log_level", "error").build()).getCount());
	}
}

@@ -252,37 +252,8 @@
 er;%0A
-import org.junit.AfterClass;%0A
 impo
@@ -317,22 +317,26 @@
 g.junit.
-Before
+AfterClass
 ;%0Aimport
@@ -386,41 +386,8 @@
 st;%0A
-import org.junit.runner.RunWith;%0A
 impo
@@ -544,158 +544,8 @@
 me;%0A
-import org.stagemonitor.junit.ConditionalTravisTestRunner;%0Aimport org.stagemonitor.junit.ExcludeOnTravis;%0A%0A@RunWith(ConditionalTravisTestRunner.class)
 %0Apub
@@ -608,16 +608,54 @@
 r logger
+ = LoggerFactory.getLogger(getClass())
 ;%0A%0A%09@Bef
@@ -733,168 +733,8 @@
 %09%7D%0A%0A
-%09@Before%0A%09public void reinit() throws Exception %7B%0A%09%09Stagemonitor.reset();%0A%09%09SharedMetricRegistries.clear();%0A%09%09logger = LoggerFactory.getLogger(getClass());%0A%09%7D%0A%0A
 %09@Af
@@ -801,35 +801,51 @@
 );%0A%09
-%7D%0A%0A%09@Test%0A%09@ExcludeOnTravis
+%09SharedMetricRegistries.clear();%0A%09%7D%0A%0A%09@Test
 %0A%09pu

Fix MeterLoggingInstrumenterTest