Search in sources :

Example 1 with Diff

use of org.custommonkey.xmlunit.Diff in project jersey by jersey.

the class WadlBeanParamTest method testBeanParamConstructorInitializedBean.

private void testBeanParamConstructorInitializedBean(String resource) throws Exception {
    final Response response = target("/application.wadl").request().get();
    final Document d = WadlResourceTest.extractWadlAsDocument(response);
    final XPath xp = XPathFactory.newInstance().newXPath();
    final SimpleNamespaceResolver nsContext = new SimpleNamespaceResolver("wadl", "http://wadl.dev.java.net/2009/02");
    xp.setNamespaceContext(nsContext);
    final Diff diff = XMLUnit.compareXML(nodeAsString(xp.evaluate("//wadl:resource[@path='wadlBeanParamReference']/wadl:resource", d, XPathConstants.NODE)), nodeAsString(xp.evaluate("//wadl:resource[@path='" + resource + "']/wadl:resource", d, XPathConstants.NODE)));
    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(ImmutableMap.of("wadl", "http://wadl.dev.java.net/2009/02")));
    diff.overrideElementQualifier(elementQualifier);
    XMLAssert.assertXMLEqual(diff, true);
}
Also used : Response(javax.ws.rs.core.Response) XPath(javax.xml.xpath.XPath) Diff(org.custommonkey.xmlunit.Diff) SimpleNamespaceResolver(org.glassfish.jersey.internal.util.SimpleNamespaceResolver) SimpleNamespaceContext(org.custommonkey.xmlunit.SimpleNamespaceContext) Document(org.w3c.dom.Document)

Example 2 with Diff

use of org.custommonkey.xmlunit.Diff in project cucumber-jvm by cucumber.

the class TestNGFormatterTest method assertXmlEqual.

private void assertXmlEqual(String expected, String actual) throws SAXException, IOException {
    XMLUnit.setIgnoreWhitespace(true);
    Diff diff = new Diff(expected, actual) {

        @Override
        public int differenceFound(Difference difference) {
            if (difference.getControlNodeDetail().getNode().getNodeName().matches("started-at|finished-at")) {
                return 0;
            }
            return super.differenceFound(difference);
        }
    };
    assertTrue("XML files are similar " + diff + "\nFormatterOutput = " + actual, diff.identical());
}
Also used : Diff(org.custommonkey.xmlunit.Diff) Difference(org.custommonkey.xmlunit.Difference)

Example 3 with Diff

use of org.custommonkey.xmlunit.Diff in project cucumber-jvm by cucumber.

the class JUnitFormatterTest method assertXmlEqual.

private void assertXmlEqual(String expected, String actual) throws SAXException, IOException {
    XMLUnit.setIgnoreWhitespace(true);
    Diff diff = new Diff(expected, actual);
    assertTrue("XML files are similar " + diff + "\nFormatterOutput = " + actual, diff.identical());
}
Also used : Diff(org.custommonkey.xmlunit.Diff)

Example 4 with Diff

use of org.custommonkey.xmlunit.Diff in project ORCID-Source by ORCID.

the class VisibilityFilterImplTest method testFilterStripWithVisibilities.

@Test
public void testFilterStripWithVisibilities() throws Exception {
    protectedOrcidMessage = getOrcidMessage("/orcid-protected-full-message-latest.xml");
    publicOrcidMessage = getOrcidMessage("/orcid-stripped-with-visibility-message-latest.xml");
    OrcidMessage orcidMessage = visibilityFilter.filter(cascadeSectionPrivacyToItems(protectedOrcidMessage), Visibility.PUBLIC);
    Diff myDiff = new Diff(publicOrcidMessage.toString(), orcidMessage.toString());
    assertEquals(publicOrcidMessage.toString(), orcidMessage.toString());
    assertTrue(myDiff.toString(), myDiff.similar());
}
Also used : Diff(org.custommonkey.xmlunit.Diff) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Example 5 with Diff

use of org.custommonkey.xmlunit.Diff in project groovy by apache.

the class XmlAssert method assertXmlEquals.

public static void assertXmlEquals(String expected, String actual) throws Exception {
    XMLUnit.setIgnoreWhitespace(true);
    Diff diff = new Diff(expected, actual);
    Assert.assertTrue(diff.toString(), diff.similar());
}
Also used : Diff(org.custommonkey.xmlunit.Diff)

Aggregations

Diff (org.custommonkey.xmlunit.Diff)116 Test (org.junit.Test)72 StringWriter (java.io.StringWriter)26 InputStream (java.io.InputStream)23 DetailedDiff (org.custommonkey.xmlunit.DetailedDiff)16 LineString (com.vividsolutions.jts.geom.LineString)14 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)14 Difference (org.custommonkey.xmlunit.Difference)14 IOException (java.io.IOException)12 StreamResult (javax.xml.transform.stream.StreamResult)11 QueryImpl (ddf.catalog.operation.impl.QueryImpl)10 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)10 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 JAXBElement (javax.xml.bind.JAXBElement)9 Document (org.w3c.dom.Document)9 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 StringReader (java.io.StringReader)8 Transformer (javax.xml.transform.Transformer)8