View Javadoc

1   /*
2    * $Id: QuartzReceiveAndDispatchJobTestCase.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.assertEquals;
14  import static org.junit.Assert.assertNotNull;
15  
16  import java.util.Arrays;
17  import java.util.Collection;
18  
19  import org.junit.Test;
20  import org.junit.runners.Parameterized.Parameters;
21  import org.mule.module.client.MuleClient;
22  import org.mule.tck.AbstractServiceAndFlowTestCase;
23  import org.mule.tck.functional.CountdownCallback;
24  import org.mule.tck.functional.FunctionalTestComponent;
25  
26  public class QuartzReceiveAndDispatchJobTestCase extends AbstractServiceAndFlowTestCase
27  {
28  
29      public QuartzReceiveAndDispatchJobTestCase(ConfigVariant variant, String configResources)
30      {
31          super(variant, configResources);
32      }
33  
34      @Parameters
35      public static Collection<Object[]> parameters()
36      {
37          return Arrays.asList(new Object[][]{{ConfigVariant.SERVICE, "quartz-receive-dispatch-service.xml"},
38              {ConfigVariant.FLOW, "quartz-receive-dispatch-flow.xml"}});
39      }
40  
41      @Test
42      public void testMuleClientReceiveAndDispatchJob() throws Exception
43      {
44          FunctionalTestComponent component = getFunctionalTestComponent("scheduledService");
45          assertNotNull(component);
46          CountdownCallback count = new CountdownCallback(3);
47          component.setEventCallback(count);
48  
49          MuleClient client = new MuleClient(muleContext);
50          client.dispatch("vm://event.queue", "quartz test", null);
51          client.dispatch("vm://event.queue", "quartz test", null);
52          client.dispatch("vm://event.queue", "quartz test", null);
53  
54          client.dispatch("vm://quartz.scheduler", "test", null);
55          Thread.sleep(5000);
56          assertEquals(0, count.getCount());
57      }
58  }