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.outbound;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.tck.testmodels.fruit.Apple;
13  import org.mule.tck.testmodels.fruit.Banana;
14  import org.mule.tck.testmodels.fruit.FruitBowl;
15  import org.mule.tck.testmodels.fruit.Orange;
16  
17  import java.util.ArrayList;
18  import java.util.List;
19  
20  import org.junit.Test;
21  
22  import static org.junit.Assert.assertNotNull;
23  import static org.junit.Assert.assertTrue;
24  
25  public class ExpressionSplitterAsyncTestCase extends FunctionalTestCase
26  {
27  
28      @Override
29      protected String getConfigResources()
30      {
31          return "org/mule/test/integration/routing/outbound/expression-splitter-async-test.xml";
32      }
33  
34      @Test
35      public void testSplitter() throws Exception
36      {
37          FruitBowl fruitBowl = new FruitBowl(new Apple(), new Banana());
38          fruitBowl.addFruit(new Orange());
39  
40          MuleClient client = new MuleClient(muleContext);
41          client.dispatch("vm://distributor.queue", fruitBowl, null);
42  
43          List<Object> results = new ArrayList<Object>(3);
44  
45          MuleMessage result = client.request("vm://collector.queue", 5000);
46          assertNotNull(result);
47          results.add(result.getPayload());
48  
49          result = client.request("vm://collector.queue", 3000);
50          assertNotNull(result);
51          results.add(result.getPayload());
52  
53          result = client.request("vm://collector.queue", 3000);
54          assertNotNull(result);
55          results.add(result.getPayload());
56  
57          assertTrue(results.contains("Apple Received in ServiceOne"));
58          assertTrue(results.contains("Banana Received in ServiceTwo"));
59          assertTrue(results.contains("Orange Received in ServiceThree"));
60      }
61  
62  }