KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > monitor > action > ScheduleMenuTest


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.monitor.action;
5
6 import junit.framework.TestCase;
7
8 import org.apache.log4j.Logger;
9 import org.oddjob.monitor.model.ExplorerContext;
10 import org.oddjob.monitor.model.ExplorerModel;
11 import org.oddjob.scheduling.OddjobScheduler;
12 import org.oddjob.scheduling.ScheduleInstruction;
13 import org.oddjob.scheduling.ScheduleSummary;
14
15 public class ScheduleMenuTest extends TestCase {
16     private static final Logger logger = Logger.getLogger(ScheduleMenuTest.class);
17
18     public void test1() {
19         
20         class MySched implements OddjobScheduler {
21             String JavaDoc name;
22             MySched(String JavaDoc name) {
23                 this.name = name;
24             }
25             public boolean canSchedule(Object JavaDoc component) {
26                 return true;
27             }
28             public ScheduleSummary[] summariesFor(Object JavaDoc object) {
29                 return null;
30             }
31             public void schedule(ScheduleInstruction scheduleInstruction) {
32             }
33             public void unSchedule(String JavaDoc id) {
34             }
35             public String JavaDoc toString() {
36                 return name;
37             }
38             
39         }
40     
41         MySched sched1 = new MySched("Scheduler 1");
42
43         Object JavaDoc job = new Object JavaDoc();
44         
45         ExplorerModel em = new ExplorerModel();
46         em.setRoot(job);
47         ExplorerContext ec = new ExplorerContext(em);
48         
49         ScheduleMenu test = new ScheduleMenu(sched1);
50         assertFalse(test.enabled());
51         
52         test.select(job, ec);
53         
54         assertTrue(test.enabled());
55         assertEquals(3, test.options().length);
56         
57         logger.debug(test.options()[0].getName());
58     }
59
60 }
61
Popular Tags