From 2a0dafa2f4e1a8f1fac38e8bf750b77858c03af3 Mon Sep 17 00:00:00 2001 From: Daniella Hubble <68478626+DaniellaHubble@users.noreply.github.com> Date: Fri, 22 Nov 2024 00:14:05 -0600 Subject: [PATCH] fix flaky tests (#12885) --- .../client/naming/selector/NamingSelectorFactoryTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java index 3c3aa27ad95..f4520de8801 100644 --- a/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java +++ b/client/src/test/java/com/alibaba/nacos/client/naming/selector/NamingSelectorFactoryTest.java @@ -24,7 +24,7 @@ import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -92,6 +92,7 @@ public void testNewIpSelector() { @Test public void testNewMetadataSelector() { Instance ins1 = new Instance(); + ins1.setMetadata(new LinkedHashMap<>()); ins1.addMetadata("a", "1"); ins1.addMetadata("b", "2"); Instance ins2 = new Instance(); @@ -102,7 +103,7 @@ public void testNewMetadataSelector() { NamingContext namingContext = mock(NamingContext.class); when(namingContext.getInstances()).thenReturn(Arrays.asList(ins1, ins2, ins3)); - NamingSelector metadataSelector = NamingSelectorFactory.newMetadataSelector(new HashMap() { + NamingSelector metadataSelector = NamingSelectorFactory.newMetadataSelector(new LinkedHashMap() { { put("a", "1"); put("b", "2"); @@ -117,6 +118,7 @@ public void testNewMetadataSelector() { @Test public void testNewMetadataSelector2() { Instance ins1 = new Instance(); + ins1.setMetadata(new LinkedHashMap<>()); ins1.addMetadata("a", "1"); ins1.addMetadata("c", "3"); Instance ins2 = new Instance(); @@ -127,7 +129,7 @@ public void testNewMetadataSelector2() { NamingContext namingContext = mock(NamingContext.class); when(namingContext.getInstances()).thenReturn(Arrays.asList(ins1, ins2, ins3)); - NamingSelector metadataSelector = NamingSelectorFactory.newMetadataSelector(new HashMap() { + NamingSelector metadataSelector = NamingSelectorFactory.newMetadataSelector(new LinkedHashMap() { { put("a", "1"); put("b", "2");