@Test public void testJoinURL() { logger.info("joinURL"); Map<URLParser.URLParts, String> urlParts = new HashMap<>(); urlParts.put(URLParser.URLParts.PROTOCOL, "http"); urlParts.put(URLParser.URLParts.PATH, "/to/path/document"); urlParts.put(URLParser.URLParts.HOST, "www.example.com"); urlParts.put(URLParser.URLParts.PORT, "8080"); urlParts.put(URLParser.URLParts.USERINFO, "user:password"); urlParts.put(URLParser.URLParts.FILENAME, "/to/path/document?arg1=val1&arg2=val2"); urlParts.put(URLParser.URLParts.QUERY, "arg1=val1&arg2=val2"); urlParts.put(URLParser.URLParts.AUTHORITY, "user:password@www.example.com:8080"); urlParts.put(URLParser.URLParts.REF, "part"); String expResult = "http: String result = URLParser.joinURL(urlParts); assertEquals(expResult, result); }
public static String joinURL(Map<URLParts, String> urlParts) { try { URI uri = new URI(urlParts.get(URLParts.PROTOCOL), urlParts.get(URLParts.AUTHORITY), urlParts.get(URLParts.PATH), urlParts.get(URLParts.QUERY), urlParts.get(URLParts.REF)); return uri.toString(); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } }
URLParser { public static String joinURL(Map<URLParts, String> urlParts) { try { URI uri = new URI(urlParts.get(URLParts.PROTOCOL), urlParts.get(URLParts.AUTHORITY), urlParts.get(URLParts.PATH), urlParts.get(URLParts.QUERY), urlParts.get(URLParts.REF)); return uri.toString(); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } } }
URLParser { public static String joinURL(Map<URLParts, String> urlParts) { try { URI uri = new URI(urlParts.get(URLParts.PROTOCOL), urlParts.get(URLParts.AUTHORITY), urlParts.get(URLParts.PATH), urlParts.get(URLParts.QUERY), urlParts.get(URLParts.REF)); return uri.toString(); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } }  }
URLParser { public static String joinURL(Map<URLParts, String> urlParts) { try { URI uri = new URI(urlParts.get(URLParts.PROTOCOL), urlParts.get(URLParts.AUTHORITY), urlParts.get(URLParts.PATH), urlParts.get(URLParts.QUERY), urlParts.get(URLParts.REF)); return uri.toString(); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } }  static URL toAbsolute(URL baseURL, String relative); static String toAbsolute(String base, String relative); static Map<URLParts, String> splitURL(String URLString); static Map<URLParts, String> splitURL(URL url); static String joinURL(Map<URLParts, String> urlParts); static Map<DomainParts, String> splitDomain(String domain); }
URLParser { public static String joinURL(Map<URLParts, String> urlParts) { try { URI uri = new URI(urlParts.get(URLParts.PROTOCOL), urlParts.get(URLParts.AUTHORITY), urlParts.get(URLParts.PATH), urlParts.get(URLParts.QUERY), urlParts.get(URLParts.REF)); return uri.toString(); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } }  static URL toAbsolute(URL baseURL, String relative); static String toAbsolute(String base, String relative); static Map<URLParts, String> splitURL(String URLString); static Map<URLParts, String> splitURL(URL url); static String joinURL(Map<URLParts, String> urlParts); static Map<DomainParts, String> splitDomain(String domain);  }