Reuse SchemaContext in NetconfCommandsImplTest 75/83975/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 26 Aug 2019 10:21:58 +0000 (12:21 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 26 Aug 2019 19:27:56 +0000 (21:27 +0200)
SchemaContext is an invariant here, make sure we reuse it across
tests.

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

index a70e629b6e1847985f78d8e6a10b2de0d2cd6f65..f8cb733ee1267ffff34ef2e149412042d124c663 100644 (file)
@@ -23,7 +23,9 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import org.awaitility.Awaitility;
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
@@ -63,20 +65,28 @@ public class NetconfCommandsImplTest {
             NetconfNodeConnectionStatus.ConnectionStatus.Connected;
     private static final String CAP_PREFIX = "prefix";
 
+    private static SchemaContext SCHEMA_CONTEXT;
+
     private DataBroker dataBroker;
-    private SchemaContext schemaContext;
     private NetconfCommandsImpl netconfCommands;
 
-    @Before
-    public void setUp() throws Exception {
-        schemaContext = YangParserTestUtils.parseYangResources(NetconfCommandsImplTest.class,
+    @BeforeClass
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = YangParserTestUtils.parseYangResources(NetconfCommandsImplTest.class,
             "/schemas/network-topology@2013-10-21.yang", "/schemas/ietf-inet-types@2013-07-15.yang",
             "/schemas/yang-ext.yang", "/schemas/netconf-node-topology.yang");
-        schemaContext.getModules();
+    }
 
+    @AfterClass
+    public static void afterClass() {
+        SCHEMA_CONTEXT = null;
+    }
+
+    @Before
+    public void setUp() throws Exception {
         ConcurrentDataBrokerTestCustomizer customizer = new ConcurrentDataBrokerTestCustomizer(true);
         dataBroker = customizer.createDataBroker();
-        customizer.updateSchema(schemaContext);
+        customizer.updateSchema(SCHEMA_CONTEXT);
 
         netconfCommands = new NetconfCommandsImpl(dataBroker);
     }