blob: 6b2fb77fb93443e72ce5fdb7024950036717a80d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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"))));
}
}
|