@@ -0,0 +1,1477 @@
+package com.librato.metrics;%0A%0Aimport com.codahale.metrics.Gauge;%0Aimport com.codahale.metrics.MetricFilter;%0Aimport com.codahale.metrics.MetricRegistry;%0Aimport junit.framework.TestCase;%0Aimport org.hamcrest.CoreMatchers;%0Aimport org.junit.Assert;%0A%0Aimport java.io.IOException;%0Aimport java.util.SortedMap;%0Aimport java.util.concurrent.Future;%0Aimport java.util.concurrent.atomic.AtomicInteger;%0A%0Apublic class LibratoReporterTest extends TestCase %7B%0A%0A    class FailingRegistry extends MetricRegistry %7B%0A        AtomicInteger timesAttempted = new AtomicInteger();%0A%0A        @Override%0A        public SortedMap%3CString, Gauge%3E getGauges(MetricFilter filter) %7B%0A            timesAttempted.addAndGet(1);%0A            throw new RuntimeException(%22test-exception%22);%0A        %7D%0A    %7D%0A%0A    public void testIsResilientToExceptionsInReport() throws Exception %7B%0A        FailingRegistry registry = new FailingRegistry();%0A        HttpPoster poster = new HttpPoster() %7B%0A            public Future%3CResponse%3E post(String userAgent, String payload) throws IOException %7B%0A                return null;%0A            %7D%0A        %7D;%0A        LibratoReporter reporter = LibratoReporter.builder(registry, %22test-username%22, %22test-token%22, %22test-source%22)%0A                .setHttpPoster(poster)%0A                .build();%0A        // assert that it doesn't throw an exception%0A        reporter.report();%0A        // verify the failure occurred%0A        Assert.assertThat(registry.timesAttempted.get(), CoreMatchers.equalTo(1));%0A    %7D%0A%7D%0A

Test case for librato-reporter not failing from report