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.usecases.routing;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import java.util.ArrayList;
14  import java.util.List;
15  
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertNotNull;
19  import static org.junit.Assert.assertTrue;
20  
21  public class ForwardingMessageSplitterTestCase extends FunctionalTestCase
22  {
23  
24      @Override
25      protected String getConfigResources()
26      {
27          return "org/mule/test/usecases/routing/forwarding-message-splitter.xml";
28      }
29  
30      @Test
31      public void testSyncResponse() throws Exception
32      {
33          MuleClient client = new MuleClient(muleContext);
34  
35          List payload = new ArrayList();
36          payload.add("hello");
37          payload.add(new Integer(3));
38          payload.add(new Exception());
39          client.send("vm://in.queue", payload, null);
40          MuleMessage m = client.request("vm://component.1", 2000);
41          assertNotNull(m);
42          assertTrue(m.getPayload() instanceof String);
43          m = client.request("vm://component.2", 2000);
44          assertNotNull(m);
45          assertTrue(m.getPayload() instanceof Integer);
46  
47          m = client.request("vm://error.queue", 2000);
48          assertNotNull(m);
49          assertTrue(m.getPayload() instanceof Exception);
50      }
51  }