Remove AbstractTypesTest 64/95664/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 3 Apr 2021 15:59:00 +0000 (17:59 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 3 Apr 2021 16:00:09 +0000 (18:00 +0200)
The test harness used here is quite funky and prone to errors if there
are things like vim temporary files. Use the method dedicated to this
particular uses case, making things simpler and more reliable.

Change-Id: I4320869672ee4949fb18b7cb18aed81a7d548fb2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypesTest.java [deleted file]
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AugmentRelativeXPathTest.java
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/ChoiceCaseGenTypesTest.java

diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypesTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypesTest.java
deleted file mode 100644 (file)
index db4e8a4..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.binding.generator.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Before;
-
-public abstract class AbstractTypesTest {
-
-    private final URL testSourcesDirUrl;
-    protected Set<File> testModels;
-
-    AbstractTypesTest(final URL testSourcesDirUrl) {
-        this.testSourcesDirUrl = testSourcesDirUrl;
-    }
-
-    @Before
-    public void loadTestResources() throws URISyntaxException {
-        File testSourcesDir = new File(testSourcesDirUrl.toURI());
-        File[] testFiles = requireNonNull(testSourcesDir.listFiles(), testSourcesDir + " does not denote a directory");
-        testModels = new HashSet<>();
-        for (File file : testFiles) {
-            if (file.isFile()) {
-                testModels.add(file);
-            }
-        }
-    }
-
-}
index d5a118c44ade8d6d6002886ba608527843919d8d..7502807e32589446ce7f693b8a4214c34e218799 100644 (file)
@@ -22,16 +22,11 @@ import org.opendaylight.mdsal.binding.model.api.MethodSignature;
 import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class AugmentRelativeXPathTest extends AbstractTypesTest {
-
-    public AugmentRelativeXPathTest() {
-        super(AugmentRelativeXPathTest.class.getResource("/augment-relative-xpath-models"));
-    }
-
+public class AugmentRelativeXPathTest {
     @Test
     public void testAugmentationWithRelativeXPath() {
         final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
-            YangParserTestUtils.parseYangFiles(testModels));
+            YangParserTestUtils.parseYangResourceDirectory("/augment-relative-xpath-models"));
         assertNotNull("genTypes is null", genTypes);
         assertEquals(26, genTypes.size());
 
@@ -118,5 +113,4 @@ public class AugmentRelativeXPathTest extends AbstractTypesTest {
         assertNotNull("Tunnel is null", gtTunnel);
         assertNotNull("TunnelKey is null", gtTunnelKey);
     }
-
 }
index 174402fc2ac203353c6200df270e61fc064dc921..2abcfb506d8c7edaed1121203c5dc53a02212182 100644 (file)
@@ -18,40 +18,11 @@ import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class ChoiceCaseGenTypesTest extends AbstractTypesTest {
-
-    public ChoiceCaseGenTypesTest() {
-        super(ChoiceCaseGenTypesTest.class.getResource("/choice-case-type-test-models"));
-    }
-
-    private static GeneratedType checkGeneratedType(final List<GeneratedType> genTypes, final String genTypeName,
-            final String packageName, final int occurences) {
-        GeneratedType searchedGenType = null;
-        int searchedGenTypeCounter = 0;
-        for (GeneratedType genType : genTypes) {
-            if (!(genType instanceof GeneratedTransferObject)) {
-                if (genType.getName().equals(genTypeName) && genType.getPackageName().equals(packageName)) {
-                    searchedGenType = genType;
-                    searchedGenTypeCounter++;
-                }
-            }
-        }
-        assertNotNull("Generated type " + genTypeName + " wasn't found", searchedGenType);
-        assertEquals(genTypeName + " generated type has incorrect number of occurences.", occurences,
-                searchedGenTypeCounter);
-        return searchedGenType;
-
-    }
-
-    private static GeneratedType checkGeneratedType(final List<GeneratedType> genTypes, final String genTypeName,
-            final String packageName) {
-        return checkGeneratedType(genTypes, genTypeName, packageName, 1);
-    }
-
+public class ChoiceCaseGenTypesTest {
     @Test
     public void choiceCaseResolvingTypeTest() {
         final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
-            YangParserTestUtils.parseYangFiles(testModels));
+            YangParserTestUtils.parseYangResourceDirectory("/choice-case-type-test-models"));
 
         assertNotNull("genTypes is null", genTypes);
         assertEquals(40, genTypes.size());
@@ -164,4 +135,28 @@ public class ChoiceCaseGenTypesTest extends AbstractTypesTest {
         containsMethods(genType, new NameTypePattern("getYangFileName", "String"));
         containsInterface("StorageFormat", genType);
     }
+
+    private static GeneratedType checkGeneratedType(final List<GeneratedType> genTypes, final String genTypeName,
+            final String packageName, final int occurences) {
+        GeneratedType searchedGenType = null;
+        int searchedGenTypeCounter = 0;
+        for (GeneratedType genType : genTypes) {
+            if (!(genType instanceof GeneratedTransferObject)) {
+                if (genType.getName().equals(genTypeName) && genType.getPackageName().equals(packageName)) {
+                    searchedGenType = genType;
+                    searchedGenTypeCounter++;
+                }
+            }
+        }
+        assertNotNull("Generated type " + genTypeName + " wasn't found", searchedGenType);
+        assertEquals(genTypeName + " generated type has incorrect number of occurences.", occurences,
+            searchedGenTypeCounter);
+        return searchedGenType;
+
+    }
+
+    private static GeneratedType checkGeneratedType(final List<GeneratedType> genTypes, final String genTypeName,
+        final String packageName) {
+        return checkGeneratedType(genTypes, genTypeName, packageName, 1);
+    }
 }