View Javadoc

1   /*
2    * $Id: QuartzDispatchJobTestCase.java 22498 2011-07-21 13:01:39Z justin.calleja $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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 static org.junit.Assert.assertNotNull;
14  import static org.junit.Assert.assertTrue;
15  
16  import java.util.Arrays;
17  import java.util.Collection;
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.junit.Test;
22  import org.junit.runners.Parameterized.Parameters;
23  import org.mule.module.client.MuleClient;
24  import org.mule.tck.AbstractServiceAndFlowTestCase;
25  import org.mule.tck.functional.CountdownCallback;
26  import org.mule.tck.functional.FunctionalTestComponent;
27  
28  public class QuartzDispatchJobTestCase extends AbstractServiceAndFlowTestCase
29  {
30  
31      public QuartzDispatchJobTestCase(ConfigVariant variant, String configResources)
32      {
33          super(variant, configResources);
34      }
35  
36      @Parameters
37      public static Collection<Object[]> parameters()
38      {
39          return Arrays.asList(new Object[][]{
40              {ConfigVariant.SERVICE, "quartz-dispatch-service.xml"},
41              {ConfigVariant.FLOW, "quartz-dispatch-flow.xml"}
42          });
43      }
44  
45      @Test
46      public void testMuleClientDispatchJob() throws Exception
47      {
48          FunctionalTestComponent component = getFunctionalTestComponent("scheduledService");
49          assertNotNull(component);
50          CountdownCallback count = new CountdownCallback(3);
51          component.setEventCallback(count);
52  
53          new MuleClient(muleContext).dispatch("vm://quartz.scheduler", "quartz test", null);
54          assertTrue(count.await(5000));
55      }
56  
57      @Test
58      public void testMuleClientDispatchJobWithExpressionAddress() throws Exception
59      {
60          FunctionalTestComponent component = getFunctionalTestComponent("expressionScheduledService");
61          assertNotNull(component);
62          CountdownCallback count = new CountdownCallback(3);
63          component.setEventCallback(count);
64  
65          Map<String,String> props = new HashMap<String,String>();
66          props.put("ENDPOINT_NAME", "quartz.expression.in");
67  
68          new MuleClient(muleContext).dispatch("vm://quartz.expression.scheduler", "quartz test", props);
69          assertTrue(count.await(5000));
70      }
71  }