View Javadoc

1   /*
2    * $Id: ForwardingMessageSplitterTestCase.java 22431 2011-07-18 07:40:35Z 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.usecases.routing;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  
17  import java.util.ArrayList;
18  import java.util.Arrays;
19  import java.util.Collection;
20  import java.util.List;
21  
22  import org.junit.Test;
23  import org.junit.runners.Parameterized.Parameters;
24  
25  import static org.junit.Assert.assertNotNull;
26  import static org.junit.Assert.assertTrue;
27  
28  public class ForwardingMessageSplitterTestCase extends AbstractServiceAndFlowTestCase
29  {
30      @Parameters
31      public static Collection<Object[]> parameters()
32      {
33          return Arrays.asList(new Object[][]{
34              {ConfigVariant.SERVICE, "org/mule/test/usecases/routing/forwarding-message-splitter-service.xml"},
35              {ConfigVariant.FLOW, "org/mule/test/usecases/routing/forwarding-message-splitter-flow.xml"}
36          });
37      }
38  
39      public ForwardingMessageSplitterTestCase(ConfigVariant variant, String configResources)
40      {
41          super(variant, configResources);
42      }
43  
44      @Test
45      public void testSyncResponse() throws Exception
46      {
47          MuleClient client = new MuleClient(muleContext);
48  
49          List<Object> payload = new ArrayList<Object>();
50          payload.add("hello");
51          payload.add(new Integer(3));
52          payload.add(new Exception());
53          client.send("vm://in.queue", payload, null);
54          MuleMessage m = client.request("vm://component.1", 2000);
55          assertNotNull(m);
56          assertTrue(m.getPayload() instanceof String);
57          m = client.request("vm://component.2", 2000);
58          assertNotNull(m);
59          assertTrue(m.getPayload() instanceof Integer);
60  
61          m = client.request("vm://error.queue", 2000);
62          assertNotNull(m);
63          assertTrue(m.getPayload() instanceof Exception);
64      }
65  }