StdOutMetricsSender implements MetricsSender { @Override public String pushMetrics(String payload) { out.println("Sending to " + metricsHostName + ": " + payload); return "OK"; } StdOutMetricsSender(String metricsHostName);  StdOutMetricsSender(String metricsHostName, PrintStream out); @Override String pushMetrics(String payload); final PrintStream out; }
@Test public void testPushMetrics() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream out = new PrintStream(baos); StdOutMetricsSender sender = new StdOutMetricsSender("expectedHostName", out); sender.pushMetrics("test"); System.out.println(baos.toString()); }