2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.actors.client;
10 import static org.junit.Assert.assertSame;
11 import akka.actor.ActorRef;
12 import akka.actor.Scheduler;
13 import akka.dispatch.Dispatcher;
14 import com.google.common.base.Ticker;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.mockito.Mock;
18 import org.mockito.MockitoAnnotations;
19 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
20 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
21 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
22 import org.opendaylight.controller.cluster.access.concepts.MemberName;
23 import org.opendaylight.controller.cluster.datastore.ShardTransactionTest;
25 public class ClientActorContextTest {
26 private static final MemberName MEMBER_NAME = MemberName.forName("member-1");
27 private static final FrontendType FRONTEND_TYPE = FrontendType.forName(ShardTransactionTest.class.getSimpleName());
28 private static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE);
29 private static final ClientIdentifier CLIENT_ID = ClientIdentifier.create(FRONTEND_ID, 0);
30 private static final String PERSISTENCE_ID = ClientActorContextTest.class.getSimpleName();
33 private ActorRef mockSelf;
36 private Scheduler mockScheduler;
39 private Dispatcher mockDispatcher;
43 MockitoAnnotations.initMocks(this);
47 public void testMockingControl() {
48 ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher, PERSISTENCE_ID, CLIENT_ID);
49 assertSame(CLIENT_ID, ctx.getIdentifier());
50 assertSame(PERSISTENCE_ID, ctx.persistenceId());
51 assertSame(mockSelf, ctx.self());
55 public void testTicker() {
56 ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher, PERSISTENCE_ID, CLIENT_ID);
57 assertSame(Ticker.systemTicker(), ctx.ticker());