Move MessageTrackerTest
[controller.git] / opendaylight / md-sal / cds-access-client / src / test / java / org / opendaylight / controller / cluster / access / client / ClientActorContextTest.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.controller.cluster.access.client;
9
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
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();
30
31     @Mock
32     private ActorRef mockSelf;
33
34     @Mock
35     private Scheduler mockScheduler;
36
37     @Mock
38     private Dispatcher mockDispatcher;
39
40     @Before
41     public void setup() {
42         MockitoAnnotations.initMocks(this);
43     }
44
45     @Test
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());
51     }
52
53     @Test
54     public void testTicker() {
55         ClientActorContext ctx = new ClientActorContext(mockSelf, mockScheduler, mockDispatcher, PERSISTENCE_ID, CLIENT_ID);
56         assertSame(Ticker.systemTicker(), ctx.ticker());
57     }
58 }