KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > schedules > regression > ScheduleTester


1 package org.oddjob.schedules.regression;
2
3 import java.io.InputStream JavaDoc;
4 import java.util.TimeZone JavaDoc;
5
6 import junit.framework.Test;
7 import junit.framework.TestResult;
8 import junit.framework.TestSuite;
9
10 import org.oddjob.arooa.ArooaFactory;
11 import org.oddjob.arooa.PropertyProxyResolver;
12 import org.oddjob.schedules.Schedule;
13 import org.oddjob.schedules.ScheduleElement;
14
15 /**
16  *
17  */

18 public class ScheduleTester
19 implements Test {
20
21     protected TestSuite suite;
22     protected int count = 0;
23     private TimeZone JavaDoc tz;
24     
25     public void addConfiguredTest(SingleTestSchedule test ) {
26         suite.addTest(test);
27         ++count;
28     }
29     
30     public ScheduleTester(String JavaDoc configFile)
31     throws Exception JavaDoc {
32         this(configFile, null);
33     }
34     
35     public ScheduleTester(String JavaDoc configFile, TimeZone JavaDoc timeZone)
36     throws Exception JavaDoc {
37         this.tz = timeZone;
38         
39         suite = new TestSuite("Test for " + configFile);
40         
41         InputStream JavaDoc in = this.getClass().getResourceAsStream(configFile);
42
43         PropertyProxyResolver ppr = new PropertyProxyResolver();
44         ppr.setProxy(Schedule.class.getName(), ScheduleElement.class.getName());
45         
46         ArooaFactory af = new ArooaFactory();
47         af.setPropertProxyResolver(ppr);
48         af.setObjectToConfigure(this);
49         af.setDocumentTag("schedule-tester");
50         af.build(in);
51     }
52
53     public int countTestCases() {
54         return count;
55     }
56     
57     public void run(TestResult result) {
58         TimeZone.setDefault(tz);
59         suite.run(result);
60     }
61     
62     
63     public static void main(String JavaDoc args[]) {
64         try {
65             ScheduleTester test = new ScheduleTester("daily_schedule_test.xml");
66             test.run(new TestResult());
67         } catch (Exception JavaDoc e) {
68             e.printStackTrace();
69         }
70     }
71     
72     public String JavaDoc toString() {
73         return suite.getName();
74     }
75 }
76
Popular Tags