Search in sources :

Example 1 with Predicate

use of org.xmlunit.util.Predicate in project spring-framework by spring-projects.

the class XMLEventStreamReaderTests method readCorrect.

@Test
public void readCorrect() throws Exception {
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    StAXSource source = new StAXSource(streamReader);
    StringWriter writer = new StringWriter();
    transformer.transform(source, new StreamResult(writer));
    Predicate<Node> nodeFilter = n -> n.getNodeType() != Node.DOCUMENT_TYPE_NODE && n.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE;
    assertThat(writer.toString(), isSimilarTo(XML).withNodeFilter(nodeFilter));
}
Also used : XMLEventReader(javax.xml.stream.XMLEventReader) Transformer(javax.xml.transform.Transformer) XMLInputFactory(javax.xml.stream.XMLInputFactory) StreamResult(javax.xml.transform.stream.StreamResult) StringWriter(java.io.StringWriter) Test(org.junit.Test) Assert.assertThat(org.junit.Assert.assertThat) CompareMatcher.isSimilarTo(org.xmlunit.matchers.CompareMatcher.isSimilarTo) Predicate(org.xmlunit.util.Predicate) StAXSource(javax.xml.transform.stax.StAXSource) StringReader(java.io.StringReader) Node(org.w3c.dom.Node) TransformerFactory(javax.xml.transform.TransformerFactory) Before(org.junit.Before) Transformer(javax.xml.transform.Transformer) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) Node(org.w3c.dom.Node) StAXSource(javax.xml.transform.stax.StAXSource) Test(org.junit.Test)

Aggregations

StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 XMLEventReader (javax.xml.stream.XMLEventReader)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1 Transformer (javax.xml.transform.Transformer)1 TransformerFactory (javax.xml.transform.TransformerFactory)1 StAXSource (javax.xml.transform.stax.StAXSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 Assert.assertThat (org.junit.Assert.assertThat)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1 CompareMatcher.isSimilarTo (org.xmlunit.matchers.CompareMatcher.isSimilarTo)1 Predicate (org.xmlunit.util.Predicate)1