@Test public void anExceptionMeteredAnnotatedMethod_WithPublicScopeButNoExceptionThrown() throws Exception { final Metric metric = registry .allMetrics() .get(new MetricName(InstrumentedWithExceptionMetered.class, "exceptionCounter")); assertMetricIsSetup(metric); assertThat("Metric intialises to zero", ((Meter) metric).count(), is(0L)); instance.explodeWithPublicScope(false); assertThat( "Metric should remain at zero if no exception is thrown", ((Meter) metric).count(), is(0L)); }
@Test public void anExceptionMeteredAnnotatedMethodWithPublicScope() throws Exception { final Metric metric = registry .allMetrics() .get(new MetricName(InstrumentedWithExceptionMetered.class, "exceptionCounter")); assertMetricIsSetup(metric); assertThat("Metric intialises to zero", ((Meter) metric).count(), is(0L)); try { instance.explodeWithPublicScope(true); fail("Expected an exception to be thrown"); } catch (RuntimeException e) { // Swallow the expected exception } assertThat("Metric is marked", ((Meter) metric).count(), is(1L)); }