### Question:
MetricsStream extends PrintStream { void printMetric(String name, Object value) { print(name + " " + value + '\n'); scrapeCount++; } MetricsStream(HttpServletRequest request, OutputStream outputStream);   MetricsStream(HttpServletRequest request, OutputStream outputStream, PerformanceProbe performanceProbe);   }### Answer:
@Test public void whenMetricsPrinted_eachHasItsOwnLineSeparatedByCarriageReturns() { metrics.printMetric("a", 12); metrics.printMetric("b", 120); metrics.printMetric("c", 0); assertThat(getPrintedMetricValues(), hasItems("12", "120", "0", "3")); }
@Test public void whenMetricsPrintedOnWindows_eachHasItsOwnLineSeparatedByCarriageReturns() throws NoSuchFieldException { simulateWindows(); metrics.printMetric("a", 12); metrics.printMetric("b", 120); metrics.printMetric("c", 0); assertThat(getPrintedMetricValues(), hasItems("12", "120", "0", "3")); }
@Test public void afterMetricsScraped_reportScrapedCount() { metrics.printMetric("a", 12); metrics.printMetric("b", 120); metrics.printMetric("c", 0); assertThat(getPrintedMetrics(), containsString("wls_scrape_mbeans_count_total{instance=\"wlshost:7201\"} 3")); }