JunitTest.java 948 B

123456789101112131415161718192021222324252627282930
  1. package quartz;
  2. import java.lang.reflect.InvocationTargetException;
  3. import java.util.concurrent.TimeUnit;
  4. import org.junit.Test;
  5. import org.junit.runner.RunWith;
  6. import org.quartz.SchedulerException;
  7. import org.springframework.test.context.ContextConfiguration;
  8. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  9. import com.xxl.quartz.DynamicSchedulerUtil;
  10. import com.xxl.quartz.JobModel;
  11. @RunWith(SpringJUnit4ClassRunner.class)
  12. @ContextConfiguration(locations = "classpath*:applicationcontext-*.xml")
  13. public class JunitTest {
  14. @Test
  15. public void addJob() throws SchedulerException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InterruptedException {
  16. boolean ret = DynamicSchedulerUtil.addJob(new JobModel("Jost-job", "0/1 * * * * ?", TestDynamicJob.class));
  17. System.out.println(ret);
  18. TimeUnit.SECONDS.sleep(30);
  19. }
  20. }