View Javadoc

1   /*
2    * $Id: BindingReturnTypeTestCase.java 19386 2010-09-06 21:57:44Z mike.schilling $
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.integration.routing.nested;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  
17  public class BindingReturnTypeTestCase extends FunctionalTestCase
18  {
19  
20      private static final String PROCESSED = "Processed";
21      private static final int MAGIC_NUMBER = 0xC0DE;
22  
23      @Override
24      protected String getConfigResources()
25      {
26          return "org/mule/test/integration/routing/nested/binding-returns-message.xml";
27      }
28  
29      public void testInvokeBinding() throws Exception
30      {
31          MuleClient client = new MuleClient(muleContext);
32          MuleMessage response = client.send("vm://invoker.in", TEST_MESSAGE, null);
33          assertNotNull(response);
34          assertNull(response.getExceptionPayload());
35          //TODO MULE-4990 this should really be in the inbound scope 
36          assertTrue(response.getInboundProperty(PROCESSED, false));
37          //assertTrue(response.getOutboundProperty(PROCESSED, false));
38          String expected = "Hello " + TEST_MESSAGE + " " + MAGIC_NUMBER;
39          assertEquals(expected, response.getPayload());
40      }
41  
42      public static class Component
43      {
44          private BindingInterface binding;
45  
46          public Object invoke(String s)
47          {
48              MuleMessage result = binding.process(s, new Integer(MAGIC_NUMBER));
49              result.setOutboundProperty(PROCESSED, Boolean.TRUE);
50              return result;
51          }
52          
53          public void setBindingInterface(BindingInterface hello)
54          {
55              this.binding = hello;
56          }
57  
58          public BindingInterface getBindingInterface()
59          {
60              return binding;
61          }
62      }
63      
64      public interface BindingInterface
65      {
66          MuleMessage process(String s, Integer v);
67      }
68      
69  }
70  
71