2 * Copyright (c) 2015 Brocade Communications 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.utils;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.mockito.Mockito.mock;
14 import akka.actor.ActorSelection;
15 import org.junit.Test;
16 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
17 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
18 import scala.concurrent.Future;
21 * Unit tests for PrimaryShardInfoFutureCache.
23 * @author Thomas Pantelis
25 public class PrimaryShardInfoFutureCacheTest {
28 public void testOperations() {
29 PrimaryShardInfoFutureCache cache = new PrimaryShardInfoFutureCache();
31 assertEquals("getIfPresent", null, cache.getIfPresent("foo"));
33 PrimaryShardInfo shardInfo = new PrimaryShardInfo(mock(ActorSelection.class),
34 DataStoreVersions.CURRENT_VERSION);
35 cache.putSuccessful("foo", shardInfo);
37 Future<PrimaryShardInfo> future = cache.getIfPresent("foo");
38 assertNotNull("Null future", future);
39 assertEquals("getIfPresent", shardInfo, future.value().get().get());
43 assertEquals("getIfPresent", null, cache.getIfPresent("foo"));