/** * Test that print job queue recursively prints child queues */ @Test @SuppressWarnings("deprecation") public void testPrintJobQueueInfo() throws IOException { JobQueueClient queueClient = new JobQueueClient(); JobQueueInfo parent = new JobQueueInfo(); JobQueueInfo child = new JobQueueInfo(); JobQueueInfo grandChild = new JobQueueInfo(); child.addChild(grandChild); parent.addChild(child); grandChild.setQueueName("GrandChildQueue"); ByteArrayOutputStream bbos = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter(bbos); queueClient.printJobQueueInfo(parent, writer); Assert.assertTrue("printJobQueueInfo did not print grandchild's name", bbos.toString().contains("GrandChildQueue")); }
/** * @return a simple hierarchy of JobQueueInfos */ static JobQueueInfo[] getSimpleQueueHierarchy() { int numQs = 3; JobQueueInfo[] queues = new JobQueueInfo[numQs]; queues[0] = newJobQueueInfo(new ArrayList<JobQueueInfo>(), null, "q1", QueueState.UNDEFINED, null); queues[1] = newJobQueueInfo(new ArrayList<JobQueueInfo>(), null, "q1:q2", QueueState.RUNNING, null); queues[2] = newJobQueueInfo(new ArrayList<JobQueueInfo>(), null, "q1:q3", QueueState.RUNNING, null); queues[0].addChild(queues[1]); queues[0].addChild(queues[2]); return queues; }
/** * Test to verify that the refresh of queue properties fails if a new queue is * added. * * @throws Exception */ @Test public void testRefreshWithAddedQueues() throws Exception { JobQueueInfo[] queues = getSimpleQueueHierarchy(); // write the configuration file writeQueueConfigurationFile( QUEUES_CONFIG_FILE_PATH, new JobQueueInfo[] { queues[0] }); QueueManager qManager = new QueueManager(); JobQueueInfo newQueue = newJobQueueInfo(new ArrayList<JobQueueInfo>(), null, "q4", QueueState.UNDEFINED, null); queues[0].addChild(newQueue); // Rewrite the configuration file writeQueueConfigurationFile( QUEUES_CONFIG_FILE_PATH, new JobQueueInfo[] { queues[0] }); testRefreshFailureWithChangeOfHierarchy(qManager); }