Package org.jbehave.core.io.rest

Examples of org.jbehave.core.io.rest.Resource


        return result;
    }

    private void addPage(Map<String, Resource> result, String href, String pattern) {
        Page page = confluence.loadPage(href, true);
        Resource resource = new Resource(page.getSelfReference(), page.getTitle());
        resource.setContent(page.getBody());
        if (pattern == null ||
                (pattern != null && Pattern.matches(pattern, page.getTitle()))) {
            result.put(page.getTitle(), resource);
        }
        if (page.hasChildren()) {
View Full Code Here


    Collection<Page> pages = parse(entity);
    Map<String, Resource> index = new HashMap<String, Resource>();
    for (Page page : pages) {
      String parentName = (page.parent != null ? resolveName(page.parent) : null);
      String uri = format(PAGE_URI, rootURI, page.name);
      Resource resource = new Resource(uri, resolveName(page.name), parentName);
      index.put(resource.getName(), resource);
    }
    return index;
  }
View Full Code Here

        writeResources(index, targetPath, targetExt);
    }

    private void loadResources(Map<String, Resource> index) {
        for (String name : index.keySet()) {
            Resource resource = index.get(name);
            String text = loader.loadResourceAsText(resource.getURI());
            resource.setContent(text);
        }
    }
View Full Code Here

        }
    }

    private void writeResources(Map<String, Resource> index, String targetPath, String targetExt) {
        for (String name : index.keySet()) {
            Resource resource = index.get(name);
            writeResource(resource, asFile(resource, targetPath, targetExt));
        }
    }
View Full Code Here

    uploadResources(index);
  }

  private void uploadResources(Map<String, Resource> index) {
    for (String name : index.keySet()) {
      Resource resource = index.get(name);
      uploader.uploadResource(resource);
    }
  }
View Full Code Here

  }

  private void readResources(Map<String, Resource> index, String sourcePath,
      String sourceExt) {
    for (String name : index.keySet()) {
      Resource resource = index.get(name);
      readResource(resource, asFile(resource, sourcePath, sourceExt));
    }
  }
View Full Code Here

      Collection<Page> pages = parse(entity);
        Map<String, Resource> index = new HashMap<String, Resource>();
        for (Page page : pages) {
            String parentName = (page.parent != null ? resolveName(page.parent.title) : null);
            String uri = format(PAGE_URI, rootURI, page.title);
            Resource resource = new Resource(uri, resolveName(page.title), parentName);
            index.put(resource.getName(), resource);
        }
        return index;
    }
View Full Code Here

        // 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);
View Full Code Here

        File file1 = new File(sourcePath + "/A_story" + sourceExt);
        write(text1, file1);
        File file2 = new File(sourcePath + "/Another_story" + sourceExt);
        write(text2, file2);
        Map<String, Resource> index = new HashMap<String, Resource>();
        Resource aResource = new Resource(rootURI + "/A_story");
    index.put("A_story", aResource);
        Resource anotherResource = new Resource(rootURI + "/Another_story");
    index.put("Another_story", anotherResource);
        String includes = "**";
    when(indexer.indexResources(rootURI, sourcePath, sourceSyntax, includes)).thenReturn(index);

        // When
View Full Code Here

  @Test
  public void canFormatAsJSONWithDefaultSyntax() {
      UploadToXWiki uploader = new UploadToXWiki(Type.JSON);
    String resourcePath = "http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/some_story";
    String content = read("xwiki.json");
    Resource resource = new Resource(resourcePath);
    resource.setContent(content);
    String entity = uploader.entity(resource, Type.JSON);
    assertThat(entity, containsString("\"title\":\"some_story\""));
    assertThat(entity, containsString("\"syntax\":\"xwiki/2.0\""));
  }
View Full Code Here

TOP

Related Classes of org.jbehave.core.io.rest.Resource

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.