package org.stagemonitor.logging;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.SortedMap;

import com.codahale.metrics.Meter;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.stagemonitor.core.Stagemonitor;

public class MeterLoggingInstrumenterTest {

	private Logger logger;

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

	// FIXME
	@Test
	@Ignore("when executed via gradle, it throws" +
			"java.lang.NoClassDefFoundError: org/stagemonitor/core/Stagemonitor")
	public void testLogging() throws Exception {
		new LoggingPlugin().retransformLogger();

		logger.error("test");
		final SortedMap<String,Meter> meters = Stagemonitor.getMetricRegistry().getMeters();
		assertEquals(1, meters.size());
		assertNotNull(meters.get("logging.error"));
		assertEquals(1, meters.get("logging.error").getCount());
	}
}

@@ -237,56 +237,8 @@
 re;%0A
-import org.junit.Ignore;%0Aimport org.junit.Test;%0A
 impo
@@ -551,26 +551,9 @@
 IXME
-%0A%09@Test%0A%09@Ignore(%22
+ 
 when
@@ -587,16 +587,13 @@
 rows
-%22 +%0A%09%09%09%22
+%0A%09// 
 java
@@ -654,18 +654,26 @@
 emonitor
-%22)
+%0A%09// @Test
 %0A%09public

Exclude MeterLoggingInstrumenterTest