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.DefaultMuleMessage;
10  import org.mule.api.MuleMessage;
11  import org.mule.module.client.MuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertNotNull;
17  import static org.junit.Assert.assertTrue;
18  
19  /*
20   * In this Test Case we make use of a Custom Catch All Strategy in order to show how
21   * to send the transformed message instead of the non-transformed message.
22   */
23  public class InboundTransformingCatchAllTestCase extends FunctionalTestCase
24  {
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "org/mule/test/usecases/routing/inbound-transforming-catchall.xml";
30      }
31  
32      @Test
33      public void testNormal() throws Exception
34      {
35          MuleClient client = new MuleClient(muleContext);
36          client.dispatch("vm://in1", new DefaultMuleMessage("HELLO!", muleContext));
37          MuleMessage msg = client.request("vm://catchall", 3000);
38          assertNotNull(msg);
39          assertTrue(msg.getPayload() instanceof String);
40  
41          client.dispatch("vm://in2", new DefaultMuleMessage("HELLO!", muleContext));
42          msg = client.request("vm://catchall", 3000);
43          assertNotNull(msg);
44          assertTrue(msg.getPayload() instanceof byte[]);
45      }
46  }