summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-02-21 09:15:50 +0000
committerMichael Williamson <mike@zwobble.org>2016-02-21 09:15:50 +0000
commit9d5da9d5339055198aac8d0d41c3d33d97344ebd (patch)
tree6a34e31b8df70a654dd4dee1091b617ee2842b4c /src/test/java
parentcfabbcdab4fbd8401569ec5e6e88a6bca913b502 (diff)
Handle errors when reading images
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/MammothTests.java18
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 e778630..603d39a 100644
--- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java
@@ -9,6 +9,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.zwobble.mammoth.results.Result.success;
import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals;
@@ -85,6 +86,23 @@ public class MammothTests {
}
@Test
+ public void warnIfImagesStoredOutsideOfDocumentAreNotFound() throws IOException {
+ Path tempDirectory = Files.createTempDirectory("mammoth-");
+ try {
+ Path documentPath = tempDirectory.resolve("external-picture.docx");
+ Files.copy(TestData.file("external-picture.docx").toPath(), documentPath);
+ assertThat(
+ Mammoth.convertToHtml(documentPath.toFile()),
+ allOf(
+ hasProperty("value", equalTo("")),
+ hasProperty("warnings", contains(
+ hasProperty("message", startsWith("could not open external image 'tiny-picture.png'"))))));
+ } finally {
+ tempDirectory.toFile().delete();
+ }
+ }
+
+ @Test
public void contentTypesAreRead() {
assertThat(
convertToHtml("tiny-picture-custom-content-type.docx"),