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);
  }
@Test
  public void testTrimQueueNameEquals() throws Exception {
    final String[] equalsStrings = {
        // no spaces
        "a",
        // leading spaces
        " 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",
        // trailing spaces
        "a\u200A",
        "a  \u0085 ",
        // spaces on both sides
        " 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));
    }
  }