1 16 package org.quartz.impl; 17 18 import java.util.Collections ; 19 20 import junit.framework.TestCase; 21 22 import org.quartz.Scheduler; 23 import org.quartz.simpl.RAMJobStore; 24 import org.quartz.simpl.SimpleThreadPool; 25 import org.quartz.spi.SchedulerPlugin; 26 import org.quartz.spi.ThreadPool; 27 28 public class DirectSchedulerFactoryTest extends TestCase { 29 public void testPlugins() throws Exception { 30 final StringBuffer result = new StringBuffer (); 31 32 SchedulerPlugin testPlugin = new SchedulerPlugin() { 33 public void initialize(String name, org.quartz.Scheduler scheduler) throws org.quartz.SchedulerException { 34 result.append(name).append("|").append(scheduler.getSchedulerName()); 35 }; 36 public void start() { 37 result.append("|start"); 38 }; 39 public void shutdown() { 40 result.append("|shutdown"); 41 }; 42 }; 43 44 ThreadPool threadPool = new SimpleThreadPool(1, 5); 45 threadPool.initialize(); 46 DirectSchedulerFactory.getInstance().createScheduler( 47 "MyScheduler", "Instance1", threadPool, 48 new RAMJobStore(), Collections.singletonMap("TestPlugin", testPlugin), 49 null, -1, 0, 0); 50 51 Scheduler scheduler = DirectSchedulerFactory.getInstance().getScheduler("MyScheduler"); 52 scheduler.start(); 53 scheduler.shutdown(); 54 55 assertEquals("TestPlugin|MyScheduler|start|shutdown", result.toString()); 56 } 57 } 58 | Popular Tags |