View Javadoc

1   /*
2    * $Id: JdbcMessagePropertiesCopyingTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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.transport.jdbc.functional;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.transport.NullPayload;
17  
18  public class JdbcMessagePropertiesCopyingTestCase extends AbstractJdbcFunctionalTestCase
19  {    
20      private static final String PROPERTY_KEY = "custom-key";
21      private static final String PROPERTY_VALUE = "custom-value";
22  
23      protected String getConfigResources()
24      {
25          return super.getConfigResources() + ", jdbc-message-properties-copying.xml";
26      }
27  
28      public void testMessagePropertiesCopying() throws Exception
29      {
30          MuleClient client = new MuleClient(muleContext);
31          
32          MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
33          // provide a valid type header so the JDBC query actually returns something
34          message.setOutboundProperty("type", 1);
35          message.setOutboundProperty(PROPERTY_KEY, PROPERTY_VALUE);
36          
37          MuleMessage result = client.send("vm://in", message);
38          assertNotNull(result);
39          assertNull(result.getExceptionPayload());
40          assertFalse(result.getPayload() instanceof NullPayload);
41          assertEquals(PROPERTY_VALUE, result.getInboundProperty(PROPERTY_KEY));
42      }
43  }