View Javadoc

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