From 398c66f06c9d2db6a2bbd1e873316baebd04a914 Mon Sep 17 00:00:00 2001 From: luccioman Date: Mon, 20 Nov 2017 15:23:33 +0100 Subject: Do locale neutral case conversions in MultiProtocolURL For any relevant URL parts : host name, URL scheme, session ids or technical parts (see https://url.spec.whatwg.org/#url-writing and https://tools.ietf.org/html/rfc3986 for current standard references). Remaining locale sensitive conversion used for detection of URL word components in urlComps() makes sense but using detected language would be preferable than using the default system locale. --- .../net/yacy/cora/document/id/MultiProtocolURLTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/java/net/yacy/cora/document/id/MultiProtocolURLTest.java b/test/java/net/yacy/cora/document/id/MultiProtocolURLTest.java index 482ccc2c7..2e18ac578 100644 --- a/test/java/net/yacy/cora/document/id/MultiProtocolURLTest.java +++ b/test/java/net/yacy/cora/document/id/MultiProtocolURLTest.java @@ -14,10 +14,12 @@ import java.util.Map; import java.util.TreeSet; import org.junit.Test; -//import junit.framework.TestCase; +/** + * Automated unit tests for the {@link MultiProtocolURL} class. + */ public class MultiProtocolURLTest { - + @Test public void testSessionIdRemoval() throws MalformedURLException { String[][] testURIs = new String[][]{ @@ -169,11 +171,19 @@ public class MultiProtocolURLTest { Map testurls = new HashMap(); // ( 1. parameter = urlstring to test, 2. parameter = expected protocol) testurls.put("http://host.com", "http"); + testurls.put("HTTP://EXAMPLE.COM", "http"); + testurls.put("https://host.com", "https"); testurls.put("HTTPS://host.com", "https"); + testurls.put("Ftp://example.org", "ftp"); + testurls.put("FTP://EXAMPLE.ORG", "ftp"); testurls.put("Ftp://host.com", "ftp"); + testurls.put("smb://host.com", "smb"); testurls.put("SMB://host.com", "smb"); testurls.put("/file.com", "file"); testurls.put("file://host.com/file.com", "file"); + testurls.put("file:///file1.txt", "file"); + testurls.put("FILE:///file2.txt", "file"); + testurls.put("MAILTO:Abc@host.com", "mailto"); testurls.put("MailTo:Abc@host.com", "mailto"); for (String txt : testurls.keySet()) { @@ -258,10 +268,12 @@ public class MultiProtocolURLTest { Map testurls = new HashMap(); // key=testurl, value=result testurls.put("path/file.xml","xml"); // easiest + testurls.put("/FILE.GIF","gif"); // easy upper case testurls.put("path/file?h.pdf",""); // file w/o extension testurls.put("file.html?param=h.pdf","html"); // dot in query part testurls.put("url?param=h.pdf",""); // dot in query part testurls.put("file.html?param", "html"); + testurls.put("FILE.GIF?param", "gif"); testurls.put("/path/",""); for (String s : testurls.keySet()) { System.out.println("test getFileExtension: " + s + " -> " + testurls.get(s)); -- cgit v1.2.3