diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-21 09:05:38 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-21 09:05:38 +0000 |
| commit | cfabbcdab4fbd8401569ec5e6e88a6bca913b502 (patch) | |
| tree | 23b21bc4c2f5ad26259ce65aa87f074c5c06361c /src/test/java/org/zwobble/mammoth | |
| parent | f0159a9c51a92adcef38307c4e173a3de51bc373 (diff) | |
Implement FileReader to support external images
Diffstat (limited to 'src/test/java/org/zwobble/mammoth')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/MammothTests.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java index c165cfd..e778630 100644 --- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java @@ -5,6 +5,9 @@ import org.zwobble.mammoth.Mammoth; import org.zwobble.mammoth.results.Result; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import static org.junit.Assert.assertThat; import static org.zwobble.mammoth.results.Result.success; @@ -67,6 +70,21 @@ public class MammothTests { } @Test + public void imagesStoredOutsideOfDocumentAreIncludedInOutput() throws IOException { + Path tempDirectory = Files.createTempDirectory("mammoth-"); + try { + Path documentPath = tempDirectory.resolve("external-picture.docx"); + Files.copy(TestData.file("external-picture.docx").toPath(), documentPath); + Files.copy(TestData.file("tiny-picture.png").toPath(), tempDirectory.resolve("tiny-picture.png")); + assertThat( + Mammoth.convertToHtml(documentPath.toFile()), + deepEquals(success("<p><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=\" /></p>"))); + } finally { + tempDirectory.toFile().delete(); + } + } + + @Test public void contentTypesAreRead() { assertThat( convertToHtml("tiny-picture-custom-content-type.docx"), |
