Fix EventuallyConsistentMapImpl unit tests.
Change-Id: I5d114bac40c16d0f67330ba2b4b922a4301666b2
Showing
2 changed files
with
16 additions
and
5 deletions
... | @@ -85,7 +85,7 @@ public class EventuallyConsistentMapImpl<K, V> | ... | @@ -85,7 +85,7 @@ public class EventuallyConsistentMapImpl<K, V> |
85 | 85 | ||
86 | private final ScheduledExecutorService backgroundExecutor; | 86 | private final ScheduledExecutorService backgroundExecutor; |
87 | 87 | ||
88 | - private final ExecutorService broadcastMessageExecutor; | 88 | + private ExecutorService broadcastMessageExecutor; |
89 | 89 | ||
90 | private volatile boolean destroyed = false; | 90 | private volatile boolean destroyed = false; |
91 | private static final String ERROR_DESTROYED = " map is already destroyed"; | 91 | private static final String ERROR_DESTROYED = " map is already destroyed"; |
... | @@ -188,6 +188,18 @@ public class EventuallyConsistentMapImpl<K, V> | ... | @@ -188,6 +188,18 @@ public class EventuallyConsistentMapImpl<K, V> |
188 | }; | 188 | }; |
189 | } | 189 | } |
190 | 190 | ||
191 | + /** | ||
192 | + * Sets the executor to use for broadcasting messages and returns this | ||
193 | + * instance for method chaining. | ||
194 | + * @param executor executor service | ||
195 | + * @return this instance | ||
196 | + */ | ||
197 | + public EventuallyConsistentMapImpl<K, V> withBroadcastMessageExecutor(ExecutorService executor) { | ||
198 | + checkNotNull(executor, "Null executor"); | ||
199 | + broadcastMessageExecutor = executor; | ||
200 | + return this; | ||
201 | + } | ||
202 | + | ||
191 | @Override | 203 | @Override |
192 | public int size() { | 204 | public int size() { |
193 | checkState(!destroyed, mapName + ERROR_DESTROYED); | 205 | checkState(!destroyed, mapName + ERROR_DESTROYED); | ... | ... |
... | @@ -17,10 +17,10 @@ package org.onosproject.store.ecmap; | ... | @@ -17,10 +17,10 @@ package org.onosproject.store.ecmap; |
17 | 17 | ||
18 | import com.google.common.collect.ComparisonChain; | 18 | import com.google.common.collect.ComparisonChain; |
19 | import com.google.common.util.concurrent.ListenableFuture; | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | +import com.google.common.util.concurrent.MoreExecutors; | ||
20 | 21 | ||
21 | import org.junit.After; | 22 | import org.junit.After; |
22 | import org.junit.Before; | 23 | import org.junit.Before; |
23 | -import org.junit.Ignore; | ||
24 | import org.junit.Test; | 24 | import org.junit.Test; |
25 | import org.onlab.packet.IpAddress; | 25 | import org.onlab.packet.IpAddress; |
26 | import org.onlab.util.KryoNamespace; | 26 | import org.onlab.util.KryoNamespace; |
... | @@ -60,8 +60,6 @@ import static org.junit.Assert.fail; | ... | @@ -60,8 +60,6 @@ import static org.junit.Assert.fail; |
60 | /** | 60 | /** |
61 | * Unit tests for EventuallyConsistentMapImpl. | 61 | * Unit tests for EventuallyConsistentMapImpl. |
62 | */ | 62 | */ |
63 | -// FIXME: fix this test | ||
64 | -@Ignore | ||
65 | public class EventuallyConsistentMapImplTest { | 63 | public class EventuallyConsistentMapImplTest { |
66 | 64 | ||
67 | private EventuallyConsistentMap<String, String> ecMap; | 65 | private EventuallyConsistentMap<String, String> ecMap; |
... | @@ -144,7 +142,8 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -144,7 +142,8 @@ public class EventuallyConsistentMapImplTest { |
144 | 142 | ||
145 | ecMap = new EventuallyConsistentMapImpl<>(MAP_NAME, clusterService, | 143 | ecMap = new EventuallyConsistentMapImpl<>(MAP_NAME, clusterService, |
146 | clusterCommunicator, | 144 | clusterCommunicator, |
147 | - serializer, clockService); | 145 | + serializer, clockService) |
146 | + .withBroadcastMessageExecutor(MoreExecutors.newDirectExecutorService()); | ||
148 | 147 | ||
149 | // Reset ready for tests to add their own expectations | 148 | // Reset ready for tests to add their own expectations |
150 | reset(clusterCommunicator); | 149 | reset(clusterCommunicator); | ... | ... |
-
Please register or login to post a comment