### Question:
DropwizardMetricsFactoryService implements MetricsFactoryService { @Override public MetricsFactory load() { return ClassLoaderUtils.findClass(METRICS_CLASS_NAME) ? DropwizardMetrics.FACTORY : null; }  @Override MetricsFactory load(); static final String METRICS_CLASS_NAME; }### Answer:
@Test public void testLoadSuccess() { MetricsFactory metricsFactory = new DropwizardMetricsFactoryService().load(); assertNotNull(metricsFactory); assertSame(DropwizardMetrics.FACTORY, metricsFactory); }
@Test public void testLoadFailure() { ClassLoader currentClassLoader = ClassLoaderUtils.getClassLoader(); try { Thread.currentThread().setContextClassLoader(new ClassLoader() { @Override protected Class loadClass(String class_name, boolean resolve) throws ClassNotFoundException { if(class_name.equals(METRICS_CLASS_NAME)) { return null; } return super.loadClass(class_name, resolve); } }); MetricsFactory metricsFactory = new DropwizardMetricsFactoryService().load(); assertNull(metricsFactory); } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } }