From: Robert Varga Date: Wed, 8 Aug 2018 14:36:20 +0000 (+0200) Subject: Speed up DistributedDataStoreTest X-Git-Tag: release/neon~105 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=78622608d4c83bfc2e755c63b8b326e746ec500c Speed up DistributedDataStoreTest Sharing SchemaContext shaves off about .5 seconds. Change-Id: I628af3b577ca53fc9f5ace05dc825f7324b71b8f Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java index f3e6e4bbc9..cadec51432 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java @@ -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(); }