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