diff --git a/core-util/test/com/mirth/connect/util/HttpUtilTest.java b/core-util/test/com/mirth/connect/util/HttpUtilTest.java index f13811902..6e591391c 100644 --- a/core-util/test/com/mirth/connect/util/HttpUtilTest.java +++ b/core-util/test/com/mirth/connect/util/HttpUtilTest.java @@ -9,10 +9,13 @@ package com.mirth.connect.util; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import java.security.KeyStore; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.UUID; import javax.net.ssl.SSLContext; @@ -22,6 +25,9 @@ import org.apache.http.ssl.SSLContexts; import org.junit.Test; +import com.mirth.connect.donkey.model.message.ConnectorMessage; +import com.mirth.connect.donkey.util.MessageMaps; + public class HttpUtilTest { @Test @@ -40,4 +46,20 @@ public void testExecuteGetRequest() throws Exception { } catch (Exception e) { } } + + @Test + public void testMapOrderPreserved() { + final String MAP_KEY = "MyMap"; + + Map initial = new LinkedHashMap<>(); + initial.put("First", 1); + initial.put("Second", 2); + initial.put("Third", 3); + + ConnectorMessage cm = new ConnectorMessage(); + cm.getSourceMap().put(MAP_KEY, initial); + + Map copied = HttpUtil.getTableMap(MAP_KEY, new MessageMaps(), cm); + assertArrayEquals("Failed to preserve key order", initial.keySet().toArray(), copied.keySet().toArray()); + } }