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.api.MuleMessageCollection;
11  import org.mule.module.client.MuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  import org.mule.tck.testmodels.fruit.Apple;
14  
15  import java.util.List;
16  
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertEquals;
20  import static org.junit.Assert.assertNotNull;
21  import static org.junit.Assert.assertTrue;
22  
23  public class MulticasterMixedSyncAsyncTestCase extends FunctionalTestCase
24  {
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "org/mule/test/integration/routing/outbound/multicaster-mixed-sync-async-test.xml";
30      }
31  
32      @Test
33      public void testMixedMulticast() throws Exception
34      {
35          MuleClient client = new MuleClient(muleContext);
36          MuleMessage result = client.send("vm://distributor.queue", new Apple(), null);
37  
38          assertNotNull(result);
39          assertTrue(result instanceof MuleMessageCollection);
40          MuleMessageCollection coll = (MuleMessageCollection) result;
41          assertEquals(2, coll.size());
42          List<?> results = (List<?>) coll.getPayload();
43  
44          //ServiceTwo endpoint is async
45          assertTrue(results.contains("Apple Received in ServiceOne"));
46          assertTrue(results.contains("Apple Received in ServiceThree"));
47      }
48  }