@Test
  public void all_files_with_given_extension_should_be_returned_recursively() {

    File pathToWalk = classpath.getResource("src");
    DirectoryWalker globDirectoryWalker =
        new GlobDirectoryWalker(pathToWalk.getPath(), "**/*.adoc");
    List<File> asciidocFiles = globDirectoryWalker.scan();

    assertThat(
        asciidocFiles,
        containsInAnyOrder(
            classpath.getResource("src/documents/_sample.adoc"),
            classpath.getResource("src/documents/sample.adoc")));
  }
コード例 #2
0
  @Ignore(
      "Test is ignored because currently it is not possible to register two block extensions in same instance. This may require deep changes on Asciidoctor Extensions API")
  @Test
  public void extensions_should_be_correctly_added() throws IOException {

    Asciidoctor asciidoctor = JRubyAsciidoctor.create();

    // To avoid registering the same extension over and over for all tests, service is instantiated
    // manually.
    new ArrowsAndBoxesExtension().register(asciidoctor);

    Options options =
        options()
            .inPlace(false)
            .toFile(new File(testFolder.getRoot(), "rendersample.html"))
            .safe(SafeMode.UNSAFE)
            .get();

    asciidoctor.renderFile(classpath.getResource("arrows-and-boxes-example.ad"), options);

    File renderedFile = new File(testFolder.getRoot(), "rendersample.html");
    Document doc = Jsoup.parse(renderedFile, "UTF-8");

    Element arrowsJs =
        doc.select("script[src=http://www.headjump.de/javascripts/arrowsandboxes.js").first();
    assertThat(arrowsJs, is(notNullValue()));

    Element arrowsCss =
        doc.select("link[href=http://www.headjump.de/stylesheets/arrowsandboxes.css").first();
    assertThat(arrowsCss, is(notNullValue()));

    Element arrowsAndBoxes = doc.select("pre[class=arrows-and-boxes").first();
    assertThat(arrowsAndBoxes, is(notNullValue()));
  }
  @Test
  public void no_should_be_returned_if_glob_expression_does_not_match() {

    File pathToWalk = classpath.getResource("src");
    DirectoryWalker globDirectoryWalker = new GlobDirectoryWalker(pathToWalk.getPath(), "**/*.a");
    List<File> asciidocFiles = globDirectoryWalker.scan();

    assertThat(asciidocFiles, is(empty()));
  }