AbstractAuthenticationBackend { public static AbstractAuthenticationBackend getInstance() { String className = AppSettings.getInstance().getString(AppSettings.AUTHENTICATION_BACKEND); if (instance == null || !className.equals(instance.getClass().getCanonicalName())) { instance = (AbstractAuthenticationBackend) InstanceUtils.invokeConstructor(className); } return instance; }  static AbstractAuthenticationBackend getInstance(); String authenticateUser(); abstract String authenticateUser(String authorizationHeader); static final String AUTHENTICATED_USER; }
@Test public void testGetInstance() { try(SettingsOverride override = SettingsOverride.apply(Map.of(AppSettings.AUTHENTICATION_BACKEND, "com.example.DoesNotExist"))) { try { AbstractAuthenticationBackend.getInstance(); fail(); } catch (RuntimeException e) { assertEquals("java.lang.ClassNotFoundException: com.example.DoesNotExist", e.getMessage()); } } }