Improve UsesAugmentTest 08/97708/2
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 2 Oct 2021 15:56:31 +0000 (17:56 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 3 Oct 2021 18:47:54 +0000 (20:47 +0200)
We have two tests sharing the reactor, use beforeClass() build it only
once and use better loading method to do that.

Change-Id: I82993ea04087c2ee90da40f2aee786a0cde95ee8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/UsesAugmentTest.java

index ba0737376f0a75bc0fc1727f22755aa76f52fc53..4169541241f24e7cece0ed598dc7856620ce1fa4 100644 (file)
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Collection;
-import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
@@ -38,11 +38,11 @@ public class UsesAugmentTest {
     private static final QNameModule GD = QNameModule.create(
         XMLNamespace.of("urn:opendaylight:params:xml:ns:yang:grouping-definitions"), Revision.of("2013-09-04"));
 
-    private SchemaContext context;
+    private static SchemaContext CONTEXT;
 
-    @Before
-    public void init() throws Exception {
-        context = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+        CONTEXT = TestUtils.loadModules("/grouping-test");
     }
 
     /*
@@ -103,7 +103,7 @@ public class UsesAugmentTest {
      */
     @Test
     public void testAugmentInUses() throws Exception {
-        final Module testModule = context.findModules("uses-grouping").iterator().next();
+        final Module testModule = CONTEXT.findModules("uses-grouping").iterator().next();
 
         // * notification pcreq
         final Collection<? extends NotificationDefinition> notifications = testModule.getNotifications();
@@ -406,7 +406,7 @@ public class UsesAugmentTest {
 
     @Test
     public void testTypedefs() throws Exception {
-        final Module testModule = context.findModules("grouping-definitions").iterator().next();
+        final Module testModule = CONTEXT.findModules("grouping-definitions").iterator().next();
         final Collection<? extends TypeDefinition<?>> types = testModule.getTypeDefinitions();
 
         TypeDefinition<?> intExt = null;