title: why quartz example code can't be tested in Junit?
body: <p>I am running this <code>quartz-2.1.0\examples\src\main\java\org\quartz\examples\example3</code> sample code, it runs very well, but if I move the <code>main</code> code in <code>CronTriggerExample.java</code> to a junit test class, the job doesn't run.
  the following are quartz example code(I truncate them for simplification, you can get full code from quartz website).</p>
  
  <p><strong>SimpleJob.java:</strong></p>
  
  <pre><code>public class SimpleJob implements Job {
    private static Logger _log = LoggerFactory.getLogger(SimpleJob.class);
  
    public void execute(JobExecutionContext context) throws JobExecutionException {
      JobKey jobKey = context.getJobDetail().getKey();
      _log.info("SimpleJob says: " + jobKey + " executing at " + new Date());
    }
  }
  </code></pre>
  
  <p><strong>CronTriggerExample.java:</strong></p>
  
  <pre><code>public class CronTriggerExample {
      public void run() throws Exception {
          Logger log = LoggerFactory.getLogger(CronTriggerExample.class);
          SchedulerFactory sf = new StdSchedulerFactory();
          Scheduler sched = sf.getScheduler();
          JobDetail job = newJob(SimpleJob.class)
              .withIdentity("job1", "group1")
              .build();
          CronTrigger trigger = newTrigger()
              .withIdentity("trigger1", "group1")
              .withSchedule(cronSchedule("0/3 * * * * ?"))
              .build();
  
          Date ft = sched.scheduleJob(job, trigger);
          log.info(job.getKey() + " has been scheduled to run at: " + ft
              + " and repeat based on expression: "
              + trigger.getCronExpression());
  
          sched.start();
      }
  
      public static void main(String[] args) throws Exception {
          CronTriggerExample example = new CronTriggerExample();
          example.run();
      }
  }
  </code></pre>
  
  <p>the code above runs well, if I move the two lines code in <code>main</code> method to a junit test class(junit4), like this:</p>
  
  <pre><code>public class Test1 {
      @Test
      public void run() throws Exception {
          CronTriggerExample example = new CronTriggerExample();
          example.run();
      }
  }
  </code></pre>
  
  <p>the job doesn't run.</p>
  
  <p>I am very confused why the same code can't run in junit?</p>