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;
13 import akka.actor.ActorSelection;
14 import org.junit.Test;
15 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
16 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
17 import scala.concurrent.Future;
20 * Unit tests for PrimaryShardInfoFutureCache.
22 * @author Thomas Pantelis
24 public class PrimaryShardInfoFutureCacheTest {
27 public void testOperations() {
28 PrimaryShardInfoFutureCache cache = new PrimaryShardInfoFutureCache();
30 assertEquals("getIfPresent", null, cache.getIfPresent("foo"));
32 PrimaryShardInfo shardInfo = new PrimaryShardInfo(mock(ActorSelection.class), DataStoreVersions.CURRENT_VERSION);
33 cache.putSuccessful("foo", shardInfo);
35 Future<PrimaryShardInfo> future = cache.getIfPresent("foo");
36 assertNotNull("Null future", future);
37 assertEquals("getIfPresent", shardInfo, future.value().get().get());
41 assertEquals("getIfPresent", null, cache.getIfPresent("foo"));