1   /*
2    * $Id: QuartzCustomJobFromMessageTestCase.java 12017 2008-06-12 09:04:04Z rossmason $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.quartz;
12  
13  import org.mule.module.client.MuleClient;
14  import org.mule.tck.FunctionalTestCase;
15  import org.mule.tck.functional.FunctionalTestComponent;
16  import org.mule.tck.functional.CountdownCallback;
17  import org.mule.transport.quartz.QuartzConnector;
18  import org.mule.transport.quartz.jobs.ScheduledDispatchJobConfig;
19  import org.mule.transport.NullPayload;
20  
21  import java.util.HashMap;
22  import java.util.Map;
23  
24  public class QuartzCustomJobFromMessageTestCase extends FunctionalTestCase
25  {
26      protected String getConfigResources()
27      {
28          return "quartz-receive-dispatch-delegating-job.xml";
29      }
30  
31      public void testDelegatingJobAsProperty() throws Exception
32      {
33          FunctionalTestComponent component = (FunctionalTestComponent) getComponent("scheduledService");
34          assertNotNull(component);
35          CountdownCallback count = new CountdownCallback(1);
36          component.setEventCallback(count);
37  
38          MuleClient client = new MuleClient();
39  
40          Map props = new HashMap();
41          ScheduledDispatchJobConfig jobConfig = new ScheduledDispatchJobConfig();
42          jobConfig.setEndpointRef("vm://quartz.in");
43          props.put(QuartzConnector.PROPERTY_JOB_CONFIG, jobConfig);
44  
45          client.send("vm://quartz.scheduler1", NullPayload.getInstance(), props);
46          assertTrue(count.await(7000));
47      }
48  
49      public void testDelegatingJobAsPayload() throws Exception
50      {
51          FunctionalTestComponent component = (FunctionalTestComponent) getComponent("scheduledService");
52          assertNotNull(component);
53          CountdownCallback count = new CountdownCallback(1);
54          component.setEventCallback(count);
55  
56  
57          MuleClient client = new MuleClient();
58  
59          ScheduledDispatchJobConfig jobConfig = new ScheduledDispatchJobConfig();
60          jobConfig.setEndpointRef("vm://quartz.in");
61  
62          client.send("vm://quartz.scheduler2", jobConfig, null);
63          assertTrue(count.await(7000));
64      }
65  
66  }