View Javadoc

1   /*
2    * $Id: MulticasterMixedSyncAsyncTestCase.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  
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.assertEquals;
27  import static org.junit.Assert.assertNotNull;
28  import static org.junit.Assert.assertTrue;
29  
30  public class MulticasterMixedSyncAsyncTestCase extends AbstractServiceAndFlowTestCase
31  {
32      @Parameters
33      public static Collection<Object[]> parameters()
34      {
35          return Arrays.asList(new Object[][]{
36              {ConfigVariant.SERVICE, "org/mule/test/integration/routing/outbound/multicaster-mixed-sync-async-test-service.xml"},
37              {ConfigVariant.FLOW, "org/mule/test/integration/routing/outbound/multicaster-mixed-sync-async-test-flow.xml"}
38          });
39      }
40  
41      public MulticasterMixedSyncAsyncTestCase(ConfigVariant variant, String configResources)
42      {
43          super(variant, configResources);
44      }
45  
46      @Test
47      public void testMixedMulticast() throws Exception
48      {
49          MuleClient client = new MuleClient(muleContext);
50          MuleMessage result = client.send("vm://distributor.queue", new Apple(), null);
51  
52          assertNotNull(result);
53          assertTrue(result instanceof MuleMessageCollection);
54          MuleMessageCollection coll = (MuleMessageCollection) result;
55          assertEquals(2, coll.size());
56          List<?> results = (List<?>) coll.getPayload();
57  
58          //ServiceTwo endpoint is async
59          assertTrue(results.contains("Apple Received in ServiceOne"));
60          assertTrue(results.contains("Apple Received in ServiceThree"));
61      }
62  }