View Javadoc

1   /*
2    * $Id: PollingEtagTestCase.java 19817 2010-10-04 18:10:39Z dzapata $
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  package org.mule.transport.http.functional;
11  
12  import org.mule.tck.DynamicPortTestCase;
13  import org.mule.tck.FunctionalTestCase;
14  import org.mule.tck.functional.CounterCallback;
15  import org.mule.tck.functional.FunctionalTestComponent;
16  
17  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
18  
19  public class PollingEtagTestCase extends DynamicPortTestCase
20  {
21      private static final int WAIT_TIME = 2500;
22  
23      protected String getConfigResources()
24      {
25          return "polling-etag-test.xml";
26      }
27  
28      public void testPollingReceiversRestart() throws Exception
29      {
30          Object ftc = getComponent("Test");
31          assertTrue("FunctionalTestComponent expected", ftc instanceof FunctionalTestComponent);
32  
33          AtomicInteger pollCounter = new AtomicInteger(0);
34          ((FunctionalTestComponent) ftc).setEventCallback(new CounterCallback(pollCounter));
35  
36          // should be enough to poll for multiple messages
37          Thread.sleep(WAIT_TIME);
38  
39          assertEquals(1, pollCounter.get());
40      }
41  
42      @Override
43      protected int getNumPortsToFind()
44      {
45          return 1;
46      }
47  }
48