1   /*
2    * $Id: InboundAggregationWithTimeoutTestCase.java 11567 2008-04-11 13:08:05Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.api.context.notification.ServerNotification;
15  import org.mule.context.notification.RoutingNotification;
16  import org.mule.module.client.MuleClient;
17  import org.mule.tck.FunctionalTestCase;
18  
19  import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
20  import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
21  
22  public class InboundAggregationWithTimeoutTestCase extends FunctionalTestCase
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() {
34              public void onNotification(ServerNotification notification)
35              {
36                  if(notification.getAction() == RoutingNotification.CORRELATION_TIMEOUT)
37                  {
38                      latch.countDown();
39                  }
40              }
41          });
42  
43          String message = "test";
44          MuleClient client = new MuleClient();
45           client.dispatch("vm://distributor.queue", message, null);
46  
47          assertTrue(latch.await(3000, TimeUnit.MILLISECONDS));
48      }
49  }