assertEquals(0, overloaded_param.getCount());
}
@Test
public void overloadedExceptionMeteredMethod() throws Throwable {
Meter overloaded = metricRegistry.getMeters().get(MetricRegistry.name(MeteredClass.class.getCanonicalName(), "overloaded-exception-metered"));
Meter overloaded_param = metricRegistry.getMeters().get(
MetricRegistry.name(MeteredClass.class.getCanonicalName(), "overloaded-exception-metered-param"));
assertEquals(0, overloaded.getCount());
assertEquals(0, overloaded_param.getCount());
// doesn't throw an exception
meteredClass.overloadedExceptionMeteredMethod(null);
assertEquals(0, overloaded.getCount());
assertEquals(0, overloaded_param.getCount());
// throws the wrong exception
try {
meteredClass.overloadedExceptionMeteredMethod(RuntimeException.class);
fail();
}
catch (Throwable t) {
assertTrue(t instanceof RuntimeException);
}
assertEquals(0, overloaded.getCount());
assertEquals(0, overloaded_param.getCount());
// throws the right exception
try {
meteredClass.overloadedExceptionMeteredMethod(BogusException.class);
fail();
}
catch (Throwable t) {
assertTrue(t instanceof BogusException);
}
assertEquals(1, overloaded.getCount());
assertEquals(0, overloaded_param.getCount());
// doesn't throw an exception
meteredClass.overloadedExceptionMeteredMethod(null, 1);
assertEquals(1, overloaded.getCount());
assertEquals(0, overloaded_param.getCount());
// throws the wrong exception
try {
meteredClass.overloadedExceptionMeteredMethod(RuntimeException.class, 1);
fail();
}
catch (Throwable t) {
assertTrue(t instanceof RuntimeException);
}
assertEquals(1, overloaded.getCount());
assertEquals(0, overloaded_param.getCount());
// throws the right exception
try {
meteredClass.overloadedExceptionMeteredMethod(BogusException.class, 1);
fail();
}
catch (Throwable t) {
assertTrue(t instanceof BogusException);
}
assertEquals(1, overloaded.getCount());
assertEquals(1, overloaded_param.getCount());
}