AbstractRemoteCache { public static AbstractRemoteCache getInstance() { String className = AppSettings.getInstance().getString(AppSettings.REMOTE_CACHE); if (instance == null || !className.equals(instance.getClass().getCanonicalName())) { instance = (AbstractRemoteCache) InstanceUtils.invokeConstructor(className); } return instance; }  abstract byte[] get(String key); abstract void set(String key, byte[] value); abstract void set(String key, byte[] value, int expireIn); abstract void delete(String key); abstract Lock acquireLock(String lockName); abstract CheckResult checkConnection(); static AbstractRemoteCache getInstance();  }
@Test public void testGetInstance() { try(SettingsOverride override = SettingsOverride.apply(Map.of(AppSettings.REMOTE_CACHE, "com.example.DoesNotExist"))) { try { AbstractRemoteCache.getInstance(); fail(); } catch (RuntimeException e) { assertEquals("java.lang.ClassNotFoundException: com.example.DoesNotExist", e.getMessage()); } } }