1 2 3 package org.quilt.frontend.ant; 4 5 import java.util.Vector ; 6 7 import org.apache.tools.ant.Project; 8 import org.apache.tools.ant.Task; 9 import org.quilt.framework.QuiltTest; 10 11 16 public class Scheduler { 17 18 private QuiltTask task = null; 19 private TaskControl tc = null; 20 private boolean batched = true; 21 22 23 private Vector tests = new Vector (); 24 25 private int testIndex = 0; 26 27 28 private Vector batchTests = new Vector (); 29 30 private int batchIndex = 0; 31 32 33 private QuiltTest modelTest = new QuiltTest(); 34 35 36 public Scheduler ( QuiltTask t) { 37 task = t; 38 tc = new TaskControl (task); 39 } 40 41 51 public void addBatchTest (BatchTest bt) { 52 task.log("--> Scheduler.addBatchTest", Project.MSG_VERBOSE); 53 batchTests.addElement(bt); 54 } 55 63 public void addTest (QuiltTest test) { 64 task.log("--> Scheduler.addTest", Project.MSG_VERBOSE); 65 tests.addElement (test); 66 } 67 72 public void schedule () { 73 testIndex = 0; 74 batchIndex = 0; 75 76 task.log ( 77 "\n===========================================================\n" 78 + "--> Scheduler.schedule: there are " 79 + tests.size() + " tests and " 80 + batchTests.size() + " batch tests" 81 + "\n===========================================================\n", 82 Project.MSG_DEBUG 83 ); 84 } 85 90 public QuiltTest nextTest() { 91 if (testIndex < tests.size()) { 92 return (QuiltTest) tests.elementAt( testIndex++ ); 93 } else if (batchIndex < batchTests.size()) { 94 return (BatchTest) batchTests.elementAt( batchIndex++ ); 95 } else { 96 return null; 97 } 98 } 99 103 public void unbatch() { 104 task.log("--> Scheduler.unbatch", Project.MSG_VERBOSE); 105 for (int i = 0; i < batchTests.size(); i++) { 106 ((BatchTest)batchTests.elementAt(i)).unbatch(this); 107 } 108 batched = false; 109 batchTests = new Vector (); 110 } 111 112 117 public TaskControl getTaskControl() { 118 return tc; 119 } 120 } 121 | Popular Tags |