|
@@ -21,6 +21,7 @@ package org.apache.zookeeper.test;
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertEquals;
|
|
import org.apache.zookeeper.ZKTestCase;
|
|
import org.apache.zookeeper.ZKTestCase;
|
|
import org.apache.zookeeper.client.ConnectStringParser;
|
|
import org.apache.zookeeper.client.ConnectStringParser;
|
|
|
|
+import org.junit.Assert;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
public class ConnectStringParserTest extends ZKTestCase {
|
|
public class ConnectStringParserTest extends ZKTestCase {
|
|
@@ -85,4 +86,25 @@ public class ConnectStringParserTest extends ZKTestCase {
|
|
assertEquals(expected, parser.getChrootPath());
|
|
assertEquals(expected, parser.getChrootPath());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
+ public void testParseIPV6ConnectionString() {
|
|
|
|
+ String servers = "[127::1],127.0.10.2";
|
|
|
|
+ ConnectStringParser parser = new ConnectStringParser(servers);
|
|
|
|
+
|
|
|
|
+ Assert.assertEquals("127::1", parser.getServerAddresses().get(0).getHostString());
|
|
|
|
+ Assert.assertEquals("127.0.10.2", parser.getServerAddresses().get(1).getHostString());
|
|
|
|
+ Assert.assertEquals(2181, parser.getServerAddresses().get(0).getPort());
|
|
|
|
+ Assert.assertEquals(2181, parser.getServerAddresses().get(1).getPort());
|
|
|
|
+
|
|
|
|
+ servers = "[127::1]:2181,[127::2]:2182,[127::3]:2183";
|
|
|
|
+ parser = new ConnectStringParser(servers);
|
|
|
|
+
|
|
|
|
+ Assert.assertEquals("127::1", parser.getServerAddresses().get(0).getHostString());
|
|
|
|
+ Assert.assertEquals("127::2", parser.getServerAddresses().get(1).getHostString());
|
|
|
|
+ Assert.assertEquals("127::3", parser.getServerAddresses().get(2).getHostString());
|
|
|
|
+ Assert.assertEquals(2181, parser.getServerAddresses().get(0).getPort());
|
|
|
|
+ Assert.assertEquals(2182, parser.getServerAddresses().get(1).getPort());
|
|
|
|
+ Assert.assertEquals(2183, parser.getServerAddresses().get(2).getPort());
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|