提交 78b6ba05 编写于 作者: B Brian Clozel

Filter irrelevant nodes in StaxHandler tests

上级 3635c9db
......@@ -20,9 +20,11 @@ import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xmlunit.util.Predicate;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
......@@ -58,6 +60,9 @@ public abstract class AbstractStaxHandlerTestCase {
private XMLReader xmlReader;
private Predicate<Node> nodeFilter = n -> n.getNodeType() != Node.COMMENT_NODE
&& n.getNodeType() != Node.DOCUMENT_TYPE_NODE && n.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE;
@Before
public void createXMLReader() throws Exception {
xmlReader = XMLReaderFactory.createXMLReader();
......@@ -77,7 +82,7 @@ public abstract class AbstractStaxHandlerTestCase {
xmlReader.parse(new InputSource(new StringReader(COMPLEX_XML)));
assertThat(stringWriter.toString(), isSimilarTo(COMPLEX_XML));
assertThat(stringWriter.toString(), isSimilarTo(COMPLEX_XML).withNodeFilter(nodeFilter));
}
private static boolean wwwSpringframeworkOrgIsAccessible() {
......@@ -104,7 +109,7 @@ public abstract class AbstractStaxHandlerTestCase {
xmlReader.parse(new InputSource(new StringReader(COMPLEX_XML)));
assertThat(stringWriter.toString(), isSimilarTo(COMPLEX_XML));
assertThat(stringWriter.toString(), isSimilarTo(COMPLEX_XML).withNodeFilter(nodeFilter));
}
@Test
......@@ -126,7 +131,7 @@ public abstract class AbstractStaxHandlerTestCase {
xmlReader.parse(new InputSource(new StringReader(SIMPLE_XML)));
assertThat(result, isSimilarTo(expected));
assertThat(result, isSimilarTo(expected).withNodeFilter(nodeFilter));
}
@Test
......@@ -148,7 +153,7 @@ public abstract class AbstractStaxHandlerTestCase {
xmlReader.parse(new InputSource(new StringReader(SIMPLE_XML)));
assertThat(expected, isSimilarTo(result));
assertThat(expected, isSimilarTo(result).withNodeFilter(nodeFilter));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册