From: Maros Marsalek Date: Mon, 16 Mar 2015 13:20:02 +0000 (+0100) Subject: Reenable netconf-notifications-impl xml tests X-Git-Tag: release/lithium~387^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=ef5071994518361380342fcf570b463d7e93d1a8 Reenable netconf-notifications-impl xml tests The tests were disabled due to improper configuration for XMLUtil. The configuration is fine now. Change-Id: I59fe1081ac927596fc55079e62088cceb5b52811 Signed-off-by: Maros Marsalek --- diff --git a/opendaylight/netconf/netconf-notifications-impl/src/test/java/org/opendaylight/controller/netconf/notifications/impl/ops/GetTest.java b/opendaylight/netconf/netconf-notifications-impl/src/test/java/org/opendaylight/controller/netconf/notifications/impl/ops/GetTest.java index 6f38f24f10..05ed9bf006 100644 --- a/opendaylight/netconf/netconf-notifications-impl/src/test/java/org/opendaylight/controller/netconf/notifications/impl/ops/GetTest.java +++ b/opendaylight/netconf/netconf-notifications-impl/src/test/java/org/opendaylight/controller/netconf/notifications/impl/ops/GetTest.java @@ -8,14 +8,9 @@ package org.opendaylight.controller.netconf.notifications.impl.ops; -import static org.junit.Assert.assertTrue; - import com.google.common.collect.Lists; import java.io.IOException; -import org.custommonkey.xmlunit.Diff; -import org.custommonkey.xmlunit.XMLUnit; import org.junit.Test; -import org.opendaylight.controller.netconf.notifications.impl.ops.Get; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams; @@ -41,22 +36,20 @@ public class GetTest { final Document response = getBlankResponse(); Get.serializeStreamsSubtree(response, streams); - final Diff diff = XMLUnit.compareXML(XmlUtil.toString(response), + NotificationsTransformUtilTest.compareXml(XmlUtil.toString(response), "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "base\n" + - "description\n" + - "false\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n"); - - assertTrue(diff.toString(), diff.identical()); + "\n" + + "\n" + + "\n" + + "\n" + + "base\n" + + "description\n" + + "false\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n"); } private Document getBlankResponse() throws IOException, SAXException { diff --git a/opendaylight/netconf/netconf-notifications-impl/src/test/java/org/opendaylight/controller/netconf/notifications/impl/ops/NotificationsTransformUtilTest.java b/opendaylight/netconf/netconf-notifications-impl/src/test/java/org/opendaylight/controller/netconf/notifications/impl/ops/NotificationsTransformUtilTest.java index b63e0877b2..7bb213ab46 100644 --- a/opendaylight/netconf/netconf-notifications-impl/src/test/java/org/opendaylight/controller/netconf/notifications/impl/ops/NotificationsTransformUtilTest.java +++ b/opendaylight/netconf/netconf-notifications-impl/src/test/java/org/opendaylight/controller/netconf/notifications/impl/ops/NotificationsTransformUtilTest.java @@ -8,24 +8,30 @@ package org.opendaylight.controller.netconf.notifications.impl.ops; +import static org.junit.Assert.assertTrue; + import com.google.common.collect.Lists; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; +import org.custommonkey.xmlunit.DetailedDiff; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLUnit; +import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; import org.junit.Test; import org.opendaylight.controller.netconf.notifications.NetconfNotification; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder; +import org.xml.sax.SAXException; public class NotificationsTransformUtilTest { private static final Date DATE = new Date(); private static final String innerNotification = "" + - "uri3" + "uri4" + + "uri3" + "uri1" + ""; @@ -39,17 +45,22 @@ public class NotificationsTransformUtilTest { final NetconfCapabilityChangeBuilder netconfCapabilityChangeBuilder = new NetconfCapabilityChangeBuilder(); netconfCapabilityChangeBuilder.setAddedCapability(Lists.newArrayList(new Uri("uri1"), new Uri("uri1"))); - netconfCapabilityChangeBuilder.setDeletedCapability(Lists.newArrayList(new Uri("uri3"), new Uri("uri4"))); + netconfCapabilityChangeBuilder.setDeletedCapability(Lists.newArrayList(new Uri("uri4"), new Uri("uri3"))); final NetconfCapabilityChange capabilityChange = netconfCapabilityChangeBuilder.build(); final NetconfNotification transform = NotificationsTransformUtil.transform(capabilityChange, DATE); final String serialized = XmlUtil.toString(transform.getDocument()); + compareXml(expectedNotification, serialized); + } + + static void compareXml(final String expected, final String actual) throws SAXException, IOException { XMLUnit.setIgnoreWhitespace(true); - final Diff diff = XMLUnit.compareXML(expectedNotification, serialized); - // FIXME the diff is unreliable, provide a proper comparison of XML -// assertTrue(diff.toString(), diff.similar()); + final Diff diff = new Diff(expected, actual); + final DetailedDiff detailedDiff = new DetailedDiff(diff); + detailedDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); + assertTrue(detailedDiff.toString(), detailedDiff.similar()); } @Test @@ -57,9 +68,7 @@ public class NotificationsTransformUtilTest { final NetconfNotification netconfNotification = new NetconfNotification(XmlUtil.readXmlToDocument(innerNotification), DATE); XMLUnit.setIgnoreWhitespace(true); - final Diff diff = XMLUnit.compareXML(expectedNotification, netconfNotification.toString()); - // FIXME the diff is unreliable, provide a proper comparison of XML -// assertTrue(diff.toString(), diff.similar()); + compareXml(expectedNotification, netconfNotification.toString()); } } \ No newline at end of file