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.test.integration.routing;
8   
9   import org.mule.api.context.notification.RoutingNotificationListener;
10  import org.mule.context.notification.RoutingNotification;
11  import org.mule.module.client.MuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  
14  import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
15  import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertTrue;
19  
20  public class InboundAggregationWithTimeoutTestCase extends FunctionalTestCase
21  {
22  
23      @Override
24      protected String getConfigResources()
25      {
26          return "org/mule/test/integration/routing/multi-inbound-aggregator-with-timeout.xml";
27      }
28  
29      @Test
30      public void testAggregatorTimeout() throws Exception
31      {
32          final CountDownLatch latch = new CountDownLatch(1);
33  
34          muleContext.registerListener(new RoutingNotificationListener<RoutingNotification>()
35          {
36              public void onNotification(RoutingNotification notification)
37              {
38                  if (notification.getAction() == RoutingNotification.CORRELATION_TIMEOUT)
39                  {
40                      latch.countDown();
41                  }
42              }
43          });
44  
45          String message = "test";
46          MuleClient client = new MuleClient(muleContext);
47          client.dispatch("vm://distributor.queue", message, null);
48  
49          assertTrue(latch.await(5000, TimeUnit.MILLISECONDS));
50      }
51  }