View Javadoc

1   /*
2    * $Id: MulticastSyncWithTransformersTestCase.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.api.MuleMessageCollection;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.AbstractServiceAndFlowTestCase;
17  import org.mule.tck.testmodels.fruit.Apple;
18  import org.mule.tck.testmodels.fruit.Banana;
19  import org.mule.tck.testmodels.fruit.FruitBowl;
20  import org.mule.tck.testmodels.fruit.Orange;
21  
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.assertEquals;
30  import static org.junit.Assert.assertNotNull;
31  import static org.junit.Assert.assertTrue;
32  
33  public class MulticastSyncWithTransformersTestCase extends AbstractServiceAndFlowTestCase
34  {
35      @Parameters
36      public static Collection<Object[]> parameters()
37      {
38          return Arrays.asList(new Object[][]{
39              {ConfigVariant.SERVICE,
40                  "org/mule/test/integration/routing/outbound/multicaster-sync-with-transformers-test-service.xml"},
41              {ConfigVariant.FLOW,
42                  "org/mule/test/integration/routing/outbound/multicaster-sync-with-transformers-test-flow.xml"}});
43      }
44  
45      public MulticastSyncWithTransformersTestCase(ConfigVariant variant, String configResources)
46      {
47          super(variant, configResources);
48      }
49  
50      @Test
51      public void testSyncMulticast() throws Exception
52      {
53          FruitBowl fruitBowl = new FruitBowl(new Apple(), new Banana());
54          fruitBowl.addFruit(new Orange());
55  
56          MuleClient client = new MuleClient(muleContext);
57          MuleMessage result = client.send("vm://distributor.queue", fruitBowl, null);
58  
59          assertNotNull(result);
60          assertTrue(result instanceof MuleMessageCollection);
61          MuleMessageCollection coll = (MuleMessageCollection) result;
62          assertEquals(3, coll.size());
63          List<?> results = (List<?>) coll.getPayload();
64  
65          assertTrue(results.contains("Apple Received"));
66          assertTrue(results.contains("Banana Received"));
67          assertTrue(results.contains("Orange Received"));
68      }
69  }