Speed up DistributedDataStoreTest 51/74951/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 8 Aug 2018 14:36:20 +0000 (16:36 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Sat, 11 Aug 2018 13:53:04 +0000 (13:53 +0000)
Sharing SchemaContext shaves off about .5 seconds.

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

index f3e6e4b..cadec51 100644 (file)
@@ -17,7 +17,9 @@ import akka.util.Timeout;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
@@ -34,7 +36,7 @@ public class DistributedDataStoreTest extends AbstractActorTest {
     private static final ClientIdentifier UNKNOWN_ID = ClientIdentifier.create(
             FrontendIdentifier.create(MemberName.forName("local"), FrontendType.forName("unknown")), 0);
 
-    private SchemaContext schemaContext;
+    private static SchemaContext SCHEMA_CONTEXT;
 
     @Mock
     private ActorContext actorContext;
@@ -45,13 +47,21 @@ public class DistributedDataStoreTest extends AbstractActorTest {
     @Mock
     private Timeout shardElectionTimeout;
 
+    @BeforeClass
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = TestModel.createTestContext();
+    }
+
+    @AfterClass
+    public static void afterClass() {
+        SCHEMA_CONTEXT = null;
+    }
+
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        schemaContext = TestModel.createTestContext();
-
-        doReturn(schemaContext).when(actorContext).getSchemaContext();
+        doReturn(SCHEMA_CONTEXT).when(actorContext).getSchemaContext();
         doReturn(DatastoreContext.newBuilder().build()).when(actorContext).getDatastoreContext();
     }
 

©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.