Collection<? extends MutationEngineFactory> findMutationEngines() { return ServiceLoader.load(MutationEngineFactory.class, this.loader); }
private static <S> Collection<S> loadImpl(final Class<S> ifc, final ClassLoader loader) throws IOException { final Enumeration<URL> e = loader.getResources("META-INF/services/" + ifc.getName()); final Collection<S> services = new ArrayList<>(); while (e.hasMoreElements()) { final URL url = e.nextElement(); try (InputStream is = url.openStream()) { createServicesFromStream(ifc, loader, services, is); } } return services; }
public static <S> Collection<S> load(final Class<S> ifc, final ClassLoader loader) { try { return loadImpl(ifc, loader); } catch (final IOException ex) { throw new PitError("Error creating service " + ifc.getName(), ex); } }
private static <S> void createServicesFromStream(final Class<S> ifc, final ClassLoader loader, final Collection<S> services, final InputStream is) throws IOException { final BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8")); while (true) { String line = r.readLine(); if (line == null) { break; } final int comment = line.indexOf('#'); if (comment >= 0) { line = line.substring(0, comment); } final String name = line.trim(); if (name.length() == 0) { continue; } services.add(createService(name, ifc, loader)); } }
public static <S> Collection<S> load(final Class<S> ifc, final ClassLoader loader) { try { return loadImpl(ifc, loader); } catch (final IOException ex) { throw new PitError("Error creating service " + ifc.getName(), ex); } }
private static <S> void createServicesFromStream(final Class<S> ifc, final ClassLoader loader, final Collection<S> services, final InputStream is) throws IOException { final BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8")); while (true) { String line = r.readLine(); if (line == null) { break; } final int comment = line.indexOf('#'); if (comment >= 0) { line = line.substring(0, comment); } final String name = line.trim(); if (name.length() == 0) { continue; } services.add(createService(name, ifc, loader)); } }
Collection<? extends TestPluginFactory> findTestFrameworkPlugins() { return ServiceLoader.load(TestPluginFactory.class, this.loader); }
private static <S> Collection<S> loadImpl(final Class<S> ifc, final ClassLoader loader) throws IOException { final Enumeration<URL> e = loader.getResources("META-INF/services/" + ifc.getName()); final Collection<S> services = new ArrayList<>(); while (e.hasMoreElements()) { final URL url = e.nextElement(); try (InputStream is = url.openStream()) { createServicesFromStream(ifc, loader, services, is); } } return services; }
Collection<? extends MutationGrouperFactory> findGroupers() { return ServiceLoader.load(MutationGrouperFactory.class, this.loader); }
Collection<? extends TestPluginFactory> findTestFrameworkPlugins() { return ServiceLoader.load(TestPluginFactory.class, this.loader); }
Collection<? extends MutationResultListenerFactory> findListeners() { return ServiceLoader.load(MutationResultListenerFactory.class, this.loader); }
private Collection<ClientClasspathPlugin> nullPlugins() { return ServiceLoader.load(ClientClasspathPlugin.class, this.loader); }
public Collection<? extends MutationInterceptorFactory> findInterceptors() { return ServiceLoader.load(MutationInterceptorFactory.class, this.loader); }
Collection<? extends MutationEngineFactory> findMutationEngines() { return ServiceLoader.load(MutationEngineFactory.class, this.loader); }
Collection<? extends TestPrioritiserFactory> findTestPrioritisers() { return ServiceLoader.load(TestPrioritiserFactory.class, this.loader); }
public static <S> Collection<S> load(final Class<S> ifc) { return load(ifc, Thread.currentThread().getContextClassLoader()); }
@Test public void shouldReturnNoValuesWhenNoServicesFounds() throws Exception { final Iterable<AService> actual = ServiceLoader.load(AService.class, Thread .currentThread().getContextClassLoader()); assertFalse(actual.iterator().hasNext()); }
@Test public void shouldReturnValueWhenServiceFound() throws Exception { final Iterable<MutationEngineFactory> actual = ServiceLoader.load( MutationEngineFactory.class, Thread.currentThread() .getContextClassLoader()); assertTrue(actual.iterator().hasNext()); }
Collection<? extends TestPluginFactory> findTestFrameworkPlugins() { return ServiceLoader.load(TestPluginFactory.class, this.loader); }
Collection<? extends MutationEngineFactory> findMutationEngines() { return ServiceLoader.load(MutationEngineFactory.class, this.loader); }