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