Package org.jbehave.examples.core.guice

Source Code of org.jbehave.examples.core.guice.CoreStoriesUsingGuice

package org.jbehave.examples.core.guice;

import java.util.List;

import org.jbehave.core.io.StoryFinder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.guice.GuiceStepsFactory;
import org.jbehave.examples.core.CoreStories;
import org.jbehave.examples.core.guice.AnnotatedEmbedderUsingGuice.StepsModule;

import com.google.inject.Guice;
import com.google.inject.Injector;

import static org.jbehave.core.io.CodeLocations.codeLocationFromPath;

/**
* Run core stories using GuiceStepsFactory. The textual core stories are
* exactly the same ones found in the core example. Here we are only
* concerned with using the container to compose the steps instances.
*/
public class CoreStoriesUsingGuice extends CoreStories {

    @Override
    public InjectableStepsFactory stepsFactory() {
        return new GuiceStepsFactory(configuration(), createInjector());
    }

    private Injector createInjector() {
        return Guice.createInjector(new StepsModule());
    }

    @Override
    protected List<String> storyPaths() {
        return new StoryFinder().findPaths(codeLocationFromPath("../core/src/main/java"), "**/*.story", "");
    }

}
TOP

Related Classes of org.jbehave.examples.core.guice.CoreStoriesUsingGuice

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.