Package org.jbehave.core.io

Examples of org.jbehave.core.io.StoryLocation


    @Test
    public void shouldCreateAndWriteToFilePrintStreamForStoryLocation() throws IOException {

        // Given
        String storyPath = storyPath(MyStory.class);
        FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(CodeLocations.codeLocationFromClass(this.getClass()), storyPath));
        File file = factory.outputFile();
        file.delete();
        assertThat(file.exists(), is(false));
       
        // When
View Full Code Here


   
    @Test
    public void shouldBuildPrintStreamReportersAndOverrideDefaultForAGivenFormat() throws IOException {
        final String storyPath = storyPath(MyStory.class);
        final FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(CodeLocations.codeLocationFromClass(this.getClass()), storyPath));
        StoryReporter reporter = new StoryReporterBuilder() {
            @Override
            public StoryReporter reporterFor(String storyPath, org.jbehave.core.reporters.Format format) {
                if (format == org.jbehave.core.reporters.Format.TXT) {
                    factory.useConfiguration(new FilePrintStreamFactory.FileConfiguration("text"));
View Full Code Here

        final OutputStream out = new ByteArrayOutputStream();

        StoryReporterBuilder builder = new StoryReporterBuilder() {
            @Override
            protected FilePrintStreamFactory filePrintStreamFactory(String storyPath) {
                return new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath)) {
                    @Override
                    public PrintStream createPrintStream() {
                        return new PrintStream(out);
                    }
                };
View Full Code Here

    @Test
    public void shouldBuildWithCustomReporterForAGivenFormat() throws IOException {
        // Given
        String storyPath = storyPath(MyStory.class);
        final FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(
                CodeLocations.codeLocationFromClass(MyStory.class), storyPath));
        final StoryReporter txtReporter = new TxtOutput(factory.createPrintStream(), new Properties(),
                new LocalizedKeywords(), true);
        StoryReporterBuilder builder = new StoryReporterBuilder() {
            @Override
View Full Code Here

    @Test
    public void shouldBuildWithCustomReportersAsProvidedFormat() throws IOException {
        // Given
        String storyPath = storyPath(MyStory.class);
        FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(
                CodeLocations.codeLocationFromClass(MyStory.class), storyPath));
        StoryReporter txtReporter = new TxtOutput(factory.createPrintStream(), new Properties(),
                new LocalizedKeywords(), true);
        StoryReporter htmlReporter = new TxtOutput(factory.createPrintStream(), new Properties(),
                new LocalizedKeywords(), true);
View Full Code Here

        URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
        String storyPath = "org/jbehave/examples/trader/stories/my_given.story";
        FileConfiguration configuration = new FileConfiguration("ext");
       
        // When
        FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath), configuration);
        assertThat(factory.configuration(), equalTo(configuration));       
        FileConfiguration newConfiguration = new FileConfiguration();
        factory.useConfiguration(newConfiguration);
       
        // Then
View Full Code Here

        // Given
        URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
        String extension = "ext";       
        FileConfiguration configuration = (pathResolver != null ? new FileConfiguration("", extension, pathResolver) : new FileConfiguration(extension));
        // When
        FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath), configuration);
        // Then
        assertThat(factory.outputName(), equalTo(outputName));
    }
View Full Code Here

    public void shouldFailIfPrintStreamCannotBeCreated(){
        // Given
        URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
        String storyPath = "org/jbehave/examples/trader/stories/my_given.story";
        FileConfiguration configuration = new FileConfiguration("ext");
        FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath), configuration){
            protected File outputDirectory() {
                return new File((String)null);
            }
        };
        // When
View Full Code Here

        // Then fail as expected
    }

    private void ensureOutputFileIsSame(URL codeLocation, String storyPath) {
        FileConfiguration configuration = new FileConfiguration("ext");
        FilePrintStreamFactory factory = new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath), configuration);
        factory.createPrintStream();
        File outputFile = factory.getOutputFile();
        String expected = new File(codeLocation.getFile()).getParent().replace('\\', '/') + "/" + configuration.getRelativeDirectory() + "/"
                + "org.jbehave.examples.trader.stories.my_given." + configuration.getExtension();
        assertThat(outputFile.toString().replace('\\', '/'), equalTo(expected));
View Full Code Here

        FilePrintStreamFactory factory = filePrintStreamFactory(storyPath);
        return format.createStoryReporter(factory, this);
    }

    protected FilePrintStreamFactory filePrintStreamFactory(String storyPath) {
        return new FilePrintStreamFactory(new StoryLocation(codeLocation, storyPath), fileConfiguration(""));
    }
View Full Code Here

TOP

Related Classes of org.jbehave.core.io.StoryLocation

Copyright © 2018 www.massapicom. 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.