Package org.jbehave.core.io

Examples of org.jbehave.core.io.ResourceLoader


    }

    @Test
    public void shouldCreateExamplesTableFromResourceInput() {
        // Given
        ResourceLoader resourceLoader = mock(ResourceLoader.class);
        ExamplesTableFactory factory = new ExamplesTableFactory(resourceLoader);
       
        // When
        String resourcePath = "/path/to/table";
        when(resourceLoader.loadResourceAsText(resourcePath)).thenReturn(tableAsString);
        ExamplesTable examplesTable = factory.createExamplesTable(resourcePath);
       
        // Then
        assertThat(examplesTable.asString(), equalTo(tableAsString));
    }
View Full Code Here


    }
  }

  private ResourceImporter createImporter() {
    ResourceIndexer indexer = newResourceIndexer();
    ResourceLoader loader = newResourceLoader();
    getLog().info(
        "Creating importer to filesystem using REST provider "
            + restProvider + " with resourcesPath " + resourcesPath
            + " and resourcesExt " + resourcesExt);
    return new ImportToFilesystem(indexer, loader, resourcesPath, resourcesExt);
View Full Code Here

    @Test
    public void canImportToFilesystem() throws IOException {

        // Given
        ResourceIndexer indexer = mock(ResourceIndexer.class);
        ResourceLoader loader = mock(ResourceLoader.class);
        String rootURI = "http://wiki";
        Map<String, Resource> index = new HashMap<String, Resource>();
        index.put("one", new Resource(rootURI + "/one"));
        index.put("two", new Resource(rootURI + "/two"));
        when(indexer.indexResources(rootURI)).thenReturn(index);
        String text1 = "story text 1";
        when(loader.loadResourceAsText(index.get("one").getURI())).thenReturn(text1);
        String text2 = "story text 2";
        when(loader.loadResourceAsText(index.get("two").getURI())).thenReturn(text2);

        // When
        String targetPath = "target/stories";
        String targetExt = ".story";
        ResourceImporter importer = new ImportToFilesystem(indexer, loader, targetPath, targetExt);
View Full Code Here

      RESTClient client = mock(RESTClient.class);
      when(client.getType()).thenReturn(Type.JSON);
      String url = "http://wiki/page";
        String entity = "Some content";
        when(client.get(url)).thenReturn(entity);
    ResourceLoader loader = new LoadFromREST(client);
    String text = loader.loadResourceAsText(url);
    assertThat(text, containsString(entity));
  }
View Full Code Here

    @Test
    public void canImportToFilesystem() throws IOException, MojoExecutionException, MojoFailureException {

        // Given
        final ResourceIndexer indexer = mock(ResourceIndexer.class);
        final ResourceLoader loader = mock(ResourceLoader.class);
        String rootURI = "http://wiki";
        Map<String, Resource> index = new HashMap<String, Resource>();
        index.put("one", new Resource(rootURI + "/one"));
        index.put("two", new Resource(rootURI + "/two"));
        when(indexer.indexResources(rootURI)).thenReturn(index);
        String text1 = "story text 1";
        when(loader.loadResourceAsText(index.get("one").getURI())).thenReturn(text1);
        String text2 = "story text 2";
        when(loader.loadResourceAsText(index.get("two").getURI())).thenReturn(text2);

        // When
        String targetPath = "target/stories";
        String targetExt = ".story";
        ImportToFilesystemMojo mojo = new ImportToFilesystemMojo(){
View Full Code Here

    assertThat(index.isEmpty(), is(false));
  }

  @When("story $name text contains '$text'")
  public void storyIsLoaded(String name, String text) {
    ResourceLoader loader = resourceLoader();
    Resource resource = index.get(name);
    String asText = loader.loadResourceAsText(resource.getURI());
    assertThat(asText, containsString(text));
  }
View Full Code Here

TOP

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

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.