Search in sources :

Example 1 with RecursiveElementNameAndTextQualifier

use of org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEntityToModelMapperTest method testMapToFLUXFAReportMessage.

@Test
@Parameters(method = "resources")
public void testMapToFLUXFAReportMessage(String resource) throws Exception {
    FLUXFAReportMessage fluxfaReportMessage = sourceToEntity(resource);
    FluxFaReportMessageEntity entity = incomingFAReportMapper.mapToFluxFaReportMessage(fluxfaReportMessage, FaReportSourceEnum.MANUAL, new FluxFaReportMessageEntity());
    FLUXFAReportMessage target = modelMapper.mapToFLUXFAReportMessage(new ArrayList<>(entity.getFaReportDocuments()));
    String controlSource = JAXBUtils.marshallJaxBObjectToString(getFirstElement(fluxfaReportMessage));
    String testSource = JAXBUtils.marshallJaxBObjectToString(getFirstElement(target));
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    DetailedDiff diff = new DetailedDiff(new org.custommonkey.xmlunit.Diff(clearEmptyTags(controlSource), clearEmptyTags(testSource)));
    diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
    assertTrue("XML are similar " + diff, diff.similar());
}
Also used : DetailedDiff(org.custommonkey.xmlunit.DetailedDiff) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) RecursiveElementNameAndTextQualifier(org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 2 with RecursiveElementNameAndTextQualifier

use of org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier in project sirix by sirixdb.

the class TestNodeWrapperS9ApiXSLT method testWithSerializer.

@Test
public void testWithSerializer() throws Exception {
    final Serializer serializer = new Serializer();
    serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
    serializer.setOutputProperty(Serializer.Property.INDENT, "yes");
    final OutputStream out = new XSLTEvaluator(mHolder.getSession(), STYLESHEET, new ByteArrayOutputStream(), serializer).call();
    final StringBuilder sBuilder = readFile();
    final Diff diff = new Diff(sBuilder.toString(), out.toString());
    diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
    assertTrue(diff.toString(), diff.similar());
}
Also used : Diff(org.custommonkey.xmlunit.Diff) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) RecursiveElementNameAndTextQualifier(org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier) XSLTEvaluator(org.sirix.saxon.evaluator.XSLTEvaluator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Serializer(net.sf.saxon.s9api.Serializer) Test(org.junit.Test)

Example 3 with RecursiveElementNameAndTextQualifier

use of org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier in project Smack by igniterealtime.

the class XmlUnitUtils method assertSimilar.

public static void assertSimilar(CharSequence expected, CharSequence actual) throws SAXException, IOException {
    Diff diff = new Diff(expected.toString(), actual.toString());
    diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
    assertXMLEqual(diff, true);
}
Also used : Diff(org.custommonkey.xmlunit.Diff) RecursiveElementNameAndTextQualifier(org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier)

Example 4 with RecursiveElementNameAndTextQualifier

use of org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier in project pentaho-platform by pentaho.

the class CacheExpirationServiceTest method testGetXml_MultipleItems.

@Test
public void testGetXml_MultipleItems() throws SAXException, IOException {
    TestCacheItem item = new TestCacheItem("pentaho_cache_itemKey1");
    String lm = Long.toString(item.getLastModified());
    registry.register(item);
    item = new TestCacheItem("pentaho_cache_itemKey2");
    String lm2 = Long.toString(item.getLastModified());
    registry.register(item);
    String xml = service.getXml();
    Diff myDiff = new Diff("<cache-expiration-items><cache-item><key>pentaho_cache_itemKey1</key><last-modified>" + lm + "</last-modified></cache-item><cache-item><key>pentaho_cache_itemKey2</key><last-modified>" + lm2 + "</last-modified></cache-item></cache-expiration-items>", xml);
    // This allows the xml elements to be ordered differently and still pass the equality check
    myDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
    assertXMLEqual("But they are equal when an ElementQualifier controls which test element is compared with each control element", myDiff, true);
    assertEquals(2, registry.getCachedItems().size());
}
Also used : Diff(org.custommonkey.xmlunit.Diff) RecursiveElementNameAndTextQualifier(org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier) Test(org.junit.Test)

Example 5 with RecursiveElementNameAndTextQualifier

use of org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier in project sirix by sirixdb.

the class TestNodeWrapperS9ApiXSLT method testWithoutSerializer.

@Test
public void testWithoutSerializer() throws Exception {
    final OutputStream out = new XSLTEvaluator(mHolder.getSession(), STYLESHEET, new ByteArrayOutputStream()).call();
    final StringBuilder sBuilder = readFile();
    final Diff diff = new Diff(sBuilder.toString(), out.toString());
    diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
    assertTrue(diff.toString(), diff.similar());
}
Also used : Diff(org.custommonkey.xmlunit.Diff) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) RecursiveElementNameAndTextQualifier(org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier) XSLTEvaluator(org.sirix.saxon.evaluator.XSLTEvaluator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Aggregations

RecursiveElementNameAndTextQualifier (org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier)6 Diff (org.custommonkey.xmlunit.Diff)5 Test (org.junit.Test)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStream (java.io.OutputStream)2 DetailedDiff (org.custommonkey.xmlunit.DetailedDiff)2 XSLTEvaluator (org.sirix.saxon.evaluator.XSLTEvaluator)2 FluxFaReportMessageEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity)1 File (java.io.File)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 Parameters (junitparams.Parameters)1 Serializer (net.sf.saxon.s9api.Serializer)1 Document (org.w3c.dom.Document)1 FLUXFAReportMessage (un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage)1