Ignore NETCONF message document whitespace 99/79199/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 3 Jan 2019 18:43:38 +0000 (19:43 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 3 Jan 2019 18:43:38 +0000 (19:43 +0100)
The transformer we use is specifically allowed to add whitespace,
which does not offer us with enough control as to what it is going
to be -- making it implementation-dependent.

Checking whitespace match actually breaks with Java11, so disable
that checking.

Change-Id: I8b3b5fa648ea2f13cc069b03ba374975be33e9d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/MessageParserTest.java

index a8e05a900a63554e409b95d0a2b5ae8ef082da3f..82c42dcb29fa59c0c9022737f087f92878a9b185 100644 (file)
@@ -21,6 +21,7 @@ import io.netty.channel.embedded.EmbeddedChannel;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.util.Queue;
+import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.netconf.api.NetconfMessage;
@@ -88,6 +89,7 @@ public class MessageParserTest {
 
         NetconfMessage receivedMessage = testChunkChannel.readInbound();
         assertNotNull(receivedMessage);
+        XMLUnit.setIgnoreWhitespace(true);
         assertXMLEqual(this.msg.getDocument(), receivedMessage.getDocument());
     }
 
@@ -108,10 +110,11 @@ public class MessageParserTest {
         testChunkChannel.writeInbound(recievedOutbound);
         NetconfMessage receivedMessage = testChunkChannel.readInbound();
         assertNotNull(receivedMessage);
+        XMLUnit.setIgnoreWhitespace(true);
         assertXMLEqual(this.msg.getDocument(), receivedMessage.getDocument());
     }
 
-    private static long getHeaderLength(byte[] bytes) {
+    private static long getHeaderLength(final byte[] bytes) {
         byte[] headerStart = new byte[]{(byte) 0x0a, (byte) 0x23};
         return Long.parseLong(StandardCharsets.US_ASCII.decode(
                 ByteBuffer.wrap(bytes, headerStart.length, bytes.length - headerStart.length - 1)).toString());