From: Robert Varga Date: Tue, 27 Nov 2018 16:38:16 +0000 (+0100) Subject: Use predictable-order sets X-Git-Tag: release/neon~14 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=17a4bc86d611f828288c85b5a58e176035a0b95b;p=lispflowmapping.git Use predictable-order sets MapServerTest requires MapServer to respond with specific order of items. Use LinkedHashMap/ImmutableSet to achieve that consistently. Change-Id: Ia96ac31e434f8fee5095802de446f0b1dc1eeeb7 Signed-off-by: Robert Varga --- diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java index cba7fc1b7..5dd1c36f6 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java @@ -17,8 +17,8 @@ import java.net.SocketException; import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -145,7 +145,7 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener, IS MapNotifyBuilder builder = new MapNotifyBuilder(); List rlocs = null; if (merge) { - Set notifyRlocs = new HashSet(); + Set notifyRlocs = new LinkedHashSet(); List mergedMappings = new ArrayList(); for (MappingRecordItem record : mapRegister.getMappingRecordItem()) { MappingRecord mapping = record.getMappingRecord(); diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java index 1593a82da..c38123234 100644 --- a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java +++ b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java @@ -9,6 +9,7 @@ package org.opendaylight.lispflowmapping.implementation.lisp; import static org.junit.Assert.assertEquals; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import java.lang.reflect.Field; @@ -409,9 +410,7 @@ public class MapServerTest { } private static Set getDefaultIpAddressSet() { - final Set addressSet = Sets.newHashSet(IPV4_BINARY_1, IPV4_BINARY_2); - - return addressSet; + return ImmutableSet.of(IPV4_BINARY_1, IPV4_BINARY_2); } private static List getTransportAddressList() {