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.MuleMessage;
10  import org.mule.api.MuleMessageCollection;
11  import org.mule.module.client.MuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  
14  import java.util.List;
15  
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertNotNull;
20  import static org.junit.Assert.assertTrue;
21  
22  public class InboundAggregationNoTimeoutTestCase extends FunctionalTestCase
23  {
24  
25      @Override
26      protected String getConfigResources()
27      {
28          return "org/mule/test/integration/routing/multi-inbound-aggregator-no-timeout.xml";
29      }
30  
31      @Test
32      public void testAggregatorWithNoTimeout() throws Exception
33      {
34          String message = "test";
35          MuleClient client = new MuleClient(muleContext);
36          client.dispatch("vm://distributor.queue", message, null);
37  
38          MuleMessage result = client.request("vm://results", 10000);
39  
40          assertNotNull(result);
41          assertTrue(result instanceof MuleMessageCollection);
42          MuleMessageCollection mc = (MuleMessageCollection)result;
43          assertEquals(3, mc.size());
44          for (int i = 0; i < mc.getMessagesAsArray().length; i++)
45          {
46              MuleMessage msg = mc.getMessagesAsArray()[i];
47              assertEquals("test Received", msg.getPayload());
48          }
49      }
50  
51      public static class TestCollectionService
52      {
53          public Object process(List responseMessages)
54          {
55              assertEquals(3, responseMessages.size());
56              return responseMessages;
57          }
58      }
59  }