// Path: src/test/java/com/ryantenney/metrics/spring/reporter/FakeReporter.java
// public class FakeReporter extends ScheduledReporter {
// 
// 	private final MetricRegistry registry;
// 	private final MetricFilter filter;
// 	private final String prefix;
// 
// 	private long period;
// 	private int calls = 0;
// 	private boolean running = false;
// 
// 	public FakeReporter(MetricRegistry registry, MetricFilter filter, String prefix, TimeUnit rateUnit, TimeUnit durationUnit) {
// 		super(registry, "test-reporter", filter, rateUnit, durationUnit);
// 		this.registry = registry;
// 		this.filter = filter;
// 		this.prefix = prefix;
// 	}
// 
// 	public MetricRegistry getRegistry() {
// 		return registry;
// 	}
// 
// 	public MetricFilter getFilter() {
// 		return filter;
// 	}
// 
// 	public String getPrefix() {
// 		return prefix;
// 	}
// 
// 	@Override
// 	public String getRateUnit() {
// 		return super.getRateUnit();
// 	}
// 
// 	@Override
// 	public String getDurationUnit() {
// 		return super.getDurationUnit();
// 	}
// 
// 	public long getPeriod() {
// 		return period;
// 	}
// 
// 	public int getCalls() {
// 		return calls;
// 	}
// 
// 	public boolean isRunning() {
// 		return running;
// 	}
// 
// 	@Override
// 	public void start(final long period, final TimeUnit unit) {
// 		super.start(period, unit);
// 		this.period = unit.toNanos(period);
// 		this.running = true;
// 	}
// 
// 	@Override
// 	public void stop() {
// 		super.stop();
// 		this.running = false;
// 	}
// 
// 	@Override
// 	@SuppressWarnings("rawtypes")
// 	public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms,
// 			SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) {
// 		calls++;
// 	}
// 
// }
// 
// Path: src/main/java/com/ryantenney/metrics/spring/reporter/MetricPrefixSupplier.java
// public interface MetricPrefixSupplier {
// 
// 	String getPrefix();
// 
// }


import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Collection;
import com.palominolabs.metrics.newrelic.NewRelicReporter;
import org.coursera.metrics.datadog.DatadogReporter;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.CsvReporter;
import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.SharedMetricRegistries;
import com.codahale.metrics.Slf4jReporter;
import com.codahale.metrics.ganglia.GangliaReporter;
import com.codahale.metrics.graphite.GraphiteReporter;
import com.ryantenney.metrics.spring.reporter.FakeReporter;
import com.ryantenney.metrics.spring.reporter.MetricPrefixSupplier;
import static org.hamcrest.Matchers.*;
		try {
			ctx = new ClassPathXmlApplicationContext("classpath:reporter-placeholder-test.xml");

			@SuppressWarnings("resource")
			FakeReporter reporter = ctx.getBean(FakeReporter.class);
			Assert.assertEquals("nanoseconds", reporter.getDurationUnit());
			Assert.assertEquals("hour", reporter.getRateUnit());
			Assert.assertEquals(100000000, reporter.getPeriod());
			Assert.assertSame(ctx.getBean(BarFilter.class), reporter.getFilter());
		}
		finally {
			if (ctx != null) {
				ctx.close();
			}
		}
	}

	public static PrintStream testPrintStream() {
		return new PrintStream(new ByteArrayOutputStream());
	}

	public static class BarFilter implements MetricFilter {

		@Override
		public boolean matches(String name, Metric metric) {
			return false;
		}

	}

// Path: src/test/java/com/ryantenney/metrics/spring/reporter/FakeReporter.java
// public class FakeReporter extends ScheduledReporter {
// 
// 	private final MetricRegistry registry;
// 	private final MetricFilter filter;
// 	private final String prefix;
// 
// 	private long period;
// 	private int calls = 0;
// 	private boolean running = false;
// 
// 	public FakeReporter(MetricRegistry registry, MetricFilter filter, String prefix, TimeUnit rateUnit, TimeUnit durationUnit) {
// 		super(registry, "test-reporter", filter, rateUnit, durationUnit);
// 		this.registry = registry;
// 		this.filter = filter;
// 		this.prefix = prefix;
// 	}
// 
// 	public MetricRegistry getRegistry() {
// 		return registry;
// 	}
// 
// 	public MetricFilter getFilter() {
// 		return filter;
// 	}
// 
// 	public String getPrefix() {
// 		return prefix;
// 	}
// 
// 	@Override
// 	public String getRateUnit() {
// 		return super.getRateUnit();
// 	}
// 
// 	@Override
// 	public String getDurationUnit() {
// 		return super.getDurationUnit();
// 	}
// 
// 	public long getPeriod() {
// 		return period;
// 	}
// 
// 	public int getCalls() {
// 		return calls;
// 	}
// 
// 	public boolean isRunning() {
// 		return running;
// 	}
// 
// 	@Override
// 	public void start(final long period, final TimeUnit unit) {
// 		super.start(period, unit);
// 		this.period = unit.toNanos(period);
// 		this.running = true;
// 	}
// 
// 	@Override
// 	public void stop() {
// 		super.stop();
// 		this.running = false;
// 	}
// 
// 	@Override
// 	@SuppressWarnings("rawtypes")
// 	public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms,
// 			SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) {
// 		calls++;
// 	}
// 
// }
// 
// Path: src/main/java/com/ryantenney/metrics/spring/reporter/MetricPrefixSupplier.java
// public interface MetricPrefixSupplier {
// 
// 	String getPrefix();
// 
// }


// Path: src/test/java/com/ryantenney/metrics/spring/ReporterTest.java
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Collection;
import com.palominolabs.metrics.newrelic.NewRelicReporter;
import org.coursera.metrics.datadog.DatadogReporter;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.CsvReporter;
import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.SharedMetricRegistries;
import com.codahale.metrics.Slf4jReporter;
import com.codahale.metrics.ganglia.GangliaReporter;
import com.codahale.metrics.graphite.GraphiteReporter;
import com.ryantenney.metrics.spring.reporter.FakeReporter;
import com.ryantenney.metrics.spring.reporter.MetricPrefixSupplier;
import static org.hamcrest.Matchers.*;

		try {
			ctx = new ClassPathXmlApplicationContext("classpath:reporter-placeholder-test.xml");

			@SuppressWarnings("resource")
			FakeReporter reporter = ctx.getBean(FakeReporter.class);
			Assert.assertEquals("nanoseconds", reporter.getDurationUnit());
			Assert.assertEquals("hour", reporter.getRateUnit());
			Assert.assertEquals(100000000, reporter.getPeriod());
			Assert.assertSame(ctx.getBean(BarFilter.class), reporter.getFilter());
		}
		finally {
			if (ctx != null) {
				ctx.close();
			}
		}
	}

	public static PrintStream testPrintStream() {
		return new PrintStream(new ByteArrayOutputStream());
	}

	public static class BarFilter implements MetricFilter {

		@Override
		public boolean matches(String name, Metric metric) {
			return false;
		}

	}

	public static class TestMetricPrefixSupplier implements MetricPrefixSupplier {