View Javadoc

1   /*
2    * $Id: PollingEtagTestCase.java 22552 2011-07-25 07:18:19Z claude.mamo $
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 static org.junit.Assert.assertEquals;
13  import static org.junit.Assert.assertTrue;
14  
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  import org.mule.tck.functional.CounterCallback;
17  import org.mule.tck.functional.FunctionalTestComponent;
18  import org.mule.tck.junit4.rule.DynamicPort;
19  
20  import java.util.Arrays;
21  import java.util.Collection;
22  import java.util.concurrent.atomic.AtomicInteger;
23  
24  import org.junit.Rule;
25  import org.junit.Test;
26  import org.junit.runners.Parameterized.Parameters;
27  
28  public class PollingEtagTestCase extends AbstractServiceAndFlowTestCase
29  {
30      private static final int WAIT_TIME = 2500;
31  
32      @Rule
33      public DynamicPort dynamicPort = new DynamicPort("port1");
34  
35      @Test
36      public void testPollingReceiversRestart() throws Exception
37      {
38          Object ftc = getComponent("Test");
39          assertTrue("FunctionalTestComponent expected", ftc instanceof FunctionalTestComponent);
40  
41          AtomicInteger pollCounter = new AtomicInteger(0);
42          ((FunctionalTestComponent) ftc).setEventCallback(new CounterCallback(pollCounter));
43  
44          // should be enough to poll for multiple messages
45          Thread.sleep(WAIT_TIME);
46  
47          assertEquals(1, pollCounter.get());
48      }
49  
50      public PollingEtagTestCase(ConfigVariant variant, String configResources)
51      {
52          super(variant, configResources);
53      }
54  
55      @Parameters
56      public static Collection<Object[]> parameters()
57      {
58          return Arrays.asList(new Object[][]{
59              {ConfigVariant.SERVICE, "polling-etag-test-service.xml"},
60              {ConfigVariant.FLOW, "polling-etag-test-flow.xml"}
61          });
62      }      
63      
64  }
65