diff options
| author | reger <reger18@arcor.de> | 2016-11-19 16:37:16 +0100 |
|---|---|---|
| committer | reger <reger18@arcor.de> | 2016-11-19 16:37:16 +0100 |
| commit | fdcf33f08f47061aaebd41baf7153158374fb406 (patch) | |
| tree | d1ec063f4d915f172c729108d323af0e9a3c504d /test | |
| parent | ac6e198bd1dc69bc52be0760e15ba8deb959f784 (diff) | |
fix Domain.stripToHostName for some IPv6 cases
add unit test for it
Diffstat (limited to 'test')
| -rw-r--r-- | test/java/net/yacy/cora/protocol/DomainsTest.java | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/test/java/net/yacy/cora/protocol/DomainsTest.java b/test/java/net/yacy/cora/protocol/DomainsTest.java index a953117ce..26bea5fd1 100644 --- a/test/java/net/yacy/cora/protocol/DomainsTest.java +++ b/test/java/net/yacy/cora/protocol/DomainsTest.java @@ -35,12 +35,13 @@ public class DomainsTest { @Test
public void testStripToPort() {
Map<String, Integer> testHost = new HashMap();
-
+ // key = teststring, value = expected port
testHost.put("[3ffe:2a00:100:7031::1]:80", 80);
testHost.put("https://[3ffe:2a00:100:7031::1]:80/test.html", 80);
testHost.put("[3ffe:2a00:100:7031::1]/test.html", 80);
testHost.put("http://[3ffe:2a00:100:7031::1]/test.html", 80);
testHost.put("[3ffe:2a00:100:7031::1]:8090/test.html", 8090);
+ testHost.put("ftp://[3ffe:2a00:100:7031::1]/test.html", 21);
for (String host : testHost.keySet()) {
int port = Domains.stripToPort(host);
@@ -49,4 +50,36 @@ public class DomainsTest { }
}
+
+ /**
+ * Test of stripToHostName method, of class Domains.
+ */
+ @Test
+ public void testStripToHostName() {
+ Map<String, String> testHost = new HashMap();
+ // key = teststring, value = expected host
+ testHost.put("[3ffe:2a00:100:7031::1]:80", "3ffe:2a00:100:7031::1");
+ testHost.put("https://[3ffe:2a00:100:7032::1]:80/test.html", "3ffe:2a00:100:7032::1");
+ testHost.put("[3ffe:2a00:100:7033::1]/test.html", "3ffe:2a00:100:7033::1");
+ testHost.put("http://[3ffe:2a00:100:7034::1]/test.html", "3ffe:2a00:100:7034::1");
+ testHost.put("[3ffe:2a00:100:7035::1]:8090/test.html", "3ffe:2a00:100:7035::1");
+ testHost.put("ftp://[3ffe:2a00:100:7036::1]/test.html", "3ffe:2a00:100:7036::1");
+
+ testHost.put("http://test1.org/test.html", "test1.org");
+ testHost.put("http://test2.org:80/test.html", "test2.org");
+ testHost.put("http://test3.org:7777/test.html", "test3.org");
+ testHost.put("http://www.test4.org/test.html", "www.test4.org");
+ testHost.put("http://www.test5.org:80/test.html", "www.test5.org");
+ testHost.put("http://www.test6.org:7777/test.html", "www.test6.org");
+
+ testHost.put("test7.org/test.html", "test7.org");
+ testHost.put("test8.org:80/test.html", "test8.org");
+ testHost.put("test9.org:7777/test.html", "test9.org");
+
+ for (String teststr : testHost.keySet()) {
+ String host = Domains.stripToHostName(teststr);
+ String expectedHost = testHost.get(teststr);
+ assertEquals(teststr, expectedHost, host);
+ }
+ }
}
|
