1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.work;
12
13 import org.mule.api.MuleEventContext;
14 import org.mule.api.service.Service;
15 import org.mule.tck.FunctionalTestCase;
16 import org.mule.tck.functional.EventCallback;
17 import org.mule.tck.functional.FunctionalTestComponent;
18 import org.mule.util.concurrent.Latch;
19
20 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
21
22 public class GracefulShutdownTimeoutTestCase extends FunctionalTestCase
23 {
24
25 @Override
26 protected String getConfigResources()
27 {
28 return "org/mule/test/integration/work/graceful-shutdown-timeout.xml";
29 }
30
31 @Override
32 protected boolean isGracefulShutdown()
33 {
34 return true;
35 }
36
37
38
39
40
41
42
43
44
45
46 public void testGracefulShutdownTimeout() throws Exception
47 {
48 final Latch latch = new Latch();
49 Service service = muleContext.getRegistry().lookupService("TestService");
50 FunctionalTestComponent testComponent = (FunctionalTestComponent) getComponent(service);
51 testComponent.setEventCallback(new EventCallback()
52 {
53
54 public void eventReceived(MuleEventContext context, Object component) throws Exception
55 {
56 Thread.sleep(5500);
57 latch.countDown();
58
59 }
60 });
61 service.dispatchEvent(getTestInboundEvent("test"));
62 Thread.sleep(200);
63 service.dispose();
64 assertTrue(latch.await(1000, TimeUnit.MILLISECONDS));
65 }
66
67 }