### Question:
UrlHelper { public static List<String> extractUrls(String text) { return StringHelper.getRegexpMatches(URL_PATTERN, text); } private  UrlHelper(); static String removeSessionId(String originalUrl); static void makeAbsoluteUrls(Document document); static String getBaseUrl(Document document); static String makeFullUrl(String pageUrl, String baseUrl, String linkUrl); static String makeFullUrl(String contextUrl, String linkUrl); static String getCleanUrl(String url); static String removeAnchors(String url); static String getDomain(String url, boolean includeProtocol, boolean includeSubdomain); static String getDomain(String url, boolean includeProtocol); static String getDomain(String url); static String getCanonicalUrl(String url); static String decodeParameter(String string); static String encodeParameter(String string); static List<String> extractUrls(String text); static boolean isLocalFile(URL url); static String createParameterString(List<Pair<String, String>> parameters); static List<Pair<String, String>> parseParams(String parameterString); static String parseBaseUrl(String url); static boolean isValidUrl(String url); static final Pattern URL_PATTERN; }### Answer:
@Test public void testExtractUrls() { String text = "The quick brown fox jumps over the lazy dog. Check out: http: List<String> urls = UrlHelper.extractUrls(text); assertThat(urls, hasItem("http: assertThat(urls, hasItem("www.apple.com")); assertThat(urls, hasItem("google.com")); assertThat(urls, hasItem("www.tu-dresden.de")); assertThat(urls, hasItem("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("www.example.com", UrlHelper.extractUrls("Just a www.example.com link.").get(0)); assertEquals("http: assertEquals("bit.ly/foo", UrlHelper.extractUrls("bit.ly/foo").get(0)); assertEquals("WWW.EXAMPLE.COM", UrlHelper.extractUrls("WWW.EXAMPLE.COM").get(0)); assertEquals("http: assertEquals("example.com", UrlHelper.extractUrls("example.com").get(0)); assertEquals("example.com/", UrlHelper.extractUrls("example.com/").get(0)); assertThat(UrlHelper.extractUrls("[url=http: assertEquals("http: assertEquals("http: assertEquals("cinefreaks.com/coolstuff.zip", UrlHelper.extractUrls("You can download it here: cinefreaks.com/coolstuff.zip but be aware of the size.").get(0)); assertEquals("1-2-3.net/auctions-Are-out.jpg", UrlHelper.extractUrls("You can download it here: 1-2-3.net/auctions-Are-out.jpg but be aware of the size.").get(0)); assertEquals("http: assertEquals("www.cinefreaks.com/coolstuff.zip", UrlHelper.extractUrls("You can download it here: www.cinefreaks.com/coolstuff.zip but be aware of the size.").get(0)); assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals(0, UrlHelper.extractUrls("6:00p").size()); assertEquals(0, UrlHelper.extractUrls("filename.txt").size()); assertEquals(0, UrlHelper.extractUrls("16-28-33.0.backup.allcues.update.7z").size()); assertEquals(0, UrlHelper.extractUrls("09.Sep.11").size()); assertEquals(0, UrlHelper.extractUrls("Environment.CurrentDirectory").size()); assertEquals(0, UrlHelper.extractUrls("zipProcess.StandardOutput.ReadToEnd()").size()); assertEquals(0, UrlHelper.extractUrls("check_lang.sh").size()); }