View Javadoc

1   /*
2    * $Id: MulticastAsyncWithTransformersTestCase.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  import org.mule.tck.testmodels.fruit.Banana;
18  import org.mule.tck.testmodels.fruit.FruitBowl;
19  import org.mule.tck.testmodels.fruit.Orange;
20  
21  import java.util.ArrayList;
22  import java.util.Arrays;
23  import java.util.Collection;
24  import java.util.List;
25  
26  import org.junit.Test;
27  import org.junit.runners.Parameterized.Parameters;
28  
29  import static org.junit.Assert.assertNotNull;
30  import static org.junit.Assert.assertTrue;
31  
32  public class MulticastAsyncWithTransformersTestCase extends AbstractServiceAndFlowTestCase
33  {
34      @Parameters
35      public static Collection<Object[]> parameters()
36      {
37          return Arrays.asList(new Object[][]{
38              {ConfigVariant.SERVICE, "org/mule/test/integration/routing/outbound/multicaster-async-with-transformers-test-service.xml"},
39              {ConfigVariant.FLOW, "org/mule/test/integration/routing/outbound/multicaster-async-with-transformers-test-flow.xml"}
40          });
41      }
42  
43      public MulticastAsyncWithTransformersTestCase(ConfigVariant variant, String configResources)
44      {
45          super(variant, configResources);
46      }
47  
48      @Test
49      public void testSyncMulticast() throws Exception
50      {
51          FruitBowl fruitBowl = new FruitBowl(new Apple(), new Banana());
52          fruitBowl.addFruit(new Orange());
53  
54          MuleClient client = new MuleClient(muleContext);
55          client.dispatch("vm://distributor.queue", fruitBowl, null);
56  
57          List<Object> results = new ArrayList<Object>(3);
58  
59          //We have to wait a lot longer here since groovy takes an age to compile the first time
60          MuleMessage result = client.request("vm://collector.queue", 5000);
61          assertNotNull(result);
62          results.add(result.getPayload());
63  
64          result = client.request("vm://collector.queue", 3000);
65          assertNotNull(result);
66          results.add(result.getPayload());
67  
68          result = client.request("vm://collector.queue", 3000);
69          assertNotNull(result);
70          results.add(result.getPayload());
71  
72          assertTrue(results.contains("Apple Received"));
73          assertTrue(results.contains("Banana Received"));
74          assertTrue(results.contains("Orange Received"));
75      }
76  }