1 18 package org.apache.batik.test; 19 20 import java.util.Iterator ; 21 import java.util.Vector ; 22 23 29 public class DefaultTestSuite extends AbstractTest implements TestSuite { 30 33 private String name = null; 34 35 38 protected Vector tests = new Vector (); 39 40 43 public void addTest(Test test){ 44 if(test == null){ 45 throw new IllegalArgumentException (); 46 } 47 48 test.setParent(this); 49 tests.addElement(test); 50 } 51 52 55 public void removeTest(Test test){ 56 tests.remove(test); 57 } 58 59 62 public TestReport runImpl(){ 63 Iterator iter = tests.iterator(); 64 65 DefaultTestSuiteReport report 66 = new DefaultTestSuiteReport(this); 67 68 while(iter.hasNext()){ 69 Test t = (Test)iter.next(); 70 System.err.println("Running " + t.getName()); 71 TestReport tr = t.run(); 72 if (tr == null){ 73 System.out.println("ERROR" + t.getId() + " returned a null report"); 74 } 75 report.addReport(tr); 76 } 77 78 return report; 79 } 80 81 public String getName(){ 82 if(name != null){ 83 return name; 84 } 85 86 String id = getId(); 87 if(id != null && !"".equals(id)){ 88 return id; 89 } 90 91 return this.getClass().getName(); 92 } 93 94 public void setName(String name){ 95 if(name == null && !"".equals(name)){ 96 throw new IllegalArgumentException (); 97 } 98 99 this.name = name; 100 } 101 102 public Test[] getChildrenTests(){ 103 Test[] children = new Test[tests.size()]; 104 tests.copyInto(children); 105 return children; 106 } 107 108 111 public int getChildrenCount(){ 112 return tests.size(); 113 } 114 115 } 116 | Popular Tags |