Search in sources :

Example 21 with Embedder

use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.

the class EmbedderTaskBehaviour method shouldCreateNewEmbedderWithExecutors.

@Test
public void shouldCreateNewEmbedderWithExecutors() {
    // Given
    AbstractEmbedderTask task = new AbstractEmbedderTask() {
    };
    // When
    task.setExecutorsClass(MyExecutors.class.getName());
    Embedder embedder = task.newEmbedder();
    // Then
    assertThat(embedder.executorService(), sameInstance(EXECUTOR_SERVICE));
}
Also used : Embedder(org.jbehave.core.embedder.Embedder) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) Test(org.junit.Test)

Example 22 with Embedder

use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.

the class EmbedderTaskBehaviour method shouldCreateNewEmbedderWithSystemProperties.

@Test
public void shouldCreateNewEmbedderWithSystemProperties() throws IOException {
    // Given
    AbstractEmbedderTask task = new AbstractEmbedderTask() {
    };
    // When
    Properties systemProperties = new Properties();
    systemProperties.setProperty("one", "1");
    systemProperties.setProperty("two", "2");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    systemProperties.store(out, "");
    task.setSystemProperties(out.toString());
    Embedder embedder = task.newEmbedder();
    // Then
    assertThat(embedder.systemProperties(), equalTo(systemProperties));
}
Also used : Embedder(org.jbehave.core.embedder.Embedder) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Properties(java.util.Properties) Test(org.junit.Test)

Example 23 with Embedder

use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.

the class AnnotationBuilder method buildEmbedder.

public Embedder buildEmbedder() {
    if (!finder.isAnnotationPresent(UsingEmbedder.class)) {
        return defaultEmbedder();
    }
    boolean batch = control(finder, "batch");
    boolean skip = control(finder, "skip");
    boolean generateViewAfterStories = control(finder, "generateViewAfterStories");
    boolean ignoreFailureInStories = control(finder, "ignoreFailureInStories");
    boolean ignoreFailureInView = control(finder, "ignoreFailureInView");
    boolean verboseFailures = control(finder, "verboseFailures");
    boolean verboseFiltering = control(finder, "verboseFiltering");
    String storyTimeouts = finder.getAnnotatedValue(UsingEmbedder.class, String.class, "storyTimeouts");
    long storyTimeoutInSecs = finder.getAnnotatedValue(UsingEmbedder.class, Long.class, "storyTimeoutInSecs");
    String storyTimeoutInSecsByPath = finder.getAnnotatedValue(UsingEmbedder.class, String.class, "storyTimeoutInSecsByPath");
    boolean failOnStoryTimeout = control(finder, "failOnStoryTimeout");
    int threads = finder.getAnnotatedValue(UsingEmbedder.class, Integer.class, "threads");
    Embedder embedder = embedder();
    EmbedderControls embedderControls = embedder.embedderControls();
    embedderControls.doBatch(batch).doSkip(skip).doGenerateViewAfterStories(generateViewAfterStories).doIgnoreFailureInStories(ignoreFailureInStories).doIgnoreFailureInView(ignoreFailureInView).doVerboseFailures(verboseFailures).doVerboseFiltering(verboseFiltering).doFailOnStoryTimeout(failOnStoryTimeout).useThreads(threads);
    if (storyTimeoutInSecs != 0) {
        embedderControls.useStoryTimeoutInSecs(storyTimeoutInSecs);
    }
    if (StringUtils.isNotBlank(storyTimeoutInSecsByPath)) {
        embedderControls.useStoryTimeoutInSecsByPath(storyTimeoutInSecsByPath);
    }
    if (StringUtils.isNotBlank(storyTimeouts)) {
        embedderControls.useStoryTimeouts(storyTimeouts);
    }
    Configuration configuration = buildConfiguration();
    embedder.useConfiguration(configuration);
    boolean useStepsFactory = finder.getAnnotatedValue(UsingEmbedder.class, Boolean.class, "stepsFactory");
    if (useStepsFactory) {
        embedder.useStepsFactory(buildStepsFactory(configuration));
    } else {
        embedder.useCandidateSteps(buildCandidateSteps(configuration));
    }
    List<String> metaFilters = finder.getAnnotatedValues(UsingEmbedder.class, String.class, "metaFilters");
    if (!metaFilters.isEmpty()) {
        embedder.useMetaFilters(metaFilters);
    }
    Properties systemProperties = loadProperties(finder.getAnnotatedValue(UsingEmbedder.class, String.class, "systemProperties"));
    if (!systemProperties.isEmpty()) {
        embedder.useSystemProperties(systemProperties);
    }
    return embedder;
}
Also used : UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) Embedder(org.jbehave.core.embedder.Embedder) ConfigurableEmbedder(org.jbehave.core.ConfigurableEmbedder) EmbedderControls(org.jbehave.core.embedder.EmbedderControls) Properties(java.util.Properties)

Example 24 with Embedder

use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.

the class MapStoriesAsEmbeddables method execute.

public void execute() throws BuildException {
    Embedder embedder = newEmbedder();
    log("Mapping stories as embeddables using embedder " + embedder, MSG_INFO);
    embedder.runAsEmbeddables(classNames());
}
Also used : Embedder(org.jbehave.core.embedder.Embedder)

Example 25 with Embedder

use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.

the class MapStoriesAsPaths method execute.

public void execute() throws BuildException {
    Embedder embedder = newEmbedder();
    log("Mapping stories as paths using embedder " + embedder, MSG_INFO);
    embedder.mapStoriesAsPaths(storyPaths());
}
Also used : Embedder(org.jbehave.core.embedder.Embedder)

Aggregations

Embedder (org.jbehave.core.embedder.Embedder)56 Test (org.junit.Test)33 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)25 ConfigurableEmbedder (org.jbehave.core.ConfigurableEmbedder)10 MojoFailureException (org.apache.maven.plugin.MojoFailureException)8 EmbedderControls (org.jbehave.core.embedder.EmbedderControls)7 Configuration (org.jbehave.core.configuration.Configuration)6 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)6 File (java.io.File)5 Properties (java.util.Properties)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)5 CandidateSteps (org.jbehave.core.steps.CandidateSteps)5 StoryPathResolver (org.jbehave.core.io.StoryPathResolver)4 HashSet (java.util.HashSet)3 Artifact (org.apache.maven.artifact.Artifact)3 Build (org.apache.maven.model.Build)3 MavenProject (org.apache.maven.project.MavenProject)3 ArchiverManager (org.codehaus.plexus.archiver.manager.ArchiverManager)3 StoryFinder (org.jbehave.core.io.StoryFinder)3