StringUtils { public static boolean isFromBrowser(final String userAgent) { if (userAgent == null) { return false; } if (BROWSWER_PATTERN.matcher(userAgent).matches()) { return true; } else { return false; } }  static String shellQuote(final String s, final char quoteCh); @Deprecated static String join(final List<String> list, final String delimiter); static String join(final Collection<String> list, final String delimiter); static String join2(final Collection<String> list, final String delimiter); static boolean isFromBrowser(final String userAgent); static boolean isEmpty(final String value); static final char SINGLE_QUOTE; static final char DOUBLE_QUOTE; }
@Test public void isBrowser() throws Exception { for (final String browser : browserVariants) { Assert.assertTrue(browser, StringUtils.isFromBrowser(browser)); } }
@Test public void notBrowserWithLowercase() throws Exception { for (final String browser : browserVariants) { Assert.assertFalse(browser.toLowerCase(), StringUtils.isFromBrowser(browser.toLowerCase())); } }
@Test public void notBrowser() throws Exception { final String testStr = "curl"; Assert.assertFalse(testStr, StringUtils.isFromBrowser(testStr)); }
@Test public void emptyBrowserString() throws Exception { Assert.assertFalse("empty string", StringUtils.isFromBrowser("")); }
@Test public void nullBrowserString() throws Exception { Assert.assertFalse("null string", StringUtils.isFromBrowser(null)); }
@Test public void startsWithBrowserName() { for (final String name : BROWSER_NAMES) { Assert.assertTrue(StringUtils.isFromBrowser(name + " is awesome")); } }
@Test public void endsWithBrowserName() { for (final String name : BROWSER_NAMES) { Assert.assertTrue(StringUtils.isFromBrowser("awesome is" + name)); } }
@Test public void containsBrowserName() { for (final String name : BROWSER_NAMES) { Assert.assertTrue(StringUtils.isFromBrowser("awesome " + name + " is")); } }