Clean up Bug890Test 18/107518/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 26 Aug 2023 20:58:23 +0000 (22:58 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 26 Aug 2023 20:58:23 +0000 (22:58 +0200)
Use a multiline string to inline the XML and move the module to
top-level.

Change-Id: Ifda8d6f0fead26b5a813c8e28171032be12e9534
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug890Test.java
codec/yang-data-codec-xml/src/test/resources/bug890/foo.yang [moved from codec/yang-data-codec-xml/src/test/resources/bug890/yang/foo.yang with 100% similarity]
codec/yang-data-codec-xml/src/test/resources/bug890/xml/foo.xml [deleted file]

index 19d98397fd9cf376ae9cdb528a9d541435672606..ec09d8a90121a771672bf0eee1368833d1d38582 100644 (file)
@@ -11,6 +11,8 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import org.junit.Test;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
@@ -36,9 +38,26 @@ public class Bug890Test {
 
     @Test
     public void testinputXml() throws Exception {
-        final var schemaContext = YangParserTestUtils.parseYangResource("/bug890/yang/foo.yang");
-        final var resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/bug890/xml/foo.xml");
-        final var reader = UntrustedXML.createXMLStreamReader(resourceAsStream);
+        final var schemaContext = YangParserTestUtils.parseYangResourceDirectory("/bug890");
+        final var reader = UntrustedXML.createXMLStreamReader(new ByteArrayInputStream("""
+            <root xmlns="foo">
+                <outgoing-labels>
+                    <outgoing-labels>
+                        <index>0</index>
+                        <config>
+                            <index>0</index>
+                            <label>103</label>
+                        </config>
+                    </outgoing-labels>
+                    <outgoing-labels>
+                        <index>1</index>
+                        <config>
+                            <index>1</index>
+                            <label>104</label>
+                        </config>
+                    </outgoing-labels>
+                </outgoing-labels>
+            </root>""".getBytes(StandardCharsets.UTF_8)));
         final var result = new NormalizationResultHolder();
         final var streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
         final var xmlParser = XmlParserStream.create(streamWriter,
diff --git a/codec/yang-data-codec-xml/src/test/resources/bug890/xml/foo.xml b/codec/yang-data-codec-xml/src/test/resources/bug890/xml/foo.xml
deleted file mode 100644 (file)
index 4bd91b1..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<root xmlns="foo">
-    <outgoing-labels>
-        <outgoing-labels>
-            <index>0</index>
-            <config>
-                <index>0</index>
-                <label>103</label>
-            </config>
-        </outgoing-labels>
-        <outgoing-labels>
-            <index>1</index>
-            <config>
-                <index>1</index>
-                <label>104</label>
-            </config>
-        </outgoing-labels>
-    </outgoing-labels>
-</root>
\ No newline at end of file