use of io.cucumber.core.runtime.BackendSupplier in project cucumber-jvm by cucumber.
the class CucumberEngineExecutionContext method createCucumberExecutionContext.
private CucumberExecutionContext createCucumberExecutionContext() {
Supplier<ClassLoader> classLoader = CucumberEngineExecutionContext.class::getClassLoader;
ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(classLoader, options);
EventBus bus = synchronize(new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID));
Plugins plugins = new Plugins(new PluginFactory(), options);
ExitStatus exitStatus = new ExitStatus(options);
plugins.addPlugin(exitStatus);
RunnerSupplier runnerSupplier;
if (options.isParallelExecutionEnabled()) {
plugins.setSerialEventBusOnEventListenerPlugins(bus);
ObjectFactorySupplier objectFactorySupplier = new ThreadLocalObjectFactorySupplier(objectFactoryServiceLoader);
BackendSupplier backendSupplier = new BackendServiceLoader(classLoader, objectFactorySupplier);
runnerSupplier = new ThreadLocalRunnerSupplier(options, bus, backendSupplier, objectFactorySupplier);
} else {
plugins.setEventBusOnEventListenerPlugins(bus);
ObjectFactorySupplier objectFactorySupplier = new SingletonObjectFactorySupplier(objectFactoryServiceLoader);
BackendSupplier backendSupplier = new BackendServiceLoader(classLoader, objectFactorySupplier);
runnerSupplier = new SingletonRunnerSupplier(options, bus, backendSupplier, objectFactorySupplier);
}
return new CucumberExecutionContext(bus, exitStatus, runnerSupplier);
}
use of io.cucumber.core.runtime.BackendSupplier in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method createFeatureRunner.
private FeatureRunner createFeatureRunner(Feature feature, JUnitOptions junitOption) {
ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(getClass()::getClassLoader, RuntimeOptions.defaultOptions());
ObjectFactorySupplier objectFactory = new SingletonObjectFactorySupplier(objectFactoryServiceLoader);
final RuntimeOptions runtimeOptions = RuntimeOptions.defaultOptions();
final Clock clockStub = new Clock() {
@Override
public ZoneId getZone() {
return null;
}
@Override
public Clock withZone(ZoneId zone) {
return null;
}
@Override
public Instant instant() {
return Instant.EPOCH;
}
};
BackendSupplier backendSupplier = () -> singleton(new StubBackendProviderService.StubBackend());
EventBus bus = new TimeServiceEventBus(clockStub, UUID::randomUUID);
Filters filters = new Filters(runtimeOptions);
ThreadLocalRunnerSupplier runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier, objectFactory);
CucumberExecutionContext context = new CucumberExecutionContext(bus, new ExitStatus(runtimeOptions), runnerSupplier);
return FeatureRunner.create(feature, null, filters, context, junitOption);
}
Aggregations