StandaloneHelper { static public Class<? extends Standalone> resolveStandaloneClass() { return resolveStandaloneClass( System.getProperty(Standalone.KEY_NINJA_STANDALONE_CLASS), ForwardingServiceLoader.loadWithSystemServiceLoader(Standalone.class), Standalone.DEFAULT_STANDALONE_CLASS ); }  static int findAvailablePort(int min, int max); static Class<? extends Standalone> resolveStandaloneClass(); static Standalone create(Class<? extends Standalone> standaloneClass); static InputStream openKeyStoreInput(URI uri); static KeyStore loadKeyStore(URI uri, char[] password); static SSLContext createSSLContext(
            URI keystoreUri, char[] keystorePassword,
            URI truststoreUri, char[] truststorePassword);  }
@Test public void resolveStandaloneClass() throws Exception { Class<? extends Standalone> resolvedStandaloneClass; try { StandaloneHelper.resolveStandaloneClass("sys_prop_does_not_exist", null, null); fail(); } catch (Exception e) { assertThat(e.getMessage(), containsString("sys_prop_does_not_exist")); } ForwardingServiceLoader<Standalone> serviceLoader = mock(ForwardingServiceLoader.class); List<Standalone> standalones = new ArrayList<>(); standalones.add(new MockStandalone()); when(serviceLoader.iterator()).thenReturn(standalones.iterator()); resolvedStandaloneClass = StandaloneHelper.resolveStandaloneClass(null, serviceLoader, "default_does_not_exist"); assertThat(resolvedStandaloneClass.newInstance(), instanceOf(MockStandalone.class)); try { when(serviceLoader.iterator()).thenReturn(new ArrayList<Standalone>().iterator()); StandaloneHelper.resolveStandaloneClass(null, serviceLoader, "default_does_not_exist"); fail(); } catch (Exception e) { assertThat(e.getMessage(), containsString("default_does_not_exist")); } }