From bde847f2b88d91264cca2e3a3e2637ca56c8ece6 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 26 Aug 2019 12:21:33 +0200 Subject: [PATCH] Reuse SchemaContext in NetconfDeviceTopologyAdapterTest The SchemaContext is an invariant, make sure we reuse it across tests. Change-Id: Ib31ec637c15d50d9f7c105128e0ff5c31b9861bb Signed-off-by: Robert Varga --- .../sal/NetconfDeviceTopologyAdapterTest.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapterTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapterTest.java index 1c5f6428fb..acc16d985c 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapterTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapterTest.java @@ -19,7 +19,9 @@ import java.net.InetSocketAddress; import java.util.Optional; import java.util.concurrent.TimeUnit; import org.awaitility.Awaitility; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -48,6 +50,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; public class NetconfDeviceTopologyAdapterTest { + private static SchemaContext SCHEMA_CONTEXT; private final RemoteDeviceId id = new RemoteDeviceId("test", new InetSocketAddress("localhost", 22)); @@ -60,7 +63,6 @@ public class NetconfDeviceTopologyAdapterTest { private final String txIdent = "test transaction"; - private SchemaContext schemaContext = null; private final String sessionIdForReporting = "netconf-test-session1"; private TransactionChain transactionChain; @@ -69,6 +71,19 @@ public class NetconfDeviceTopologyAdapterTest { private DOMDataBroker domDataBroker; + @BeforeClass + public static void beforeClass() { + SCHEMA_CONTEXT = YangParserTestUtils.parseYangResources(NetconfDeviceTopologyAdapterTest.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", + "/schemas/network-topology-augment-test@2016-08-08.yang"); + } + + @AfterClass + public static void afterClass() { + SCHEMA_CONTEXT = null; + } + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); @@ -80,16 +95,10 @@ public class NetconfDeviceTopologyAdapterTest { doReturn(txIdent).when(writeTx).getIdentifier(); - this.schemaContext = YangParserTestUtils.parseYangResources(NetconfDeviceTopologyAdapterTest.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", - "/schemas/network-topology-augment-test@2016-08-08.yang"); - schemaContext.getModules(); - ConcurrentDataBrokerTestCustomizer customizer = new ConcurrentDataBrokerTestCustomizer(true); domDataBroker = customizer.getDOMDataBroker(); dataBroker = customizer.createDataBroker(); - customizer.updateSchema(schemaContext); + customizer.updateSchema(SCHEMA_CONTEXT); transactionChain = dataBroker.createTransactionChain(new TransactionChainListener() { @Override -- 2.36.6