FairQueuePlacementUtils { protected static boolean isValidQueueName(String queueName) { if (queueName != null) { if (queueName.equals(FairSchedulerUtilities.trimQueueName(queueName)) && !queueName.startsWith(DOT) && !queueName.endsWith(DOT)) { return true; } } return false; } private  FairQueuePlacementUtils();   }
@Test public void testIsValidQueueName() { final String valid = "valid"; final String validRooted = "root.valid"; final String rootOnly = "root"; final String startDot = ".invalid"; final String endDot = "invalid."; final String startSpace = " invalid"; final String endSpace = "invalid "; final String unicodeSpace = "\u00A0invalid"; assertFalse("'null' queue was not marked as invalid", isValidQueueName(null)); assertTrue("empty queue was not tagged valid", isValidQueueName("")); assertTrue("Simple queue name was not tagged valid (valid)", isValidQueueName(valid)); assertTrue("Root only queue was not tagged valid (root)", isValidQueueName(rootOnly)); assertTrue("Root prefixed queue was not tagged valid (root.valid)", isValidQueueName(validRooted)); assertFalse("Queue starting with dot was not tagged invalid (.invalid)", isValidQueueName(startDot)); assertFalse("Queue ending with dot was not tagged invalid (invalid.)", isValidQueueName(endDot)); assertFalse("Queue starting with space was not tagged invalid ( invalid)", isValidQueueName(startSpace)); assertFalse("Queue ending with space was not tagged invalid (invalid )", isValidQueueName(endSpace)); assertFalse("Queue with unicode space was not tagged as invalid (unicode)", isValidQueueName(unicodeSpace)); }