View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
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 org.junit.Test;
15  
16  import static org.junit.Assert.assertEquals;
17  import static org.junit.Assert.assertNotNull;
18  
19  public class QuartzReceiveAndDispatchJobTestCase extends FunctionalTestCase
20  {
21  
22      @Override
23      protected String getConfigResources()
24      {
25          return "quartz-receive-dispatch.xml";
26      }
27  
28      @Test
29      public void testMuleClientReceiveAndDispatchJob() throws Exception
30      {
31          FunctionalTestComponent component = getFunctionalTestComponent("scheduledService");
32          assertNotNull(component);
33          CountdownCallback count = new CountdownCallback(3);
34          component.setEventCallback(count);
35  
36          MuleClient client = new MuleClient(muleContext);
37          client.dispatch("vm://event.queue", "quartz test", null);
38          client.dispatch("vm://event.queue", "quartz test", null);
39          client.dispatch("vm://event.queue", "quartz test", null);
40  
41          client.dispatch("vm://quartz.scheduler", "test", null);
42          Thread.sleep(5000);
43          assertEquals(0, count.getCount());
44      }
45  }