Refactor MockConfiguration to extend ConfigurationImpl
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / utils / ActorContextTest.java
index 2b9b9d635e4f4e0861d71ba00c833efff002ad44..7e484ebde3d79bcadbb182162c55c23c56675d78 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 package org.opendaylight.controller.cluster.datastore.utils;
 
 import static org.junit.Assert.assertEquals;
@@ -33,9 +41,10 @@ import org.junit.Test;
 import org.mockito.Mockito;
 import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
 import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
-import org.opendaylight.controller.cluster.datastore.Configuration;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
+import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
+import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
 import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
 import org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException;
@@ -366,9 +375,12 @@ public class ActorContextTest extends AbstractActorTest{
             DatastoreContext newContext = DatastoreContext.newBuilder().operationTimeoutInSeconds(6).
                     shardTransactionCommitTimeoutInSeconds(8).build();
 
-            actorContext.setDatastoreContext(newContext);
+            DatastoreContextFactory mockContextFactory = mock(DatastoreContextFactory.class);
+            Mockito.doReturn(newContext).when(mockContextFactory).getBaseDatastoreContext();
+
+            actorContext.setDatastoreContext(mockContextFactory);
 
-            expectMsgClass(duration("5 seconds"), DatastoreContext.class);
+            expectMsgClass(duration("5 seconds"), DatastoreContextFactory.class);
 
             Assert.assertSame("getDatastoreContext", newContext, actorContext.getDatastoreContext());
 
@@ -534,10 +546,11 @@ public class ActorContextTest extends AbstractActorTest{
         }};
     }
 
-    private <T> T expectFirstMatching(ActorRef actor, Class<T> clazz) {
+    private static <T> T expectFirstMatching(ActorRef actor, Class<T> clazz) {
         int count = 5000 / 50;
         for(int i = 0; i < count; i++) {
             try {
+                @SuppressWarnings("unchecked")
                 T message = (T) MessageCollectorActor.getFirstMatching(actor, clazz);
                 if(message != null) {
                     return message;