diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-01-03 11:36:08 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-01-03 11:36:08 +0000 |
| commit | df0e65ca725de5fb471abdd7ff8621904e41a209 (patch) | |
| tree | 627dfab26fb684b74a65b9b6247912abfc1688c3 /src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java | |
| parent | 1b5c6e99770d3b555c017751f29261037d2e540d (diff) | |
Collapse alternate content elements using fallback
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java new file mode 100644 index 0000000..6b2fb77 --- /dev/null +++ b/src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java @@ -0,0 +1,34 @@ +package org.zwobble.mammoth.tests.docx; + +import com.google.common.base.Charsets; +import com.google.common.collect.ImmutableList; +import org.junit.Test; +import org.zwobble.mammoth.docx.OfficeXml; +import org.zwobble.mammoth.xml.XmlElement; + +import java.io.ByteArrayInputStream; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; +import static org.zwobble.mammoth.xml.XmlNodes.element; + +public class OfficeXmlTests { + @Test + public void alternateContentIsReplacedByContentsOfFallback() { + String xmlString = + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + + "<numbering xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\">" + + "<mc:AlternateContent>" + + "<mc:Choice Requires=\"w14\">" + + "<choice/>" + + "</mc:Choice>" + + "<mc:Fallback>" + + "<fallback/>" + + "</mc:Fallback>" + + "</mc:AlternateContent>" + + "</numbering>"; + + XmlElement result = OfficeXml.parseXml(new ByteArrayInputStream(xmlString.getBytes(Charsets.UTF_8))); + assertThat(result.children(), deepEquals(ImmutableList.of(element("fallback")))); + } +} |
