1 package org.opendaylight.controller.cluster.datastore;
3 import akka.actor.ActorRef;
4 import akka.actor.Props;
5 import com.google.common.util.concurrent.ListenableFuture;
6 import junit.framework.Assert;
7 import org.junit.Before;
9 import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply;
10 import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransactionReply;
11 import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply;
12 import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransactionReply;
13 import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor;
14 import org.opendaylight.controller.cluster.datastore.utils.MockActorContext;
16 import java.util.Arrays;
18 import static org.junit.Assert.assertNotNull;
20 public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest {
22 private ThreePhaseCommitCohortProxy proxy;
24 private ActorRef actorRef;
25 private MockActorContext actorContext;
29 props = Props.create(MessageCollectorActor.class);
30 actorRef = getSystem().actorOf(props);
31 actorContext = new MockActorContext(this.getSystem());
34 new ThreePhaseCommitCohortProxy(actorContext,
35 Arrays.asList(actorRef.path()));
40 public void testCanCommit() throws Exception {
41 actorContext.setExecuteRemoteOperationResponse(new CanCommitTransactionReply(true));
43 ListenableFuture<Boolean> future = proxy.canCommit();
45 Assert.assertTrue(future.get().booleanValue());
50 public void testPreCommit() throws Exception {
51 actorContext.setExecuteRemoteOperationResponse(new PreCommitTransactionReply());
53 ListenableFuture<Void> future = proxy.preCommit();
60 public void testAbort() throws Exception {
61 actorContext.setExecuteRemoteOperationResponse(new AbortTransactionReply());
63 ListenableFuture<Void> future = proxy.abort();
70 public void testCommit() throws Exception {
71 actorContext.setExecuteRemoteOperationResponse(new CommitTransactionReply());
73 ListenableFuture<Void> future = proxy.commit();
79 public void testGetCohortPaths() throws Exception {
80 assertNotNull(proxy.getCohortPaths());