PonyServiceRegistry { public static <T extends PonyService> T getPonyService(final Class<T> clazz) { final T ponyService = (T) registeredServices.get(clazz); if (ponyService != null) return ponyService; else throw new IllegalArgumentException("Service not registered #" + clazz.getCanonicalName()); }  static void registerPonyService(final PonyService service); static T getPonyService(final Class<T> clazz);  }
@Test(expected = IllegalArgumentException.class) public void testGetNotUnregistedPonyService() { PonyServiceRegistry.getPonyService(ServiceA.class); }