aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-02-13 23:32:26 +0000
committerMichael Williamson <mike@zwobble.org>2016-02-13 23:32:26 +0000
commitc46ec78de9524a7b7df0b475b1447a83b4f857fe (patch)
treec98c58f6d4aa8cde8824bbfe3b73131143f1d3cc /src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
parent6dd319ca5eebe1f97b9558b5b45bbccf402eb319 (diff)
Read linked blips
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
index 49542ec..5c4c40d 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
@@ -419,7 +419,7 @@ public class BodyXmlTests {
hasProperty("contentType", deepEquals(Optional.of("image/png")))));
assertThat(
CharStreams.toString(new InputStreamReader(image.open())),
- equalTo("Not an image at all!"));
+ equalTo(imageBytes));
}
private class EmbeddedImage {
@@ -446,11 +446,30 @@ public class BodyXmlTests {
with(DOCX_FILE, file),
with(CONTENT_TYPES, contentTypes)),
element);
+
assertThat(
result,
hasProperty("warnings", deepEquals(list(warning("Image of type image/x-emf is unlikely to display in web browsers")))));
}
+ @Test
+ public void canReadLinkedPictures() throws IOException {
+ XmlElement element = inlineImageXml(linkedBlipXml("rId5"), "");
+ Relationships relationships = new Relationships(map(
+ "rId5", new Relationship("file:///media/hat.png")));
+ String imageBytes = "Not an image at all!";
+
+ Image image = (Image) readSuccess(
+ a(bodyReader,
+ with(RELATIONSHIPS, relationships),
+ with(FILE_READER, new InMemoryFileReader(map("file:///media/hat.png", imageBytes)))),
+ element);
+
+ assertThat(
+ CharStreams.toString(new InputStreamReader(image.open())),
+ equalTo(imageBytes));
+ }
+
private XmlElement inlineImageXml(XmlElement blip, String description) {
return element("w:drawing", list(
element("wp:inline", imageXml(blip, description))));
@@ -474,6 +493,10 @@ public class BodyXmlTests {
return blipXml(map("r:embed", relationshipId));
}
+ private XmlElement linkedBlipXml(String relationshipId) {
+ return blipXml(map("r:link", relationshipId));
+ }
+
private XmlElement blipXml(Map<String, String> attributes) {
return element("a:blip", attributes);
}