FairQueuePlacementUtils { protected static String assureRoot(String queueName) { if (queueName != null && !queueName.isEmpty()) { if (!queueName.startsWith(ROOT_QUEUE + DOT) && !queueName.equals(ROOT_QUEUE)) { queueName = ROOT_QUEUE + DOT + queueName; } } else { LOG.warn("AssureRoot: queueName is empty or null."); } return queueName; } private  FairQueuePlacementUtils();   }
@Test public void testAssureRoot() { final String queueName = "base"; final String rootOnly = "root"; final String rootNoDot = "rootbase"; final String alreadyRoot = "root.base"; String rooted = assureRoot(queueName); assertTrue("Queue should have root prefix (base)", rooted.startsWith(ROOT_QUEUE + DOT)); rooted = assureRoot(rootOnly); assertEquals("'root' queue should not have root prefix (root)", rootOnly, rooted); rooted = assureRoot(rootNoDot); assertTrue("Queue should have root prefix (rootbase)", rooted.startsWith(ROOT_QUEUE + DOT)); assertEquals("'root' queue base was replaced and not prefixed", 5, rooted.lastIndexOf(ROOT_QUEUE)); rooted = assureRoot(alreadyRoot); assertEquals("Root prefixed queue changed and it should not (root.base)", rooted, alreadyRoot); assertNull("Null queue did not return null queue", assureRoot(null)); assertEquals("Empty queue did not return empty name", "", assureRoot("")); }