1
2
3
4
5
6
7
8
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 PollingReceiversRestartTestCase extends DynamicPortTestCase
19 {
20 private static final int WAIT_TIME = 3000;
21
22 public PollingReceiversRestartTestCase()
23 {
24 setStartContext(false);
25 }
26
27 @Override
28 protected String getConfigResources()
29 {
30 return "polling-receivers-restart-test.xml";
31 }
32
33 public void testPollingReceiversRestart() throws Exception
34 {
35 muleContext.start();
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
44 Thread.sleep(WAIT_TIME);
45
46
47 muleContext.stop();
48 assertTrue("No polls performed", pollCounter.get() > 0);
49
50
51 muleContext.start();
52
53 pollCounter.set(0);
54 ((FunctionalTestComponent) ftc).setEventCallback(new CounterCallback(pollCounter));
55
56 Thread.sleep(WAIT_TIME);
57 muleContext.dispose();
58 assertTrue("No polls performed", pollCounter.get() > 0);
59 }
60
61 @Override
62 protected int getNumPortsToFind()
63 {
64 return 1;
65 }
66 }