Merge "Fixed for bug 1168 : Issue while update subnet"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / utils / MockActorContext.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.datastore.utils;
10
11
12 import akka.actor.ActorRef;
13 import akka.actor.ActorSelection;
14 import akka.actor.ActorSystem;
15 import scala.concurrent.duration.FiniteDuration;
16
17 public class MockActorContext extends ActorContext {
18
19     private Object executeShardOperationResponse;
20     private Object executeRemoteOperationResponse;
21     private Object executeLocalOperationResponse;
22
23     public MockActorContext(ActorSystem actorSystem) {
24         super(actorSystem, null, new MockClusterWrapper(), new MockConfiguration());
25     }
26
27     public MockActorContext(ActorSystem actorSystem, ActorRef shardManager) {
28         super(actorSystem, shardManager, new MockClusterWrapper(), new MockConfiguration());
29     }
30
31
32     @Override public Object executeShardOperation(String shardName,
33         Object message, FiniteDuration duration) {
34         return executeShardOperationResponse;
35     }
36
37     @Override public Object executeRemoteOperation(ActorSelection actor,
38         Object message, FiniteDuration duration) {
39         return executeRemoteOperationResponse;
40     }
41
42     @Override public ActorSelection findPrimary(String shardName) {
43         return null;
44     }
45
46     public void setExecuteShardOperationResponse(Object response){
47         executeShardOperationResponse = response;
48     }
49
50     public void setExecuteRemoteOperationResponse(Object response){
51         executeRemoteOperationResponse = response;
52     }
53
54     public void setExecuteLocalOperationResponse(
55         Object executeLocalOperationResponse) {
56         this.executeLocalOperationResponse = executeLocalOperationResponse;
57     }
58
59     @Override public Object executeLocalOperation(ActorRef actor,
60         Object message, FiniteDuration duration) {
61         return this.executeLocalOperationResponse;
62     }
63 }