1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.routing;
12
13 import org.mule.api.context.notification.RoutingNotificationListener;
14 import org.mule.context.notification.RoutingNotification;
15 import org.mule.routing.correlation.CorrelationTimeoutException;
16 import org.mule.tck.junit4.FunctionalTestCase;
17 import org.mule.util.ExceptionUtils;
18
19 import java.util.concurrent.CountDownLatch;
20 import java.util.concurrent.TimeUnit;
21 import org.junit.Test;
22
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertTrue;
25
26 public class AsyncReplyTimeoutFailTestCase extends FunctionalTestCase
27 {
28
29 private CountDownLatch latch;
30
31 @Override
32 protected String getConfigResources()
33 {
34 return "org/mule/test/integration/routing/multi-async-repy-timeout-fail.xml";
35 }
36
37 @Test
38 public void testAggregatorTimeoutWithFailure() throws Exception
39 {
40 latch = new CountDownLatch(1);
41
42 muleContext.registerListener(new RoutingNotificationListener<RoutingNotification>() {
43 public void onNotification(RoutingNotification notification)
44 {
45 if (notification.getAction() == RoutingNotification.CORRELATION_TIMEOUT)
46 {
47 latch.countDown();
48 }
49 }
50 });
51
52 String message = "test";
53 try
54 {
55 muleContext.getClient().send("vm://distributor.queue", message, null);
56 }
57 catch (Exception e)
58 {
59 assertTrue(ExceptionUtils.getRootCause(e) instanceof CorrelationTimeoutException);
60 }
61
62 assertTrue(latch.await(3000, TimeUnit.MILLISECONDS));
63 }
64 }