/** * Dynamically loads an instance of a test runner. * * @return A Initialized TestRunner * * @throws IllegalStateException * if multiple TestRunners found in classpath. */ public static TestRunner getTestRunner(ClassLoader classLoader) { ServiceLoader<TestRunner> serviceLoader = ServiceLoader.load(TestRunner.class, classLoader); if (serviceLoader.getProviders().size() > 1) { throw new IllegalStateException("Multiple TestRunners found, only one allowed. Check your classpath"); } return serviceLoader.iterator().next(); } }
/** * Creates a new service loader for the given service type and class loader. * * @param service * The interface or abstract class representing the service * @param loader * The class loader to be used to load provider-configuration * files and provider classes, or null if the system class loader * (or, failing that, the bootstrap class loader) is to be used * * @return A new service loader */ public static <S> ServiceLoader<S> load(Class<S> service, ClassLoader loader) { if (loader == null) { loader = service.getClassLoader(); } return new ServiceLoader<S>(service, loader); }
public Set<S> getProviders() { if (providers == null) { reload(); } return Collections.unmodifiableSet(providers); }
public ServiceLoader<AutomaticDeployment> find() { return ServiceLoader.load(AutomaticDeployment.class); } };
@Before public void setUpTest() { DeploymentConfiguration.DeploymentContentBuilder content = new DeploymentConfiguration.DeploymentContentBuilder(ShrinkWrap.create( JavaArchive.class)); when(automaticDeployment.generateDeploymentScenario(any(TestClass.class))).thenReturn(content.get()); final List<AutomaticDeployment> deploymentContents = new ArrayList<AutomaticDeployment>(); deploymentContents.add(automaticDeployment); when(automaticDeploymentLocator.find()).thenReturn(serviceLoader); when(serviceLoader.iterator()).thenReturn(deploymentContents.iterator()); }
providers.add(createInstance(line));
public ServiceLoader<AutomaticDeployment> find() { return ServiceLoader.load(AutomaticDeployment.class); } };
@Before public void setUpTest() { DeploymentConfiguration.DeploymentContentBuilder content = new DeploymentConfiguration.DeploymentContentBuilder(ShrinkWrap.create( JavaArchive.class)); when(automaticDeployment.generateDeploymentScenario(any(TestClass.class))).thenReturn(content.get()); final List<AutomaticDeployment> deploymentContents = new ArrayList<AutomaticDeployment>(); deploymentContents.add(automaticDeployment); when(automaticDeploymentLocator.find()).thenReturn(serviceLoader); when(serviceLoader.iterator()).thenReturn(deploymentContents.iterator()); }
providers.add(createInstance(line));
/** * Dynamically loads an instance of a test runner. * * @return A Initialized TestRunner * * @throws IllegalStateException * if multiple TestRunners found in classpath. */ public static TestRunner getTestRunner(ClassLoader classLoader) { ServiceLoader<TestRunner> serviceLoader = ServiceLoader.load(TestRunner.class, classLoader); if (serviceLoader.getProviders().size() > 1) { throw new IllegalStateException("Multiple TestRunners found, only one allowed. Check your classpath"); } return serviceLoader.iterator().next(); } }
/** * Creates a new service loader for the given service type, using the current * thread's context class loader. * <p> * An invocation of this convenience method of the form * <p> * {@code ServiceLoader.load(service)</code>} * <p> * is equivalent to * <p> * <code>ServiceLoader.load(service, * Thread.currentThread().getContextClassLoader())</code> * * @param service * The interface or abstract class representing the service * * @return A new service loader */ public static <S> ServiceLoader<S> load(Class<S> service) { return load(service, Thread.currentThread().getContextClassLoader()); }
public Set<S> getProviders() { if (providers == null) { reload(); } return Collections.unmodifiableSet(providers); }
/** * Creates a new service loader for the given service type and class loader. * * @param service * The interface or abstract class representing the service * @param loader * The class loader to be used to load provider-configuration * files and provider classes, or null if the system class loader * (or, failing that, the bootstrap class loader) is to be used * * @return A new service loader */ public static <S> ServiceLoader<S> load(Class<S> service, ClassLoader loader) { if (loader == null) { loader = service.getClassLoader(); } return new ServiceLoader<S>(service, loader); }
/** * Creates a new service loader for the given service type, using the current * thread's context class loader. * <p> * An invocation of this convenience method of the form * <p> * {@code ServiceLoader.load(service)</code>} * <p> * is equivalent to * <p> * <code>ServiceLoader.load(service, * Thread.currentThread().getContextClassLoader())</code> * * @param service * The interface or abstract class representing the service * * @return A new service loader */ public static <S> ServiceLoader<S> load(Class<S> service) { return load(service, Thread.currentThread().getContextClassLoader()); }
ArquillianConfig(Set<String> testClasses, String deploymentUnitName) { this.serviceName = getServiceName(deploymentUnitName); this.testClasses.addAll(testClasses); for(ArquillianConfigServiceCustomizer customizer : ServiceLoader.load(ArquillianConfigServiceCustomizer.class)) { serviceCustomizers.add(customizer); } }
ArquillianConfig(Set<String> testClasses, String deploymentUnitName) { this.serviceName = getServiceName(deploymentUnitName); this.testClasses.addAll(testClasses); for(ArquillianConfigServiceCustomizer customizer : ServiceLoader.load(ArquillianConfigServiceCustomizer.class)) { serviceCustomizers.add(customizer); } }