FairSchedulerUtilities { public static String trimQueueName(String name) { if (name == null) { return null; } int start = 0; while (start < name.length() && isWhitespace(name.charAt(start)) && start < name.length()) { start++; } int end = name.length() - 1; while (end >= 0 && isWhitespace(name.charAt(end)) && end > start) { end--; } return name.substring(start, end+1); } private  FairSchedulerUtilities(); static String trimQueueName(String name);  }
@Test public void testTrimQueueNameEquals() throws Exception { final String[] equalsStrings = { "a", " a", " \u3000a", "\u2002\u3000\r\u0085\u200A\u2005\u2000\u3000a", "\u2029\u000B\u3000\u2008\u2003\u205F\u3000\u1680a", "\u0009\u0020\u2006\u2001\u202F\u00A0\u000C\u2009a", "\u3000\u2004\u3000\u3000\u2028\n\u2007\u3000a", "a\u200A", "a \u0085 ", " a ", " a\u00A0", "\u0009\u0020\u2006\u2001\u202F\u00A0\u000C\u2009a" + "\u3000\u2004\u3000\u3000\u2028\n\u2007\u3000", }; for (String s : equalsStrings) { assertEquals("a", trimQueueName(s)); } }
@Test public void testTrimQueueNamesEmpty() throws Exception { assertNull(trimQueueName(null)); final String spaces = "\u2002\u3000\r\u0085\u200A\u2005\u2000\u3000" + "\u2029\u000B\u3000\u2008\u2003\u205F\u3000\u1680" + "\u0009\u0020\u2006\u2001\u202F\u00A0\u000C\u2009" + "\u3000\u2004\u3000\u3000\u2028\n\u2007\u3000"; assertTrue(trimQueueName(spaces).isEmpty()); }