Speed up AbstractModificationTest 50/74950/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 8 Aug 2018 14:30:43 +0000 (16:30 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Sat, 11 Aug 2018 13:52:39 +0000 (13:52 +0000)
Sharing SchemaContext here shaves off about 2 seconds from
test run time.

Change-Id: I5e7fa63dd061ee6e1a16831aeae59f61deaccb5f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java

index 9daa342..e3bca7e 100644 (file)
@@ -11,7 +11,9 @@ package org.opendaylight.controller.cluster.datastore.modification;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Optional;
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
@@ -19,15 +21,27 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public abstract class AbstractModificationTest {
+    private static SchemaContext TEST_SCHEMA_CONTEXT;
 
     protected InMemoryDOMDataStore store;
 
+    @BeforeClass
+    public static void beforeClass() {
+        TEST_SCHEMA_CONTEXT = TestModel.createTestContext();
+    }
+
+    @AfterClass
+    public static void afterClass() {
+        TEST_SCHEMA_CONTEXT = null;
+    }
+
     @Before
     public void setUp() {
         store = new InMemoryDOMDataStore("test", MoreExecutors.newDirectExecutorService());
-        store.onGlobalContextUpdated(TestModel.createTestContext());
+        store.onGlobalContextUpdated(TEST_SCHEMA_CONTEXT);
     }
 
     protected void commitTransaction(final DOMStoreWriteTransaction transaction) {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.