diff --git a/asciidoctor-epub-example/pom.xml b/asciidoctor-epub-example/pom.xml index a8d5f86..a7f3427 100644 --- a/asciidoctor-epub-example/pom.xml +++ b/asciidoctor-epub-example/pom.xml @@ -50,10 +50,12 @@ - src/docs/asciidoc - - ${project.build.sourceDirectory} - + epub3 + spine.adoc + + + + . @@ -71,67 +73,21 @@ process-asciidoc - - epub3 - spine.adoc - - - - - - - - - - + - generate-spine-kf8 + generate-extracted-epub generate-resources process-asciidoc - epub3 - spine.adoc - rouge - kf8 + - - - - - diff --git a/tests/src/test/java/org/asciidoctor/maven/examples/AsciidoctorEpubTest.java b/tests/src/test/java/org/asciidoctor/maven/examples/AsciidoctorEpubTest.java index f39beb2..ac35274 100644 --- a/tests/src/test/java/org/asciidoctor/maven/examples/AsciidoctorEpubTest.java +++ b/tests/src/test/java/org/asciidoctor/maven/examples/AsciidoctorEpubTest.java @@ -2,28 +2,56 @@ import org.asciidoctor.maven.examples.tests.MavenProject; import org.asciidoctor.maven.examples.tests.MavenTest; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.File; +import java.util.function.Predicate; import static org.assertj.core.api.Assertions.assertThat; -@Disabled("issue-141") @MavenTest(projectPath = "../asciidoctor-epub-example") class AsciidoctorEpubTest { private MavenProject mavenProject; @Test - void shouldGenerateEpubFiles() { + void shouldGenerateEpubFile() { File epub = mavenProject.getTarget(generatedDocs("spine.epub")); + assertThat(epub) - .isNotEmpty(); + .isNotEmpty() + .isFile(); + } + + @Test + void shouldGenerateExtractedDir() { + File extractedDir = mavenProject.getTarget(generatedDocs("spine")); + + assertThat(extractedDir) + .isDirectory() + .isDirectoryContaining(directory("EPUB")) + .isDirectoryContaining(directory("META-INF")) + .isDirectoryContaining(file("mimetype")); + + assertThat(new File(extractedDir, "EPUB")) + .isDirectory() + .isDirectoryContaining(file("_chapter_1.xhtml")) + .isDirectoryContaining(file("_chapter_2.xhtml")) + .isDirectoryContaining(file("_chapter_3.xhtml")); + + assertThat(new File(extractedDir, "EPUB/images")) + .isDirectory() + .isDirectoryContaining(file("sunset.jpg")); + + extractedDir.toPath().resolve(""); + } + + private static Predicate directory(String name) { + return file -> file.isDirectory() && file.getName().equals(name); + } - File epubKf8 = mavenProject.getTarget(generatedDocs("spine-kf8.epub")); - assertThat(epubKf8) - .isNotEmpty(); + private static Predicate file(String name) { + return file -> file.isFile() && file.getName().equals(name) && file.length() > 0; } private String generatedDocs(String filename) {