From b28e4ad8de1924e2cfad9116c0447152e4c1cf09 Mon Sep 17 00:00:00 2001 From: Madan Jampani Date: Thu, 19 Feb 2015 12:31:37 -0800 Subject: [PATCH] Fix EventuallyConsistentMapImpl unit tests. Change-Id: I5d114bac40c16d0f67330ba2b4b922a4301666b2 --- .../store/ecmap/EventuallyConsistentMapImpl.java | 14 +++++++++++++- .../ecmap/EventuallyConsistentMapImplTest.java | 7 +++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java b/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java index 8c52156f00..fd05d7f449 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java +++ b/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java @@ -85,7 +85,7 @@ public class EventuallyConsistentMapImpl private final ScheduledExecutorService backgroundExecutor; - private final ExecutorService broadcastMessageExecutor; + private ExecutorService broadcastMessageExecutor; private volatile boolean destroyed = false; private static final String ERROR_DESTROYED = " map is already destroyed"; @@ -188,6 +188,18 @@ public class EventuallyConsistentMapImpl }; } + /** + * Sets the executor to use for broadcasting messages and returns this + * instance for method chaining. + * @param executor executor service + * @return this instance + */ + public EventuallyConsistentMapImpl withBroadcastMessageExecutor(ExecutorService executor) { + checkNotNull(executor, "Null executor"); + broadcastMessageExecutor = executor; + return this; + } + @Override public int size() { checkState(!destroyed, mapName + ERROR_DESTROYED); diff --git a/core/store/dist/src/test/java/org/onosproject/store/ecmap/EventuallyConsistentMapImplTest.java b/core/store/dist/src/test/java/org/onosproject/store/ecmap/EventuallyConsistentMapImplTest.java index 5a8d8b7f95..951f18e0fc 100644 --- a/core/store/dist/src/test/java/org/onosproject/store/ecmap/EventuallyConsistentMapImplTest.java +++ b/core/store/dist/src/test/java/org/onosproject/store/ecmap/EventuallyConsistentMapImplTest.java @@ -17,10 +17,10 @@ package org.onosproject.store.ecmap; import com.google.common.collect.ComparisonChain; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.onlab.packet.IpAddress; import org.onlab.util.KryoNamespace; @@ -60,8 +60,6 @@ import static org.junit.Assert.fail; /** * Unit tests for EventuallyConsistentMapImpl. */ -// FIXME: fix this test -@Ignore public class EventuallyConsistentMapImplTest { private EventuallyConsistentMap ecMap; @@ -144,7 +142,8 @@ public class EventuallyConsistentMapImplTest { ecMap = new EventuallyConsistentMapImpl<>(MAP_NAME, clusterService, clusterCommunicator, - serializer, clockService); + serializer, clockService) + .withBroadcastMessageExecutor(MoreExecutors.newDirectExecutorService()); // Reset ready for tests to add their own expectations reset(clusterCommunicator);