View Javadoc

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