1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.endpoints;
12
13 import org.mule.DefaultMuleMessage;
14 import org.mule.api.MuleMessage;
15 import org.mule.api.transformer.DataType;
16 import org.mule.tck.AbstractServiceAndFlowTestCase;
17
18 import java.util.Arrays;
19 import java.util.Collection;
20
21 import org.junit.Test;
22 import org.junit.runners.Parameterized.Parameters;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27
28 public class DynamicEndpointConfigTestCase extends AbstractServiceAndFlowTestCase
29 {
30 @Parameters
31 public static Collection<Object[]> parameters()
32 {
33 return Arrays.asList(new Object[][]{
34 {ConfigVariant.SERVICE, "org/mule/test/integration/endpoints/dynamic-endpoint-config-service.xml"},
35 {ConfigVariant.FLOW, "org/mule/test/integration/endpoints/dynamic-endpoint-config-flow.xml"}
36 });
37 }
38
39 public DynamicEndpointConfigTestCase(ConfigVariant variant, String configResources)
40 {
41 super(variant, configResources);
42 }
43
44 @Test
45 public void testName() throws Exception
46 {
47 MuleMessage msg = new DefaultMuleMessage("Data", muleContext);
48 msg.setOutboundProperty("testProp", "testPath");
49 MuleMessage response = muleContext.getClient().send("vm://in1", msg);
50 assertNotNull(response);
51 assertNull(response.getExceptionPayload());
52 assertEquals("Data Received", response.getPayload(DataType.STRING_DATA_TYPE));
53
54 response = muleContext.getClient().send("vm://in2", msg);
55 assertNotNull(response);
56 assertNull(response.getExceptionPayload());
57 assertEquals("Data Received", response.getPayload(DataType.STRING_DATA_TYPE));
58
59 response = muleContext.getClient().send("vm://in3", msg);
60 assertNotNull(response);
61 assertNull(response.getExceptionPayload());
62 String payload = response.getPayload(DataType.STRING_DATA_TYPE);
63 assertEquals("Data Also Received", payload);
64 }
65 }