View Javadoc

1   /*
2    * $Id: MulticasterAsyncTestCase.java 22422 2011-07-15 08:22:16Z dirk.olmes $
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.outbound;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  import org.mule.tck.testmodels.fruit.Apple;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.Collection;
21  import java.util.List;
22  
23  import org.junit.Test;
24  import org.junit.runners.Parameterized.Parameters;
25  
26  import static org.junit.Assert.assertNotNull;
27  import static org.junit.Assert.assertTrue;
28  
29  public class MulticasterAsyncTestCase extends AbstractServiceAndFlowTestCase
30  {
31      @Parameters
32      public static Collection<Object[]> parameters()
33      {
34          return Arrays.asList(new Object[][]{
35              {ConfigVariant.SERVICE, "org/mule/test/integration/routing/outbound/multicaster-async-test-service.xml"},
36              {ConfigVariant.FLOW, "org/mule/test/integration/routing/outbound/multicaster-async-test-flow.xml"}
37          });
38      }
39  
40      public MulticasterAsyncTestCase(ConfigVariant variant, String configResources)
41      {
42          super(variant, configResources);
43      }
44  
45      @Test
46      public void testSplitter() throws Exception
47      {
48          MuleClient client = new MuleClient(muleContext);
49          client.dispatch("vm://distributor.queue", new Apple(), null);
50  
51          List<Object> results = new ArrayList<Object>(3);
52  
53          MuleMessage result = client.request("vm://collector.queue", 5000);
54          assertNotNull(result);
55          results.add(result.getPayload());
56  
57          result = client.request("vm://collector.queue", 3000);
58          assertNotNull(result);
59          results.add(result.getPayload());
60  
61          result = client.request("vm://collector.queue", 3000);
62          assertNotNull(result);
63          results.add(result.getPayload());
64  
65          assertTrue(results.contains("Apple Received in ServiceOne"));
66          assertTrue(results.contains("Apple Received in ServiceTwo"));
67          assertTrue(results.contains("Apple Received in ServiceThree"));
68      }
69  
70  }