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 com.google.common.base.Ticker;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.mockito.Mock;
16 import org.mockito.MockitoAnnotations;
17 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
18 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
19 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
20 import org.opendaylight.controller.cluster.access.concepts.MemberName;
21 import org.opendaylight.controller.cluster.datastore.ShardTransactionTest;
23 public class ClientActorContextTest {
24 private static final MemberName MEMBER_NAME = MemberName.forName("member-1");
25 private static final FrontendType FRONTEND_TYPE = FrontendType.forName(ShardTransactionTest.class.getSimpleName());
26 private static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE);
27 private static final ClientIdentifier CLIENT_ID = ClientIdentifier.create(FRONTEND_ID, 0);
28 private static final String PERSISTENCE_ID = ClientActorContextTest.class.getSimpleName();
31 private ActorRef mockSelf;
35 MockitoAnnotations.initMocks(this);
39 public void testMockingControl() {
40 ClientActorContext ctx = new ClientActorContext(mockSelf, PERSISTENCE_ID, CLIENT_ID);
41 assertSame(CLIENT_ID, ctx.getIdentifier());
42 assertSame(PERSISTENCE_ID, ctx.persistenceId());
43 assertSame(mockSelf, ctx.self());
47 public void testTicker() {
48 ClientActorContext ctx = new ClientActorContext(mockSelf, PERSISTENCE_ID, CLIENT_ID);
49 assertSame(Ticker.systemTicker(), ctx.ticker());