1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.jdbc.functional;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertFalse;
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.Assert.assertNull;
17
18 import org.mule.DefaultMuleMessage;
19 import org.mule.api.MuleMessage;
20 import org.mule.module.client.MuleClient;
21 import org.mule.transport.NullPayload;
22
23 import java.util.Arrays;
24 import java.util.Collection;
25
26 import org.junit.Test;
27 import org.junit.runners.Parameterized.Parameters;
28
29 public class JdbcMessagePropertiesCopyingTestCase extends AbstractJdbcFunctionalTestCase
30 {
31
32 private static final String PROPERTY_KEY = "custom-key";
33 private static final String PROPERTY_VALUE = "custom-value";
34
35 public JdbcMessagePropertiesCopyingTestCase(ConfigVariant variant, String configResources)
36 {
37 super(variant, configResources);
38 }
39
40 @Parameters
41 public static Collection<Object[]> parameters()
42 {
43 return Arrays.asList(new Object[][]{
44 {ConfigVariant.SERVICE, AbstractJdbcFunctionalTestCase.getConfig() + ", jdbc-message-properties-copying-service.xml"},
45 {ConfigVariant.FLOW, AbstractJdbcFunctionalTestCase.getConfig() + ", jdbc-message-properties-copying-flow.xml"}
46 });
47 }
48
49 @Test
50 public void testMessagePropertiesCopying() throws Exception
51 {
52 MuleClient client = new MuleClient(muleContext);
53
54 MuleMessage message = new DefaultMuleMessage(TEST_MESSAGE, muleContext);
55
56 message.setOutboundProperty("type", 1);
57 message.setOutboundProperty(PROPERTY_KEY, PROPERTY_VALUE);
58
59 MuleMessage result = client.send("vm://in", message);
60 assertNotNull(result);
61 assertNull(result.getExceptionPayload());
62 assertFalse(result.getPayload() instanceof NullPayload);
63 assertEquals(PROPERTY_VALUE, result.getInboundProperty(PROPERTY_KEY));
64 }
65 }