This is an automated email from the ASF dual-hosted git repository. manikumar pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push: new 55707ada MINOR: add unit test for Utils.murmur2 (#5926) 55707ada is described below commit 55707adaee992e835a67920e016376235b92b70f Author: Nathan Murthy <1788878+natemur...@users.noreply.github.com> AuthorDate: Mon Jun 24 22:43:11 2019 -0700 MINOR: add unit test for Utils.murmur2 (#5926) --- .../java/org/apache/kafka/common/utils/UtilsTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/clients/src/test/java/org/apache/kafka/common/utils/UtilsTest.java b/clients/src/test/java/org/apache/kafka/common/utils/UtilsTest.java index 172a992..90cc7ac 100755 --- a/clients/src/test/java/org/apache/kafka/common/utils/UtilsTest.java +++ b/clients/src/test/java/org/apache/kafka/common/utils/UtilsTest.java @@ -32,6 +32,7 @@ import java.nio.file.Files; import java.nio.file.StandardOpenOption; import java.util.Collections; import java.util.HashSet; +import java.util.Map; import java.util.Random; import java.util.Set; import java.util.stream.Collectors; @@ -43,6 +44,7 @@ import static org.apache.kafka.common.utils.Utils.formatBytes; import static org.apache.kafka.common.utils.Utils.getHost; import static org.apache.kafka.common.utils.Utils.getPort; import static org.apache.kafka.common.utils.Utils.mkSet; +import static org.apache.kafka.common.utils.Utils.murmur2; import static org.apache.kafka.common.utils.Utils.validHostPattern; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -59,6 +61,21 @@ import static org.mockito.Mockito.when; public class UtilsTest { @Test + public void testMurmur2() { + Map<byte[], Integer> cases = new java.util.HashMap<>(); + cases.put("21".getBytes(), -973932308); + cases.put("foobar".getBytes(), -790332482); + cases.put("a-little-bit-long-string".getBytes(), -985981536); + cases.put("a-little-bit-longer-string".getBytes(), -1486304829); + cases.put("lkjh234lh9fiuh90y23oiuhsafujhadof229phr9h19h89h8".getBytes(), -58897971); + cases.put(new byte[]{'a', 'b', 'c'}, 479470107); + + for (Map.Entry c : cases.entrySet()) { + assertEquals((int) c.getValue(), murmur2((byte[]) c.getKey())); + } + } + + @Test public void testGetHost() { assertEquals("127.0.0.1", getHost("127.0.0.1:8000")); assertEquals("mydomain.com", getHost("PLAINTEXT://mydomain.com:8080"));