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.access.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;
24 public class ClientActorContextTest {
25 private static final MemberName MEMBER_NAME = MemberName.forName("member-1");
26 private static final FrontendType FRONTEND_TYPE = FrontendType.forName(ClientActorContextTest.class.getSimpleName());
27 private static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE);
28 private static final ClientIdentifier CLIENT_ID = ClientIdentifier.create(FRONTEND_ID, 0);
29 private static final String PERSISTENCE_ID = ClientActorContextTest.class.getSimpleName();
32 private ActorRef mockSelf;
35 private Scheduler mockScheduler;
38 private Dispatcher mockDispatcher;
42 MockitoAnnotations.initMocks(this);
46 public void testMockingControl() {
47 ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher, PERSISTENCE_ID, CLIENT_ID);
48 assertSame(CLIENT_ID, ctx.getIdentifier());
49 assertSame(PERSISTENCE_ID, ctx.persistenceId());
50 assertSame(mockSelf, ctx.self());
54 public void testTicker() {
55 ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher, PERSISTENCE_ID, CLIENT_ID);
56 assertSame(Ticker.systemTicker(), ctx.ticker());