From 0213206f29a117323c647f54030ad3e7c5a234d9 Mon Sep 17 00:00:00 2001 From: Pepijn Van Eeckhoudt Date: Thu, 1 Oct 2020 17:55:47 +0200 Subject: [PATCH 1/2] Update to asciidoctor-diagram 2.0.5 --- asciidoctorj-diagram/gradle.properties | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/asciidoctorj-diagram/gradle.properties b/asciidoctorj-diagram/gradle.properties index ecbc7c0..8a0a414 100644 --- a/asciidoctorj-diagram/gradle.properties +++ b/asciidoctorj-diagram/gradle.properties @@ -1,4 +1,4 @@ properName=AsciidoctorJ Diagram description=AsciidoctorJ Diagram bundles the Asciidoctor Diagram RubyGem (asciidoctor-diagram) so it can be loaded into the JVM using JRuby. -version=2.0.3 +version=2.0.5 gem_name=asciidoctor-diagram diff --git a/gradle.properties b/gradle.properties index a80dc36..3ca0855 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=2.0.3 +version=2.0.5 From db8c0a25f4cadd7e85422918f9db804d6f90f90e Mon Sep 17 00:00:00 2001 From: Pepijn Van Eeckhoudt Date: Thu, 1 Oct 2020 19:07:03 +0200 Subject: [PATCH 2/2] Safe mode unit test fixes --- .../WhenDocumentContainsDitaaDiagram.java | 6 ++++-- .../WhenDocumentWantsDataUris.java | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/asciidoctorj-diagram/src/test/java/org.asciidoctor/WhenDocumentContainsDitaaDiagram.java b/asciidoctorj-diagram/src/test/java/org.asciidoctor/WhenDocumentContainsDitaaDiagram.java index 0ffad1c..c9bb2d6 100644 --- a/asciidoctorj-diagram/src/test/java/org.asciidoctor/WhenDocumentContainsDitaaDiagram.java +++ b/asciidoctorj-diagram/src/test/java/org.asciidoctor/WhenDocumentContainsDitaaDiagram.java @@ -15,14 +15,16 @@ public class WhenDocumentContainsDitaaDiagram { @Test public void png_should_be_rendered_for_diagram() { - File inputFile = new File("build/resources/test/sample.adoc"); + File buildDir = new File("build/resources/test"); + + File inputFile = new File(buildDir, "sample.adoc"); File outputFile1 = new File(inputFile.getParentFile(), "asciidoctor-diagram-process.png"); File outputFile2 = new File(inputFile.getParentFile(), ".asciidoctor/diagram/asciidoctor-diagram-process.png.cache"); asciidoctor.requireLibrary("asciidoctor-diagram"); asciidoctor.convertFile(inputFile, options() .backend("html5") - .toDir(new File("build")) + .toFile(new File(buildDir, "sample.html")) .get()); assertThat(outputFile1.exists(), is(true)); assertThat(outputFile2.exists(), is(true)); diff --git a/asciidoctorj-diagram/src/test/java/org.asciidoctor/WhenDocumentWantsDataUris.java b/asciidoctorj-diagram/src/test/java/org.asciidoctor/WhenDocumentWantsDataUris.java index 4f9df55..07f201d 100644 --- a/asciidoctorj-diagram/src/test/java/org.asciidoctor/WhenDocumentWantsDataUris.java +++ b/asciidoctorj-diagram/src/test/java/org.asciidoctor/WhenDocumentWantsDataUris.java @@ -6,6 +6,9 @@ import org.junit.Test; import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import static org.asciidoctor.OptionsBuilder.options; import static org.hamcrest.CoreMatchers.is; @@ -18,16 +21,17 @@ public class WhenDocumentWantsDataUris { private Asciidoctor asciidoctor = Asciidoctor.Factory.create(); @Test - public void png_should_be_rendered_for_diagram() { + public void png_should_be_rendered_for_diagram() throws IOException { + File buildDir = new File("build/resources/test"); - File inputFile = new File("build/resources/test/data-uri.adoc"); + File inputFile = new File(buildDir, "data-uri.adoc"); + File outputFile = new File(buildDir, "data-uri.html"); File outputFile1 = new File(inputFile.getParentFile(), "data-uri-test.png"); File outputFile2 = new File(inputFile.getParentFile(), ".asciidoctor/diagram/data-uri-test.png.cache"); asciidoctor.requireLibrary("asciidoctor-diagram"); - final String html = asciidoctor.convertFile(inputFile, + asciidoctor.convertFile(inputFile, options().backend("html5") - .toFile(false) - .toDir(new File("build")) + .toFile(outputFile) .safe(SafeMode.SERVER) .get()); assertThat(outputFile1.exists(), is(true)); @@ -35,6 +39,7 @@ public void png_should_be_rendered_for_diagram() { outputFile1.delete(); outputFile2.delete(); + String html = new String(Files.readAllBytes(outputFile.toPath()), StandardCharsets.UTF_8); final Document doc = Jsoup.parse(html); System.out.println(doc); Elements images = doc.getElementsByTag("img");