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.resolvers;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.junit.Test;
14  
15  import static org.junit.Assert.assertEquals;
16  import static org.junit.Assert.assertNotNull;
17  
18  public class MethodEntryPointWithTransformerTestCase extends FunctionalTestCase
19  {
20  
21      @Override
22      protected String getConfigResources()
23      {
24          return "org/mule/test/integration/resolvers/method-entrypoint-with-transformer-config.xml";
25      }
26  
27      /**
28       * Tests that a MethodEntryPointResolver is able to receive the method property
29       * from a MessagePropertyTransformer, that means that the transformer is applied
30       * before resolving that property.
31       */
32      @Test
33      public void testReceivesMethodPropertyFromAPropertyTransformer() throws Exception
34      {
35          MuleClient client = new MuleClient(muleContext);
36          MuleMessage response = client.send("vm://in", "payload", null);
37          assertNotNull(response);
38          assertNotNull(response.getPayload());
39          assertEquals("Transformed payload", response.getPayloadAsString());
40      }
41  
42      /**
43       * Transforms a message for testing purposes. 
44       * <p> Is referenced by the test configuration because it implements the test component method which should be call by the MethodEntryPointResolver.
45       */
46      public String transformMessage(String message)
47      {
48          return "Transformed " + message;
49      }
50  }