1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.quartz;
12
13 import org.mule.tck.FunctionalTestCase;
14
15 import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
16 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
17
18 import org.quartz.JobExecutionContext;
19 import org.quartz.JobExecutionException;
20 import org.quartz.StatefulJob;
21
22 public class QuartzCustomStatefulJobTestCase extends FunctionalTestCase
23 {
24 @Override
25 protected String getConfigResources()
26 {
27 return "quartz-custom-stateful-job.xml";
28 }
29
30 public void testCustomStatefulJob() throws Exception
31 {
32 CountDownLatch eventLatch = (CountDownLatch) muleContext.getRegistry().lookupObject("latch");
33
34
35
36
37 assertTrue(eventLatch.await(60000, TimeUnit.MILLISECONDS));
38 }
39
40 public static class MyStatefulJob implements StatefulJob
41 {
42 private CountDownLatch latch;
43
44 public MyStatefulJob(CountDownLatch latch)
45 {
46 super();
47 this.latch = latch;
48 }
49
50 public void execute(JobExecutionContext context) throws JobExecutionException
51 {
52 assertTrue(context.getJobDetail().isStateful());
53 latch.countDown();
54 }
55 }
56 }