### Question:
MeteredStaticMethodWithExceptions { @ExceptionMetered(name = "illegalArgumentExceptionMeteredStaticMethod", cause = IllegalArgumentException.class) public static void illegalArgumentExceptionMeteredStaticMethod(Runnable runnable) { runnable.run(); }  @ExceptionMetered(name = "illegalArgumentExceptionMeteredStaticMethod", cause = IllegalArgumentException.class) static void illegalArgumentExceptionMeteredStaticMethod(Runnable runnable); @ExceptionMetered(name = "exceptionMeteredStaticMethod", cause = Exception.class) static void exceptionMeteredStaticMethod(Runnable runnable);  }### Answer:
@Test public void callExceptionMeteredStaticMethodOnceWithThrowingExpectedException() { final RuntimeException exception = new IllegalArgumentException("message"); Runnable runnableThatThrowsIllegalArgumentException = new Runnable() { @Override public void run() { throw exception; } }; try { MeteredStaticMethodWithExceptions.illegalArgumentExceptionMeteredStaticMethod(runnableThatThrowsIllegalArgumentException); } catch (RuntimeException cause) { assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME)); MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME); assertThat("Meters are not registered correctly", registry.getMeters().keySet(), is(equalTo(absoluteMetricNames()))); assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName(0)).getCount(), is(equalTo(METER_COUNTS[0].incrementAndGet()))); assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName(1)).getCount(), is(equalTo(METER_COUNTS[1].get()))); assertSame("Exception thrown is incorrect", cause, exception); return; } fail("No exception has been re-thrown!"); }
@Test public void callExceptionMeteredStaticMethodOnceWithThrowingNonExpectedException() { final RuntimeException exception = new IllegalStateException("message"); Runnable runnableThatThrowsIllegalStateException = new Runnable() { @Override public void run() { throw exception; } }; try { MeteredStaticMethodWithExceptions.illegalArgumentExceptionMeteredStaticMethod(runnableThatThrowsIllegalStateException); } catch (RuntimeException cause) { assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME)); MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME); assertThat("Meters are not registered correctly", registry.getMeters().keySet(), is(equalTo(absoluteMetricNames()))); assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName(0)).getCount(), is(equalTo(METER_COUNTS[0].get()))); assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName(1)).getCount(), is(equalTo(METER_COUNTS[1].get()))); assertSame("Exception thrown is incorrect", cause, exception); return; } fail("No exception has been re-thrown!"); }