zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anmolnar <...@git.apache.org>
Subject [GitHub] zookeeper pull request #548: [ZOOKEEPER-3057] Fix IPv6 literal usage
Date Mon, 25 Jun 2018 12:46:33 GMT
Github user anmolnar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/548#discussion_r197781125
  
    --- Diff: src/java/test/org/apache/zookeeper/common/NetUtilsTest.java ---
    @@ -0,0 +1,46 @@
    +package apache.zookeeper.common;
    +
    +import org.apache.zookeeper.common.NetUtils;
    +import org.apache.zookeeper.ZKTestCase;
    +import org.hamcrest.core.AnyOf;
    +import org.hamcrest.core.IsEqual;
    +import org.junit.Assert;
    +import org.junit.Test;
    +import java.net.InetSocketAddress;
    +
    +public class NetUtilsTest extends ZKTestCase {
    +
    +    private Integer port = 1234;
    +    private String v4addr = "127.0.0.1";
    +    private String v6addr = "[0:0:0:0:0:0:0:1]";
    +    private String v4local = v4addr + ":" + port.toString();
    +    private String v6local = v6addr + ":" + port.toString();
    +
    +    @Test
    +    public void testformatInetAddrGoodIpv4() {
    +        InetSocketAddress isa = new InetSocketAddress(v4addr, port);
    +        Assert.assertEquals("127.0.0.1:1234", NetUtils.formatInetAddr(isa));
    +    }
    +
    +    @Test
    +    public void testFormatInetAddrGoodIpv6() {
    --- End diff --
    
    I think it'd be great to add more IPv6 formatting tests other than the localhost case.


---

Mime
View raw message