Merge "Custom mailbox that is bounded and instrumented."
[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     private Object executeLocalShardOperationResponse;
23
24     public MockActorContext(ActorSystem actorSystem) {
25         super(actorSystem, null, new MockClusterWrapper(), new MockConfiguration());
26     }
27
28     public MockActorContext(ActorSystem actorSystem, ActorRef shardManager) {
29         super(actorSystem, shardManager, new MockClusterWrapper(), new MockConfiguration());
30     }
31
32
33     @Override public Object executeShardOperation(String shardName,
34         Object message, FiniteDuration duration) {
35         return executeShardOperationResponse;
36     }
37
38     @Override public Object executeRemoteOperation(ActorSelection actor,
39         Object message, FiniteDuration duration) {
40         return executeRemoteOperationResponse;
41     }
42
43     @Override public ActorSelection findPrimary(String shardName) {
44         return null;
45     }
46
47     public void setExecuteShardOperationResponse(Object response){
48         executeShardOperationResponse = response;
49     }
50
51     public void setExecuteRemoteOperationResponse(Object response){
52         executeRemoteOperationResponse = response;
53     }
54
55     public void setExecuteLocalOperationResponse(
56         Object executeLocalOperationResponse) {
57         this.executeLocalOperationResponse = executeLocalOperationResponse;
58     }
59
60     public void setExecuteLocalShardOperationResponse(
61         Object executeLocalShardOperationResponse) {
62         this.executeLocalShardOperationResponse = executeLocalShardOperationResponse;
63     }
64
65     @Override public Object executeLocalOperation(ActorRef actor,
66         Object message, FiniteDuration duration) {
67         return this.executeLocalOperationResponse;
68     }
69
70     @Override public Object executeLocalShardOperation(String shardName,
71         Object message, FiniteDuration duration) {
72         return this.executeLocalShardOperationResponse;
73     }
74 }