1   /*
2    * $Id: QuartzReceiverFunctionalTestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
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.providers.quartz;
12  
13  import org.mule.config.ConfigurationBuilder;
14  import org.mule.config.builders.MuleXmlConfigurationBuilder;
15  import org.mule.tck.AbstractMuleTestCase;
16  
17  import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
18  import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
19  
20  public class QuartzReceiverFunctionalTestCase extends AbstractMuleTestCase
21  {
22  
23      public QuartzReceiverFunctionalTestCase()
24      {
25          super();
26          this.setDisposeManagerPerSuite(true);
27      }
28  
29      public void testMuleReceiverJob() throws Exception
30      {
31          CountDownLatch counter = TestComponent.QUARTZ_COUNTER;
32          assertEquals(4, counter.getCount());
33  
34          ConfigurationBuilder configBuilder = new MuleXmlConfigurationBuilder();
35          configBuilder.configure("quartz-receive.xml");
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          if (!counter.await(60, TimeUnit.SECONDS))
41          {
42              fail("CountDown timed out: expected 0, value is: " + counter.getCount());
43          }
44      }
45  
46  }