Fix EventuallyConsistentMapImpl unit tests.
Change-Id: I5d114bac40c16d0f67330ba2b4b922a4301666b2
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 8c52156..fd05d7f 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 @@
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 @@
};
}
+ /**
+ * Sets the executor to use for broadcasting messages and returns this
+ * instance for method chaining.
+ * @param executor executor service
+ * @return this instance
+ */
+ public EventuallyConsistentMapImpl<K, V> 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 5a8d8b7..951f18e 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 @@
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 @@
/**
* Unit tests for EventuallyConsistentMapImpl.
*/
-// FIXME: fix this test
-@Ignore
public class EventuallyConsistentMapImplTest {
private EventuallyConsistentMap<String, String> ecMap;
@@ -144,7 +142,8 @@
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);