1
2
3
4
5
6
7 package org.mule.transport.quartz;
8
9 import org.mule.module.client.MuleClient;
10 import org.mule.tck.functional.CountdownCallback;
11 import org.mule.tck.functional.FunctionalTestComponent;
12 import org.mule.tck.junit4.FunctionalTestCase;
13
14 import java.util.HashMap;
15 import java.util.Map;
16
17 import org.junit.Test;
18
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertTrue;
21
22 public class QuartzDispatchJobTestCase extends FunctionalTestCase
23 {
24
25 @Override
26 protected String getConfigResources()
27 {
28 return "quartz-dispatch.xml";
29 }
30
31 @Test
32 public void testMuleClientDispatchJob() throws Exception
33 {
34 FunctionalTestComponent component = getFunctionalTestComponent("scheduledService");
35 assertNotNull(component);
36 CountdownCallback count = new CountdownCallback(3);
37 component.setEventCallback(count);
38
39 new MuleClient(muleContext).dispatch("vm://quartz.scheduler", "quartz test", null);
40 assertTrue(count.await(5000));
41 }
42
43 @Test
44 public void testMuleClientDispatchJobWithExpressionAddress() throws Exception
45 {
46 FunctionalTestComponent component = getFunctionalTestComponent("expressionScheduledService");
47 assertNotNull(component);
48 CountdownCallback count = new CountdownCallback(3);
49 component.setEventCallback(count);
50
51 Map<String,String> props = new HashMap<String,String>();
52 props.put("ENDPOINT_NAME", "quartz.expression.in");
53
54 new MuleClient(muleContext).dispatch("vm://quartz.expression.scheduler", "quartz test", props);
55 assertTrue(count.await(5000));
56 }
57 }