1 4 package org.oddjob.monitor.action; 5 6 import junit.framework.TestCase; 7 8 import org.oddjob.monitor.model.ExplorerContext; 9 import org.oddjob.monitor.model.ExplorerModel; 10 import org.oddjob.scheduling.OddjobScheduler; 11 import org.oddjob.scheduling.ScheduleInstruction; 12 import org.oddjob.scheduling.ScheduleSummary; 13 14 public class SchedulerMenuTest extends TestCase { 15 16 public void testNoSchedulers() { 17 Object root = new Object (); 18 ExplorerModel em = new ExplorerModel(); 19 em.setRoot(root); 20 ExplorerContext parentContext = new ExplorerContext(em); 21 22 Object job = new Object (); 23 ExplorerContext ec = new ExplorerContext( 24 job, parentContext); 25 26 SchedulerMenu test = new SchedulerMenu(); 27 assertFalse(test.enabled()); 28 29 test.select(job, ec); 30 31 assertTrue(test.enabled()); 32 assertEquals(1, test.options().length); 33 } 34 35 public void testWithSchedulers() { 36 class MySched implements OddjobScheduler { 37 String name; 38 MySched(String name) { 39 this.name = name; 40 } 41 public boolean canSchedule(Object component) { 42 return true; 43 } 44 public ScheduleSummary[] summariesFor(Object object) { 45 return null; 46 } 47 public void schedule(ScheduleInstruction scheduleInstruction) { 48 } 49 public void unSchedule(String id) { 50 } 51 public String toString() { 52 return name; 53 } 54 55 } 56 57 MySched sched1 = new MySched("Scheduler 1"); 58 MySched sched2 = new MySched("Scheduler 2"); 59 60 Object job = new Object (); 61 ExplorerModel em = new ExplorerModel(); 62 em.setRoot(job); 63 64 ExplorerContext ec = new ExplorerContext(em); 65 ec.getSchedulerTraker().addScheduler(sched1); 66 ec.getSchedulerTraker().addScheduler(sched2); 67 68 SchedulerMenu test = new SchedulerMenu(); 69 assertFalse(test.enabled()); 70 71 test.select(em, ec); 72 73 assertTrue(test.enabled()); 74 assertEquals(2, test.options().length); 75 } 76 77 } 78 | Popular Tags |