Cleanup TestRestconfUtils 88/98288/4
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 4 Nov 2021 10:03:16 +0000 (11:03 +0100)
committerRobert Varga <nite@hq.sk>
Thu, 4 Nov 2021 10:25:23 +0000 (10:25 +0000)
We should be ignoring non-yang files, as otherwise things like vim
.swp files are wrecking our day.

Change-Id: I4144f60e44f5b01c0521912213ea08707c78d938
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/TestRestconfUtils.java

index e2f408a15424c3fa341b9af8c351bee4031844b8..c1682dc7cce4c30ce27c662bf3214f97dfc61701 100644 (file)
@@ -14,7 +14,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
 import javax.xml.parsers.ParserConfigurationException;
@@ -24,6 +23,7 @@ import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
+import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream;
@@ -128,7 +128,7 @@ public final class TestRestconfUtils {
         return null;
     }
 
-    public static Collection<File> loadFiles(final String resourceDirectory) throws FileNotFoundException {
+    public static List<File> loadFiles(final String resourceDirectory) throws FileNotFoundException {
         final String path = TestRestconfUtils.class.getResource(resourceDirectory).getPath();
         final File testDir = new File(path);
         final String[] fileList = testDir.list();
@@ -137,7 +137,8 @@ public final class TestRestconfUtils {
             throw new FileNotFoundException(resourceDirectory);
         }
         for (final String fileName : fileList) {
-            if (new File(testDir, fileName).isDirectory() == false) {
+            if (fileName.endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION)
+                && !new File(testDir, fileName).isDirectory()) {
                 testFiles.add(new File(testDir, fileName));
             }
         }