Search in sources :

Example 1 with BackendSupplier

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);
}
Also used : BackendSupplier(io.cucumber.core.runtime.BackendSupplier) ObjectFactoryServiceLoader(io.cucumber.core.runtime.ObjectFactoryServiceLoader) SingletonRunnerSupplier(io.cucumber.core.runtime.SingletonRunnerSupplier) SingletonObjectFactorySupplier(io.cucumber.core.runtime.SingletonObjectFactorySupplier) ThreadLocalObjectFactorySupplier(io.cucumber.core.runtime.ThreadLocalObjectFactorySupplier) EventBus(io.cucumber.core.eventbus.EventBus) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) ExitStatus(io.cucumber.core.runtime.ExitStatus) ThreadLocalRunnerSupplier(io.cucumber.core.runtime.ThreadLocalRunnerSupplier) CucumberExecutionContext(io.cucumber.core.runtime.CucumberExecutionContext) SingletonRunnerSupplier(io.cucumber.core.runtime.SingletonRunnerSupplier) RunnerSupplier(io.cucumber.core.runtime.RunnerSupplier) ThreadLocalRunnerSupplier(io.cucumber.core.runtime.ThreadLocalRunnerSupplier) BackendServiceLoader(io.cucumber.core.runtime.BackendServiceLoader) PluginFactory(io.cucumber.core.plugin.PluginFactory) SingletonObjectFactorySupplier(io.cucumber.core.runtime.SingletonObjectFactorySupplier) ObjectFactorySupplier(io.cucumber.core.runtime.ObjectFactorySupplier) ThreadLocalObjectFactorySupplier(io.cucumber.core.runtime.ThreadLocalObjectFactorySupplier) Plugins(io.cucumber.core.plugin.Plugins)

Example 2 with BackendSupplier

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);
}
Also used : BackendSupplier(io.cucumber.core.runtime.BackendSupplier) ObjectFactoryServiceLoader(io.cucumber.core.runtime.ObjectFactoryServiceLoader) ZoneId(java.time.ZoneId) SingletonObjectFactorySupplier(io.cucumber.core.runtime.SingletonObjectFactorySupplier) EventBus(io.cucumber.core.eventbus.EventBus) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) Clock(java.time.Clock) TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) ThreadLocalRunnerSupplier(io.cucumber.core.runtime.ThreadLocalRunnerSupplier) ExitStatus(io.cucumber.core.runtime.ExitStatus) CucumberExecutionContext(io.cucumber.core.runtime.CucumberExecutionContext) Filters(io.cucumber.core.filter.Filters) SingletonObjectFactorySupplier(io.cucumber.core.runtime.SingletonObjectFactorySupplier) ObjectFactorySupplier(io.cucumber.core.runtime.ObjectFactorySupplier) UUID(java.util.UUID) RuntimeOptions(io.cucumber.core.options.RuntimeOptions)

Aggregations

EventBus (io.cucumber.core.eventbus.EventBus)2 BackendSupplier (io.cucumber.core.runtime.BackendSupplier)2 CucumberExecutionContext (io.cucumber.core.runtime.CucumberExecutionContext)2 ExitStatus (io.cucumber.core.runtime.ExitStatus)2 ObjectFactoryServiceLoader (io.cucumber.core.runtime.ObjectFactoryServiceLoader)2 ObjectFactorySupplier (io.cucumber.core.runtime.ObjectFactorySupplier)2 SingletonObjectFactorySupplier (io.cucumber.core.runtime.SingletonObjectFactorySupplier)2 ThreadLocalRunnerSupplier (io.cucumber.core.runtime.ThreadLocalRunnerSupplier)2 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)2 Filters (io.cucumber.core.filter.Filters)1 RuntimeOptions (io.cucumber.core.options.RuntimeOptions)1 PluginFactory (io.cucumber.core.plugin.PluginFactory)1 Plugins (io.cucumber.core.plugin.Plugins)1 BackendServiceLoader (io.cucumber.core.runtime.BackendServiceLoader)1 RunnerSupplier (io.cucumber.core.runtime.RunnerSupplier)1 SingletonRunnerSupplier (io.cucumber.core.runtime.SingletonRunnerSupplier)1 ThreadLocalObjectFactorySupplier (io.cucumber.core.runtime.ThreadLocalObjectFactorySupplier)1 Clock (java.time.Clock)1 ZoneId (java.time.ZoneId)1 UUID (java.util.UUID)1