Speed up AbstractTransactionProxyTest 49/74949/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 8 Aug 2018 14:26:48 +0000 (16:26 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Sat, 11 Aug 2018 13:51:41 +0000 (13:51 +0000)
Sharing SchemaContext here shaves off about 2 seconds from
test run time.

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

index 2dd62ab..4188157 100644 (file)
@@ -96,6 +96,7 @@ public abstract class AbstractTransactionProxyTest extends AbstractTest {
     protected final Logger log = LoggerFactory.getLogger(getClass());
 
     private static ActorSystem system;
+    private static SchemaContext SCHEMA_CONTEXT;
 
     private final Configuration configuration = new MockConfiguration() {
         Map<String, ShardStrategy> strategyMap = ImmutableMap.<String, ShardStrategy>builder().put(
@@ -143,8 +144,6 @@ public abstract class AbstractTransactionProxyTest extends AbstractTest {
 
     protected TransactionContextFactory mockComponentFactory;
 
-    private SchemaContext schemaContext;
-
     @Mock
     private ClusterWrapper mockClusterWrapper;
 
@@ -162,26 +161,26 @@ public abstract class AbstractTransactionProxyTest extends AbstractTest {
                         "akka.testkit.CallingThreadDispatcherConfigurator").build())
                 .withFallback(ConfigFactory.load());
         system = ActorSystem.create("test", config);
+        SCHEMA_CONTEXT = TestModel.createTestContext();
     }
 
     @AfterClass
     public static void tearDownClass() {
         TestKit.shutdownActorSystem(system);
         system = null;
+        SCHEMA_CONTEXT = null;
     }
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        schemaContext = TestModel.createTestContext();
-
         doReturn(getSystem()).when(mockActorContext).getActorSystem();
         doReturn(getSystem().dispatchers().defaultGlobalDispatcher()).when(mockActorContext).getClientDispatcher();
         doReturn(MemberName.forName(memberName)).when(mockActorContext).getCurrentMemberName();
         doReturn(new ShardStrategyFactory(configuration,
                 LogicalDatastoreType.CONFIGURATION)).when(mockActorContext).getShardStrategyFactory();
-        doReturn(schemaContext).when(mockActorContext).getSchemaContext();
+        doReturn(SCHEMA_CONTEXT).when(mockActorContext).getSchemaContext();
         doReturn(new Timeout(operationTimeoutInSeconds, TimeUnit.SECONDS)).when(mockActorContext).getOperationTimeout();
         doReturn(mockClusterWrapper).when(mockActorContext).getClusterWrapper();
         doReturn(mockClusterWrapper).when(mockActorContext).getClusterWrapper();

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