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.tck.functional.CountdownCallback;
10  import org.mule.tck.functional.FunctionalTestComponent;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.junit.Test;
14  
15  import static org.junit.Assert.assertNotNull;
16  import static org.junit.Assert.assertTrue;
17  
18  public class QuartzFunctionalTestCase extends FunctionalTestCase
19  {
20  
21      @Override
22      protected String getConfigResources()
23      {
24          return "quartz-functional-test.xml";
25      }
26  
27      @Test
28      public void testMuleReceiverJob() throws Exception
29      {
30          FunctionalTestComponent component = (FunctionalTestComponent) getComponent("quartzService1");
31          assertNotNull(component);
32          CountdownCallback count1 = new CountdownCallback(4);
33          component.setEventCallback(count1);
34  
35          component = (FunctionalTestComponent) getComponent("quartzService2");
36          assertNotNull(component);
37          CountdownCallback count2 = new CountdownCallback(2);
38          component.setEventCallback(count2);
39  
40          // we wait up to 60 seconds here which is WAY too long for three ticks with 1
41          // second interval, but it seems that "sometimes" it takes a very long time
42          // for Quartz go kick in. Once it starts ticking everything is fine.
43          assertTrue("Count 1 timed out: expected 0, value is: " + count1.getCount(), count1.await(60000));
44          assertTrue("Count 2 timed out: expected 0, value is: " + count2.getCount(), count2.await(5000));
45      }
46  
47  }